From cd8c5882372cdb35c25f1ea2542f4b2f904574f4 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 20 Nov 2023 15:54:23 +0100 Subject: [PATCH 1/6] Updated constraints (used new interfaces) --- src/Constraint/Pipeline/PipelineExtractsLike.php | 8 ++++---- src/Constraint/Pipeline/PipelineLoadsLike.php | 16 ++++++++-------- .../Pipeline/PipelineTransformsLike.php | 16 ++++++++-------- src/Constraint/Pipeline/PipelineWritesFile.php | 16 ++++++++-------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Constraint/Pipeline/PipelineExtractsLike.php b/src/Constraint/Pipeline/PipelineExtractsLike.php index 82c0e67..d9d5794 100644 --- a/src/Constraint/Pipeline/PipelineExtractsLike.php +++ b/src/Constraint/Pipeline/PipelineExtractsLike.php @@ -5,8 +5,8 @@ namespace Kiboko\Component\PHPUnitExtension\Constraint\Pipeline; use Kiboko\Contract\Pipeline\ExtractorInterface; -use Kiboko\Contract\Pipeline\NullRejection; -use Kiboko\Contract\Pipeline\NullState; +use Kiboko\Contract\Pipeline\NullStepRejection; +use Kiboko\Contract\Pipeline\NullStepState; use Kiboko\Contract\Pipeline\PipelineRunnerInterface; use PHPUnit\Framework\Constraint\Constraint; @@ -67,8 +67,8 @@ public function matches($other): bool $iterator = $this->runner->run( $this->asIterator($extract), $this->passThroughCoroutine(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ); $both->attachIterator($iterator); diff --git a/src/Constraint/Pipeline/PipelineLoadsLike.php b/src/Constraint/Pipeline/PipelineLoadsLike.php index 728e077..5e7c7d2 100644 --- a/src/Constraint/Pipeline/PipelineLoadsLike.php +++ b/src/Constraint/Pipeline/PipelineLoadsLike.php @@ -6,8 +6,8 @@ use Kiboko\Contract\Pipeline\FlushableInterface; use Kiboko\Contract\Pipeline\LoaderInterface; -use Kiboko\Contract\Pipeline\NullRejection; -use Kiboko\Contract\Pipeline\NullState; +use Kiboko\Contract\Pipeline\NullStepRejection; +use Kiboko\Contract\Pipeline\NullStepState; use Kiboko\Contract\Pipeline\PipelineRunnerInterface; use PHPUnit\Framework\Constraint\Constraint; @@ -67,8 +67,8 @@ public function matches($other): bool $this->runner->run( $this->asIterator($this->source), $other->load(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ) ); $iterator->append( @@ -78,16 +78,16 @@ public function matches($other): bool yield; yield $other->flush(); })(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ) ); } else { $iterator = $this->runner->run( $this->asIterator($this->source), $other->load(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ); } $both->attachIterator($iterator); diff --git a/src/Constraint/Pipeline/PipelineTransformsLike.php b/src/Constraint/Pipeline/PipelineTransformsLike.php index 8a1bbfd..fb1f8b5 100644 --- a/src/Constraint/Pipeline/PipelineTransformsLike.php +++ b/src/Constraint/Pipeline/PipelineTransformsLike.php @@ -5,8 +5,8 @@ namespace Kiboko\Component\PHPUnitExtension\Constraint\Pipeline; use Kiboko\Contract\Pipeline\FlushableInterface; -use Kiboko\Contract\Pipeline\NullRejection; -use Kiboko\Contract\Pipeline\NullState; +use Kiboko\Contract\Pipeline\NullStepRejection; +use Kiboko\Contract\Pipeline\NullStepState; use Kiboko\Contract\Pipeline\PipelineRunnerInterface; use Kiboko\Contract\Pipeline\TransformerInterface; use PHPUnit\Framework\Constraint\Constraint; @@ -67,8 +67,8 @@ public function matches($other): bool $this->runner->run( $this->asIterator($this->source), $other->transform(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ) ); $iterator->append( @@ -78,16 +78,16 @@ public function matches($other): bool yield; yield $other->flush(); })(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ) ); } else { $iterator = $this->runner->run( $this->asIterator($this->source), $other->transform(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ); } $both->attachIterator($iterator); diff --git a/src/Constraint/Pipeline/PipelineWritesFile.php b/src/Constraint/Pipeline/PipelineWritesFile.php index f64dbc9..fd2c738 100644 --- a/src/Constraint/Pipeline/PipelineWritesFile.php +++ b/src/Constraint/Pipeline/PipelineWritesFile.php @@ -6,8 +6,8 @@ use Kiboko\Contract\Pipeline\FlushableInterface; use Kiboko\Contract\Pipeline\LoaderInterface; -use Kiboko\Contract\Pipeline\NullRejection; -use Kiboko\Contract\Pipeline\NullState; +use Kiboko\Contract\Pipeline\NullStepRejection; +use Kiboko\Contract\Pipeline\NullStepState; use Kiboko\Contract\Pipeline\PipelineRunnerInterface; use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\Constraint\FileExists; @@ -58,8 +58,8 @@ public function matches($other): bool $this->runner->run( $this->asIterator($this->source), $other->load(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ) ); $iterator->append( @@ -69,16 +69,16 @@ public function matches($other): bool yield; yield $other->flush(); })(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ) ); } else { $iterator = $this->runner->run( $this->asIterator($this->source), $other->load(), - new NullRejection(), - new NullState(), + new NullStepRejection(), + new NullStepState(), ); } From 12691a45bfc41fdb84e57d4d29ee27ddb71de2d5 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 20 Nov 2023 17:23:57 +0100 Subject: [PATCH 2/6] Ran php-cs-fixer --- src/Constraint/Pipeline/PipelineWritesFile.php | 3 +-- src/Mock/FileSystemBuilder.php | 3 +-- src/Mock/HttpClientBuilder.php | 3 +-- src/Mock/RequestMatcher/RequestMatcherBuilder.php | 3 +-- src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php | 4 +--- src/Mock/ResponseBuilder.php | 3 +-- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Constraint/Pipeline/PipelineWritesFile.php b/src/Constraint/Pipeline/PipelineWritesFile.php index fd2c738..85e4e06 100644 --- a/src/Constraint/Pipeline/PipelineWritesFile.php +++ b/src/Constraint/Pipeline/PipelineWritesFile.php @@ -22,8 +22,7 @@ public function __construct( private readonly iterable $source, private readonly string $expected, private readonly PipelineRunnerInterface $runner, - ) { - } + ) {} /** * @param list $iterable diff --git a/src/Mock/FileSystemBuilder.php b/src/Mock/FileSystemBuilder.php index 5c090a6..fa2be7c 100644 --- a/src/Mock/FileSystemBuilder.php +++ b/src/Mock/FileSystemBuilder.php @@ -11,8 +11,7 @@ { public function __construct( private string $mockedFilesystem, - ) { - } + ) {} public function getNode(): Node\Expr { diff --git a/src/Mock/HttpClientBuilder.php b/src/Mock/HttpClientBuilder.php index a36c794..195dfb3 100644 --- a/src/Mock/HttpClientBuilder.php +++ b/src/Mock/HttpClientBuilder.php @@ -16,8 +16,7 @@ final class HttpClientBuilder implements Builder public function __construct( private readonly Mock\ResponseFactoryBuilder $responseFactory - ) { - } + ) {} public function expectResponse( Mock\RequestMatcher\RequestMatcherBuilderInterface $requestMatcher, diff --git a/src/Mock/RequestMatcher/RequestMatcherBuilder.php b/src/Mock/RequestMatcher/RequestMatcherBuilder.php index ee5a8c0..9d489d0 100644 --- a/src/Mock/RequestMatcher/RequestMatcherBuilder.php +++ b/src/Mock/RequestMatcher/RequestMatcherBuilder.php @@ -14,8 +14,7 @@ public function __construct( private readonly ?string $host = null, private $methods = [], private $schemes = [] - ) { - } + ) {} public function getNode(): Node { diff --git a/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php b/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php index c534a47..bed99d7 100644 --- a/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php +++ b/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php @@ -6,6 +6,4 @@ use PhpParser\Builder; -interface RequestMatcherBuilderInterface extends Builder -{ -} +interface RequestMatcherBuilderInterface extends Builder {} diff --git a/src/Mock/ResponseBuilder.php b/src/Mock/ResponseBuilder.php index ab0230d..9874115 100644 --- a/src/Mock/ResponseBuilder.php +++ b/src/Mock/ResponseBuilder.php @@ -11,8 +11,7 @@ { public function __construct( private string $path, - ) { - } + ) {} public function getNode(): Node { From 90ca485ccb0e012f429c999d8a8c8c6a0f43fb11 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 21 Nov 2023 11:17:32 +0100 Subject: [PATCH 3/6] Fixed phpstan error --- .../Builder/BuilderProducesCodeThat.php | 2 +- src/Constraint/Pipeline/IteratesLike.php | 4 ++-- src/Constraint/Pipeline/PipelineExtractsLike.php | 4 ++-- src/Constraint/Pipeline/PipelineLoadsLike.php | 4 ++-- .../Pipeline/PipelineTransformsLike.php | 4 ++-- src/Constraint/Pipeline/PipelineWritesFile.php | 6 ++---- src/Mock/ApiClientMockBuilder.php | 1 + src/Mock/ExceptionBuilder.php | 14 ++++++-------- .../RequestMatcher/RequestMatcherBuilder.php | 16 ++++++++++------ .../RequestMatcherBuilderInterface.php | 5 ++++- src/Mock/ResponseBuilder.php | 2 +- 11 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/Constraint/Builder/BuilderProducesCodeThat.php b/src/Constraint/Builder/BuilderProducesCodeThat.php index 0209238..cef1c62 100644 --- a/src/Constraint/Builder/BuilderProducesCodeThat.php +++ b/src/Constraint/Builder/BuilderProducesCodeThat.php @@ -14,7 +14,7 @@ final class BuilderProducesCodeThat extends UnaryOperator { public function __construct( private readonly string $builderCompilePath, - $constraint, + mixed $constraint, ) { parent::__construct($constraint); } diff --git a/src/Constraint/Pipeline/IteratesLike.php b/src/Constraint/Pipeline/IteratesLike.php index 33e755d..2d161de 100644 --- a/src/Constraint/Pipeline/IteratesLike.php +++ b/src/Constraint/Pipeline/IteratesLike.php @@ -37,7 +37,7 @@ private function asIterator(iterable $iterable): \Iterator return new \IteratorIterator($iterable); } - public function matches($other): bool + public function matches(mixed $other): bool { $both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY); @@ -54,7 +54,7 @@ public function matches($other): bool return !$iterator->valid(); } - protected function failureDescription($other): string + protected function failureDescription(mixed $other): string { return sprintf( '%s iterates like %s', diff --git a/src/Constraint/Pipeline/PipelineExtractsLike.php b/src/Constraint/Pipeline/PipelineExtractsLike.php index d9d5794..2c57f46 100644 --- a/src/Constraint/Pipeline/PipelineExtractsLike.php +++ b/src/Constraint/Pipeline/PipelineExtractsLike.php @@ -50,7 +50,7 @@ private function passThroughCoroutine(): \Generator } } - public function matches($other): bool + public function matches(mixed $other): bool { $both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY); @@ -82,7 +82,7 @@ public function matches($other): bool return !$iterator->valid(); } - protected function failureDescription($other): string + protected function failureDescription(mixed $other): string { return sprintf( '%s pipeline extracts like %s', diff --git a/src/Constraint/Pipeline/PipelineLoadsLike.php b/src/Constraint/Pipeline/PipelineLoadsLike.php index 5e7c7d2..d778df9 100644 --- a/src/Constraint/Pipeline/PipelineLoadsLike.php +++ b/src/Constraint/Pipeline/PipelineLoadsLike.php @@ -47,7 +47,7 @@ private function asIterator(iterable $iterable): \Iterator return new \IteratorIterator($iterable); } - public function matches($other): bool + public function matches(mixed $other): bool { $both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY); @@ -102,7 +102,7 @@ public function matches($other): bool return !$iterator->valid(); } - protected function failureDescription($other): string + protected function failureDescription(mixed $other): string { return sprintf( '%s pipeline loads like %s', diff --git a/src/Constraint/Pipeline/PipelineTransformsLike.php b/src/Constraint/Pipeline/PipelineTransformsLike.php index fb1f8b5..ce1ac94 100644 --- a/src/Constraint/Pipeline/PipelineTransformsLike.php +++ b/src/Constraint/Pipeline/PipelineTransformsLike.php @@ -47,7 +47,7 @@ private function asIterator(iterable $iterable): \Iterator return new \IteratorIterator($iterable); } - public function matches($other): bool + public function matches(mixed $other): bool { $both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY); @@ -102,7 +102,7 @@ public function matches($other): bool return !$iterator->valid(); } - protected function failureDescription($other): string + protected function failureDescription(mixed $other): string { return sprintf( '%s pipeline transforms like %s', diff --git a/src/Constraint/Pipeline/PipelineWritesFile.php b/src/Constraint/Pipeline/PipelineWritesFile.php index 85e4e06..c735cd8 100644 --- a/src/Constraint/Pipeline/PipelineWritesFile.php +++ b/src/Constraint/Pipeline/PipelineWritesFile.php @@ -41,7 +41,7 @@ private function asIterator(iterable $iterable): \Iterator return new \IteratorIterator($iterable); } - public function matches($other): bool + public function matches(mixed $other): bool { if (!$other instanceof LoaderInterface) { $this->fail($other, strtr('Expected an instance of %expected%, but got %actual%.', [ @@ -81,15 +81,13 @@ public function matches($other): bool ); } - iterator_count($iterator); - $constraint = new FileExists(); $constraint->evaluate($this->expected); return !$iterator->valid(); } - protected function failureDescription($other): string + protected function failureDescription(mixed $other): string { return sprintf( '%s pipeline writes file %s', diff --git a/src/Mock/ApiClientMockBuilder.php b/src/Mock/ApiClientMockBuilder.php index 223b0b4..b798260 100644 --- a/src/Mock/ApiClientMockBuilder.php +++ b/src/Mock/ApiClientMockBuilder.php @@ -14,6 +14,7 @@ final class ApiClientMockBuilder implements Builder { private Node\Expr $node; + /** @param array $mockedArgs */ public function __construct( private readonly string $mockedClientBuilder, private readonly ?array $mockedArgs = [] diff --git a/src/Mock/ExceptionBuilder.php b/src/Mock/ExceptionBuilder.php index 5caa7d0..172dfa4 100644 --- a/src/Mock/ExceptionBuilder.php +++ b/src/Mock/ExceptionBuilder.php @@ -19,17 +19,15 @@ public function __construct( $this->arguments = $arguments; } - public function getNode(): Node + public function getNode(): Node\Expr { return new Node\Expr\New_( class: new Node\Name\FullyQualified($this->class), - args: [ - array_map( - fn (Node\Expr $value, int|string $key) => !\is_string($key) ? new Node\Arg(value: $value) : new Node\Arg(value: $value, name: new Node\Identifier($key)), - $this->arguments, - array_keys($this->arguments), - ), - ] + args: array_map( + fn (Node\Expr $value, int|string $key) => !\is_string($key) ? new Node\Arg(value: $value) : new Node\Arg(value: $value, name: new Node\Identifier($key)), + $this->arguments, + array_keys($this->arguments), + ), ); } } diff --git a/src/Mock/RequestMatcher/RequestMatcherBuilder.php b/src/Mock/RequestMatcher/RequestMatcherBuilder.php index 9d489d0..96df62a 100644 --- a/src/Mock/RequestMatcher/RequestMatcherBuilder.php +++ b/src/Mock/RequestMatcher/RequestMatcherBuilder.php @@ -7,16 +7,20 @@ use Http\Message\RequestMatcher; use PhpParser\Node; -final class RequestMatcherBuilder implements RequestMatcherBuilderInterface +final readonly class RequestMatcherBuilder implements RequestMatcherBuilderInterface { + /** + * @param list $methods + * @param list $schemes + */ public function __construct( - private readonly ?string $path = null, - private readonly ?string $host = null, - private $methods = [], - private $schemes = [] + private ?string $path = null, + private ?string $host = null, + private array $methods = [], + private array $schemes = [] ) {} - public function getNode(): Node + public function getNode(): Node\Expr { return new Node\Expr\New_( class: new Node\Name\FullyQualified(RequestMatcher::class), diff --git a/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php b/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php index bed99d7..f303d4f 100644 --- a/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php +++ b/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php @@ -5,5 +5,8 @@ namespace Kiboko\Component\PHPUnitExtension\Mock\RequestMatcher; use PhpParser\Builder; +use PhpParser\Node; -interface RequestMatcherBuilderInterface extends Builder {} +interface RequestMatcherBuilderInterface extends Builder { + public function getNode(): Node\Expr; +} diff --git a/src/Mock/ResponseBuilder.php b/src/Mock/ResponseBuilder.php index 9874115..173f2ba 100644 --- a/src/Mock/ResponseBuilder.php +++ b/src/Mock/ResponseBuilder.php @@ -13,7 +13,7 @@ public function __construct( private string $path, ) {} - public function getNode(): Node + public function getNode(): Node\Expr { return new Node\Expr\Include_(new Node\Scalar\String_($this->path), Node\Expr\Include_::TYPE_INCLUDE); } From 488dd94cc746228de04a3c93c515d9d181fd2d53 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 21 Nov 2023 11:20:03 +0100 Subject: [PATCH 4/6] Ran php-cs-fixer --- src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php b/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php index f303d4f..02050a6 100644 --- a/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php +++ b/src/Mock/RequestMatcher/RequestMatcherBuilderInterface.php @@ -7,6 +7,7 @@ use PhpParser\Builder; use PhpParser\Node; -interface RequestMatcherBuilderInterface extends Builder { +interface RequestMatcherBuilderInterface extends Builder +{ public function getNode(): Node\Expr; } From d4bdacc3add93d625da341e5d02be05691a1f374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Tue, 21 Nov 2023 13:53:03 +0100 Subject: [PATCH 5/6] Updated PHPStan level from 3 to 8 --- .github/workflows/phpstan-6.yaml | 23 ------------------- .github/workflows/phpstan-7.yaml | 23 ------------------- .github/workflows/phpstan-8.yaml | 23 ------------------- .../{phpstan-5.yaml => phpstan-9.yaml} | 4 ++-- .github/workflows/quality.yaml | 4 ++-- src/BuilderTestCase.php | 4 ++++ .../Pipeline/PipelineExtractsLike.php | 7 ++++-- src/Mock/ApiClientMockBuilder.php | 2 +- 8 files changed, 14 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/phpstan-6.yaml delete mode 100644 .github/workflows/phpstan-7.yaml delete mode 100644 .github/workflows/phpstan-8.yaml rename .github/workflows/{phpstan-5.yaml => phpstan-9.yaml} (93%) diff --git a/.github/workflows/phpstan-6.yaml b/.github/workflows/phpstan-6.yaml deleted file mode 100644 index a367107..0000000 --- a/.github/workflows/phpstan-6.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: PHPStan level 6 -on: push -jobs: - phpstan: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: '**/vendor' - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - uses: php-actions/composer@v6 - with: - args: --prefer-dist - php_version: '8.2' - - name: PHPStan - uses: php-actions/phpstan@v3 - with: - path: src/ - level: 6 - php_version: '8.2' diff --git a/.github/workflows/phpstan-7.yaml b/.github/workflows/phpstan-7.yaml deleted file mode 100644 index cad733d..0000000 --- a/.github/workflows/phpstan-7.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: PHPStan level 7 -on: push -jobs: - phpstan: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: '**/vendor' - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - uses: php-actions/composer@v6 - with: - args: --prefer-dist - php_version: '8.2' - - name: PHPStan - uses: php-actions/phpstan@v3 - with: - path: src/ - level: 7 - php_version: '8.2' diff --git a/.github/workflows/phpstan-8.yaml b/.github/workflows/phpstan-8.yaml deleted file mode 100644 index 8d7aec6..0000000 --- a/.github/workflows/phpstan-8.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: PHPStan level 8 -on: push -jobs: - phpstan: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: '**/vendor' - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - uses: php-actions/composer@v6 - with: - args: --prefer-dist - php_version: '8.2' - - name: PHPStan - uses: php-actions/phpstan@v3 - with: - path: src/ - level: 8 - php_version: '8.2' diff --git a/.github/workflows/phpstan-5.yaml b/.github/workflows/phpstan-9.yaml similarity index 93% rename from .github/workflows/phpstan-5.yaml rename to .github/workflows/phpstan-9.yaml index 906b4c9..9e64ec4 100644 --- a/.github/workflows/phpstan-5.yaml +++ b/.github/workflows/phpstan-9.yaml @@ -1,4 +1,4 @@ -name: PHPStan level 5 +name: PHPStan level 9 on: push jobs: phpstan: @@ -19,5 +19,5 @@ jobs: uses: php-actions/phpstan@v3 with: path: src/ - level: 5 + level: 9 php_version: '8.2' diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index 7457967..c3e2001 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -1,4 +1,4 @@ -name: Quality +name: Quality (PHPSpec level 8) on: push jobs: cs-fixer: @@ -34,5 +34,5 @@ jobs: uses: php-actions/phpstan@v3 with: path: src/ - level: 3 + level: 8 php_version: '8.2' diff --git a/src/BuilderTestCase.php b/src/BuilderTestCase.php index 632b71e..49488f6 100644 --- a/src/BuilderTestCase.php +++ b/src/BuilderTestCase.php @@ -25,6 +25,10 @@ protected function tearDown(): void protected function getBuilderCompilePath(): string { + if ($this->fs === null) { + throw new \RuntimeException('The virtual file system was not initialized. The '.__METHOD__.' method should be called after the '.get_class($this).'::setUp() method was called and after the '.get_class($this).'::tearDown() method is called.'); + } + return $this->fs->url(); } diff --git a/src/Constraint/Pipeline/PipelineExtractsLike.php b/src/Constraint/Pipeline/PipelineExtractsLike.php index 2c57f46..16d4aa1 100644 --- a/src/Constraint/Pipeline/PipelineExtractsLike.php +++ b/src/Constraint/Pipeline/PipelineExtractsLike.php @@ -4,6 +4,7 @@ namespace Kiboko\Component\PHPUnitExtension\Constraint\Pipeline; +use Kiboko\Contract\Bucket\ResultBucketInterface; use Kiboko\Contract\Pipeline\ExtractorInterface; use Kiboko\Contract\Pipeline\NullStepRejection; use Kiboko\Contract\Pipeline\NullStepState; @@ -26,9 +27,11 @@ public function __construct( } /** - * @param list $iterable + * @template ItemType * - * @return \Iterator + * @param list $iterable + * + * @return \Iterator */ private function asIterator(iterable $iterable): \Iterator { diff --git a/src/Mock/ApiClientMockBuilder.php b/src/Mock/ApiClientMockBuilder.php index b798260..1be4b69 100644 --- a/src/Mock/ApiClientMockBuilder.php +++ b/src/Mock/ApiClientMockBuilder.php @@ -17,7 +17,7 @@ final class ApiClientMockBuilder implements Builder /** @param array $mockedArgs */ public function __construct( private readonly string $mockedClientBuilder, - private readonly ?array $mockedArgs = [] + private readonly array $mockedArgs = [] ) { $this->node = new Node\Expr\New_( class: new Node\Name\FullyQualified($this->mockedClientBuilder), From c69f259284ad6a1b9c1c5bd28dd0a730fbe6f702 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 21 Nov 2023 12:54:11 +0000 Subject: [PATCH 6/6] [rector] Rector fixes --- src/BuilderTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BuilderTestCase.php b/src/BuilderTestCase.php index 49488f6..083b1b4 100644 --- a/src/BuilderTestCase.php +++ b/src/BuilderTestCase.php @@ -26,7 +26,7 @@ protected function tearDown(): void protected function getBuilderCompilePath(): string { if ($this->fs === null) { - throw new \RuntimeException('The virtual file system was not initialized. The '.__METHOD__.' method should be called after the '.get_class($this).'::setUp() method was called and after the '.get_class($this).'::tearDown() method is called.'); + throw new \RuntimeException('The virtual file system was not initialized. The '.__METHOD__.' method should be called after the '.static::class.'::setUp() method was called and after the '.static::class.'::tearDown() method is called.'); } return $this->fs->url();