From 2e621c4971368f8c0f2a93aa9a069e455693ed7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Mon, 13 Nov 2023 12:23:10 +0100 Subject: [PATCH 1/6] Updated pipeline-contracts package to add the step codes everywhere it is necessary --- src/ExtractingInterface.php | 5 +++-- src/LoadingInterface.php | 5 +++-- src/NullRejection.php | 2 +- src/NullState.php | 6 +++--- src/RejectionInterface.php | 3 ++- src/RejectionWithReasonInterface.php | 10 ---------- src/StateInterface.php | 6 +++--- src/StepCodeInterface.php | 9 +++++++++ src/StepRejectionInterface.php | 16 ++++++++++++++++ src/StepStateInterface.php | 14 ++++++++++++++ src/TransformingInterface.php | 5 +++-- 11 files changed, 57 insertions(+), 24 deletions(-) delete mode 100644 src/RejectionWithReasonInterface.php create mode 100644 src/StepCodeInterface.php create mode 100644 src/StepRejectionInterface.php create mode 100644 src/StepStateInterface.php diff --git a/src/ExtractingInterface.php b/src/ExtractingInterface.php index 8f46007..383e8d2 100644 --- a/src/ExtractingInterface.php +++ b/src/ExtractingInterface.php @@ -12,8 +12,9 @@ interface ExtractingInterface * @param ExtractorInterface $extractor */ public function extract( + StepCodeInterface $step, ExtractorInterface $extractor, - RejectionInterface $rejection, - StateInterface $state, + StepRejectionInterface $rejection, + StepStateInterface $state, ): self; } diff --git a/src/LoadingInterface.php b/src/LoadingInterface.php index 3dc720f..073c97b 100644 --- a/src/LoadingInterface.php +++ b/src/LoadingInterface.php @@ -12,8 +12,9 @@ interface LoadingInterface * @param LoaderInterface $loader */ public function load( + StepCodeInterface $step, LoaderInterface $loader, - RejectionInterface $rejection, - StateInterface $state, + StepRejectionInterface $rejection, + StepStateInterface $state, ): self; } diff --git a/src/NullRejection.php b/src/NullRejection.php index bd5b239..b2d5ab7 100644 --- a/src/NullRejection.php +++ b/src/NullRejection.php @@ -12,7 +12,7 @@ public function initialize(): void } /** @param non-empty-array|object $rejection */ - public function reject(array|object $rejection, \Throwable $exception = null, string $reason = null): void + public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null, string $reason = null): void { // NOOP } diff --git a/src/NullState.php b/src/NullState.php index 437b6f9..c9b0970 100644 --- a/src/NullState.php +++ b/src/NullState.php @@ -11,17 +11,17 @@ public function initialize(int $start = 0): void // NOOP } - public function accept(int $step = 1): void + public function accept(StepCodeInterface $step, int $count = 1): void { // NOOP } - public function reject(int $step = 1): void + public function reject(StepCodeInterface $step, int $count = 1): void { // NOOP } - public function error(int $step = 1): void + public function error(StepCodeInterface $step, int $count = 1): void { // NOOP } diff --git a/src/RejectionInterface.php b/src/RejectionInterface.php index a11fdab..3dd1dda 100644 --- a/src/RejectionInterface.php +++ b/src/RejectionInterface.php @@ -9,7 +9,8 @@ interface RejectionInterface public function initialize(): void; /** @param non-empty-array|object $rejection */ - public function reject(array|object $rejection, \Throwable $exception = null, string $reason = null): void; + public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null): void; + public function rejectWithReason(StepCodeInterface $step, object|array $rejection, string $reason, null|\Throwable $exception = null): void; public function teardown(): void; } diff --git a/src/RejectionWithReasonInterface.php b/src/RejectionWithReasonInterface.php deleted file mode 100644 index a8aedf7..0000000 --- a/src/RejectionWithReasonInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -|object $rejection */ + public function reject(array|object $rejection, \Throwable $exception = null): void; + public function rejectWithReason(object|array $rejection, string $reason, null|\Throwable $exception = null): void; + + public function teardown(): void; +} diff --git a/src/StepStateInterface.php b/src/StepStateInterface.php new file mode 100644 index 0000000..00f42b1 --- /dev/null +++ b/src/StepStateInterface.php @@ -0,0 +1,14 @@ + $transformer */ public function transform( + StepCodeInterface $step, TransformerInterface $transformer, - RejectionInterface $rejection, - StateInterface $state, + StepRejectionInterface $rejection, + StepStateInterface $state, ): self; } From 6d710d0b535ef1de913193d75dabe4c69e1d4d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Mon, 13 Nov 2023 12:25:40 +0100 Subject: [PATCH 2/6] Updated pipeline-contracts package to add the step codes everywhere it is necessary --- composer.json | 2 +- src/RejectedItemException.php | 4 +++- src/RejectionInterface.php | 1 + src/RunnableInterface.php | 4 +++- src/StepRejectionInterface.php | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 1f04273..37b91e1 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "extra": { "branch-alias": { - "dev-main": "0.4.x-dev" + "dev-main": "0.5.x-dev" } } } diff --git a/src/RejectedItemException.php b/src/RejectedItemException.php index cbd61c1..bbc3f47 100644 --- a/src/RejectedItemException.php +++ b/src/RejectedItemException.php @@ -4,4 +4,6 @@ namespace Kiboko\Contract\Pipeline; -final class RejectedItemException extends \RuntimeException {} +final class RejectedItemException extends \RuntimeException +{ +} diff --git a/src/RejectionInterface.php b/src/RejectionInterface.php index 3dd1dda..63f18ec 100644 --- a/src/RejectionInterface.php +++ b/src/RejectionInterface.php @@ -10,6 +10,7 @@ public function initialize(): void; /** @param non-empty-array|object $rejection */ public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null): void; + public function rejectWithReason(StepCodeInterface $step, object|array $rejection, string $reason, null|\Throwable $exception = null): void; public function teardown(): void; diff --git a/src/RunnableInterface.php b/src/RunnableInterface.php index 835e2e1..07695fe 100644 --- a/src/RunnableInterface.php +++ b/src/RunnableInterface.php @@ -7,4 +7,6 @@ use Kiboko\Contract\Satellite\RunnableInterface as SatelliteRunableInterface; /** @deprecated Use \Kiboko\Contract\Job\RunnableInterface instead */ -interface RunnableInterface extends SatelliteRunableInterface {} +interface RunnableInterface extends SatelliteRunableInterface +{ +} diff --git a/src/StepRejectionInterface.php b/src/StepRejectionInterface.php index 1158302..a18b8df 100644 --- a/src/StepRejectionInterface.php +++ b/src/StepRejectionInterface.php @@ -10,6 +10,7 @@ public function initialize(): void; /** @param non-empty-array|object $rejection */ public function reject(array|object $rejection, \Throwable $exception = null): void; + public function rejectWithReason(object|array $rejection, string $reason, null|\Throwable $exception = null): void; public function teardown(): void; From b5fe3ef54e32985e9e4e509fbee3e8b291dd221a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Mon, 13 Nov 2023 12:28:31 +0100 Subject: [PATCH 3/6] Run CS-Fixer --- src/RejectedItemException.php | 4 +--- src/RejectionInterface.php | 2 +- src/RunnableInterface.php | 4 +--- src/StepCodeInterface.php | 4 +--- src/StepRejectionInterface.php | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/RejectedItemException.php b/src/RejectedItemException.php index bbc3f47..cbd61c1 100644 --- a/src/RejectedItemException.php +++ b/src/RejectedItemException.php @@ -4,6 +4,4 @@ namespace Kiboko\Contract\Pipeline; -final class RejectedItemException extends \RuntimeException -{ -} +final class RejectedItemException extends \RuntimeException {} diff --git a/src/RejectionInterface.php b/src/RejectionInterface.php index 63f18ec..4d6b4cd 100644 --- a/src/RejectionInterface.php +++ b/src/RejectionInterface.php @@ -11,7 +11,7 @@ public function initialize(): void; /** @param non-empty-array|object $rejection */ public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null): void; - public function rejectWithReason(StepCodeInterface $step, object|array $rejection, string $reason, null|\Throwable $exception = null): void; + public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, \Throwable $exception = null): void; public function teardown(): void; } diff --git a/src/RunnableInterface.php b/src/RunnableInterface.php index 07695fe..835e2e1 100644 --- a/src/RunnableInterface.php +++ b/src/RunnableInterface.php @@ -7,6 +7,4 @@ use Kiboko\Contract\Satellite\RunnableInterface as SatelliteRunableInterface; /** @deprecated Use \Kiboko\Contract\Job\RunnableInterface instead */ -interface RunnableInterface extends SatelliteRunableInterface -{ -} +interface RunnableInterface extends SatelliteRunableInterface {} diff --git a/src/StepCodeInterface.php b/src/StepCodeInterface.php index d860c50..a5c48b0 100644 --- a/src/StepCodeInterface.php +++ b/src/StepCodeInterface.php @@ -4,6 +4,4 @@ namespace Kiboko\Contract\Pipeline; -interface StepCodeInterface extends \Stringable -{ -} +interface StepCodeInterface extends \Stringable {} diff --git a/src/StepRejectionInterface.php b/src/StepRejectionInterface.php index a18b8df..bc58834 100644 --- a/src/StepRejectionInterface.php +++ b/src/StepRejectionInterface.php @@ -11,7 +11,7 @@ public function initialize(): void; /** @param non-empty-array|object $rejection */ public function reject(array|object $rejection, \Throwable $exception = null): void; - public function rejectWithReason(object|array $rejection, string $reason, null|\Throwable $exception = null): void; + public function rejectWithReason(array|object $rejection, string $reason, \Throwable $exception = null): void; public function teardown(): void; } From 83934dc1d6775633f1c93ce87e4313f29800edc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Mon, 13 Nov 2023 12:29:58 +0100 Subject: [PATCH 4/6] Fixed a missing method in the NullRejection --- src/NullRejection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NullRejection.php b/src/NullRejection.php index b2d5ab7..ee503f9 100644 --- a/src/NullRejection.php +++ b/src/NullRejection.php @@ -17,6 +17,11 @@ public function reject(StepCodeInterface $step, array|object $rejection, \Throwa // NOOP } + public function rejectWithReason(StepCodeInterface $step, object|array $rejection, string $reason, \Throwable $exception = null): void + { + // NOOP + } + public function teardown(): void { // NOOP From b9264b88ca913a31433dcf478e62ba4d007e0ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Mon, 13 Nov 2023 12:36:18 +0100 Subject: [PATCH 5/6] Fixed PHPStan issues, upgraded to level 5 --- .github/workflows/phpstan-5.yaml | 24 ------------------------ .github/workflows/quality.yaml | 2 +- src/NullRejection.php | 3 ++- src/PipelineRunnerInterface.php | 2 +- src/RejectionInterface.php | 3 ++- 5 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/phpstan-5.yaml diff --git a/.github/workflows/phpstan-5.yaml b/.github/workflows/phpstan-5.yaml deleted file mode 100644 index 2488785..0000000 --- a/.github/workflows/phpstan-5.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: PHPStan level 5 -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: 5 - php_version: '8.2' diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index c1791da..89bf98b 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -34,5 +34,5 @@ jobs: uses: php-actions/phpstan@v3 with: path: src/ - level: 4 + level: 5 php_version: '8.2' diff --git a/src/NullRejection.php b/src/NullRejection.php index ee503f9..670956f 100644 --- a/src/NullRejection.php +++ b/src/NullRejection.php @@ -11,12 +11,13 @@ public function initialize(): void // NOOP } - /** @param non-empty-array|object $rejection */ + /** @param non-empty-array|object $rejection */ public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null, string $reason = null): void { // NOOP } + /** @param non-empty-array|object $rejection */ public function rejectWithReason(StepCodeInterface $step, object|array $rejection, string $reason, \Throwable $exception = null): void { // NOOP diff --git a/src/PipelineRunnerInterface.php b/src/PipelineRunnerInterface.php index 83618e9..24b737f 100644 --- a/src/PipelineRunnerInterface.php +++ b/src/PipelineRunnerInterface.php @@ -12,7 +12,7 @@ interface PipelineRunnerInterface { /** - * @param \Iterator $source + * @param \Iterator $source * @param \Generator, void> $async * * @return \Iterator diff --git a/src/RejectionInterface.php b/src/RejectionInterface.php index 4d6b4cd..eaa3409 100644 --- a/src/RejectionInterface.php +++ b/src/RejectionInterface.php @@ -8,9 +8,10 @@ interface RejectionInterface { public function initialize(): void; - /** @param non-empty-array|object $rejection */ + /** @param non-empty-array|object $rejection */ public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null): void; + /** @param non-empty-array|object $rejection */ public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, \Throwable $exception = null): void; public function teardown(): void; From bc4b79fa15bcc60eddcd6e74724d2eac2a5c86ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Mon, 13 Nov 2023 12:37:52 +0100 Subject: [PATCH 6/6] Fixed PHPStan issues, upgraded to level 5 --- .github/workflows/quality.yaml | 2 +- src/NullRejection.php | 2 +- src/PipelineRunnerInterface.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index 89bf98b..920b797 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -1,4 +1,4 @@ -name: Quality (PHPStan level 4) +name: Quality (PHPStan level 5) on: push jobs: cs-fixer: diff --git a/src/NullRejection.php b/src/NullRejection.php index 670956f..111700a 100644 --- a/src/NullRejection.php +++ b/src/NullRejection.php @@ -18,7 +18,7 @@ public function reject(StepCodeInterface $step, array|object $rejection, \Throwa } /** @param non-empty-array|object $rejection */ - public function rejectWithReason(StepCodeInterface $step, object|array $rejection, string $reason, \Throwable $exception = null): void + public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, \Throwable $exception = null): void { // NOOP } diff --git a/src/PipelineRunnerInterface.php b/src/PipelineRunnerInterface.php index 24b737f..b652778 100644 --- a/src/PipelineRunnerInterface.php +++ b/src/PipelineRunnerInterface.php @@ -12,7 +12,7 @@ interface PipelineRunnerInterface { /** - * @param \Iterator $source + * @param \Iterator $source * @param \Generator, void> $async * * @return \Iterator