diff --git a/src/Extractor/ArrayExtractor.php b/src/Extractor/ArrayExtractor.php index c6c71cc..e34d088 100644 --- a/src/Extractor/ArrayExtractor.php +++ b/src/Extractor/ArrayExtractor.php @@ -8,14 +8,13 @@ /** * @template Type of non-empty-array|object + * * @implements ExtractorInterface */ class ArrayExtractor implements ExtractorInterface { /** @param non-empty-array $data */ - public function __construct(private readonly array $data) - { - } + public function __construct(private readonly array $data) {} /** * @return \Generator diff --git a/src/Extractor/IteratorExtractor.php b/src/Extractor/IteratorExtractor.php index 46cf7ec..332a85c 100644 --- a/src/Extractor/IteratorExtractor.php +++ b/src/Extractor/IteratorExtractor.php @@ -8,14 +8,13 @@ /** * @template Type of non-empty-array|object + * * @implements ExtractorInterface */ class IteratorExtractor implements ExtractorInterface { /** @param \Traversable $traversable */ - public function __construct(private readonly \Traversable $traversable) - { - } + public function __construct(private readonly \Traversable $traversable) {} /** * @return \Generator diff --git a/src/GeneratorWrapper.php b/src/GeneratorWrapper.php index 95856f3..1508d95 100644 --- a/src/GeneratorWrapper.php +++ b/src/GeneratorWrapper.php @@ -40,7 +40,7 @@ public function valid(\Iterator ...$iterators): bool } /** - * @param Type $value + * @param Type $value * @param \Generator, ResultBucketInterface, Type, void> ...$generators */ public function send($value, \Generator ...$generators): \Generator diff --git a/src/Loader/LogLoader.php b/src/Loader/LogLoader.php index 23fb3eb..a5f8700 100644 --- a/src/Loader/LogLoader.php +++ b/src/Loader/LogLoader.php @@ -17,17 +17,15 @@ */ final readonly class LogLoader implements LoaderInterface { - public function __construct(private LoggerInterface $logger, private string $logLevel = LogLevel::DEBUG) - { - } + public function __construct(private LoggerInterface $logger, private string $logLevel = LogLevel::DEBUG) {} /** @return \Generator, AcceptanceResultBucket|EmptyResultBucket, Type|null, void> */ public function load(): \Generator { $line = yield new EmptyResultBucket(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { - if ($line === null) { + if (null === $line) { $line = yield new EmptyResultBucket(); continue; } diff --git a/src/Loader/StreamLoader.php b/src/Loader/StreamLoader.php index 1b3792a..8bdca13 100644 --- a/src/Loader/StreamLoader.php +++ b/src/Loader/StreamLoader.php @@ -32,9 +32,9 @@ public function __construct($stream) public function load(): \Generator { $line = yield new EmptyResultBucket(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { - if ($line === null) { + if (null === $line) { $line = yield new EmptyResultBucket(); continue; } @@ -46,7 +46,6 @@ public function load(): \Generator /** * @param Type|null $line - * @return string */ abstract protected function formatLine(mixed $line): string; } diff --git a/src/Pipeline.php b/src/Pipeline.php index 9b33007..d823fe7 100644 --- a/src/Pipeline.php +++ b/src/Pipeline.php @@ -30,7 +30,7 @@ class Pipeline implements PipelineInterface, WalkableInterface, RunnableInterfac public function __construct( private readonly PipelineRunnerInterface $runner, private readonly StateInterface $state, - ?\Iterator $source = null + \Iterator $source = null ) { $this->source = new \AppendIterator(); $this->source->append($source ?? new \EmptyIterator()); @@ -42,7 +42,6 @@ public function __construct( * @template InputType of non-empty-array|object * * @param InputType ...$data - * @return void */ public function feed(...$data): void { @@ -52,7 +51,7 @@ public function feed(...$data): void private function passThroughCoroutine(): \Generator { $line = yield; - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { $line = yield $line; } @@ -61,7 +60,7 @@ private function passThroughCoroutine(): \Generator /** * @template Type of non-empty-array|object * - * @param ExtractorInterface $extractor + * @param ExtractorInterface $extractor * @param StepRejectionInterface $rejection */ public function extract( @@ -110,7 +109,7 @@ public function extract( * @template OutputType of non-empty-array|object * * @param TransformerInterface $transformer - * @param StepRejectionInterface $rejection + * @param StepRejectionInterface $rejection */ public function transform( StepCodeInterface $stepCode, @@ -159,7 +158,7 @@ public function transform( * @template OutputType of non-empty-array|object * * @param LoaderInterface $loader - * @param StepRejectionInterface $rejection + * @param StepRejectionInterface $rejection */ public function load( StepCodeInterface $stepCode, diff --git a/src/PipelineRunner.php b/src/PipelineRunner.php index 9862d08..283ce21 100644 --- a/src/PipelineRunner.php +++ b/src/PipelineRunner.php @@ -4,14 +4,10 @@ namespace Kiboko\Component\Pipeline; -use Kiboko\Component\Bucket\RejectionResultBucket; -use Kiboko\Component\Bucket\RejectionWithReasonResultBucket; use Kiboko\Contract\Bucket\AcceptanceResultBucketInterface; use Kiboko\Contract\Bucket\RejectionResultBucketInterface; use Kiboko\Contract\Bucket\ResultBucketInterface; use Kiboko\Contract\Pipeline\PipelineRunnerInterface; -use Kiboko\Contract\Pipeline\RejectionInterface; -use Kiboko\Contract\Pipeline\StateInterface; use Kiboko\Contract\Pipeline\StepRejectionInterface; use Kiboko\Contract\Pipeline\StepStateInterface; use Psr\Log\LoggerInterface; @@ -23,17 +19,16 @@ class PipelineRunner implements PipelineRunnerInterface public function __construct( private readonly LoggerInterface $logger = new NullLogger(), private readonly LogLevel|string $rejectionLevel = LogLevel::WARNING - ) { - } + ) {} /** * @template InputType of non-empty-array|object * @template OutputType of non-empty-array|object * - * @param \Iterator, InputType|null> $source + * @param \Iterator, InputType|null> $source * @param \Generator, ResultBucketInterface|AcceptanceResultBucketInterface|RejectionResultBucketInterface|null, InputType, void> $coroutine - * @param StepRejectionInterface $rejection - * @param StepStateInterface $state + * @param StepRejectionInterface $rejection + * * @return \Iterator, ResultBucketInterface> */ public function run( @@ -59,8 +54,8 @@ public function run( if ($bucket instanceof RejectionResultBucketInterface) { $reasons = $bucket->reasons(); foreach ($bucket->walkRejection() as $line) { - if ($reasons !== null) { - $rejection->rejectWithReason($line, implode(PHP_EOL, $reasons)); + if (null !== $reasons) { + $rejection->rejectWithReason($line, implode(\PHP_EOL, $reasons)); } else { $rejection->reject($line); } diff --git a/src/StepCode.php b/src/StepCode.php index ac1dfd7..2f019be 100644 --- a/src/StepCode.php +++ b/src/StepCode.php @@ -10,8 +10,7 @@ { private function __construct( private string $reference, - ) { - } + ) {} public static function fromString(string $reference): self { diff --git a/src/Transformer/BatchingTransformer.php b/src/Transformer/BatchingTransformer.php index c404127..7764ddd 100644 --- a/src/Transformer/BatchingTransformer.php +++ b/src/Transformer/BatchingTransformer.php @@ -27,8 +27,7 @@ class BatchingTransformer implements TransformerInterface, FlushableInterface */ public function __construct( private readonly int $batchSize - ) { - } + ) {} /** @return \Generator, ResultBucketInterface|EmptyResultBucket, InputType|null, void> */ public function transform(): \Generator @@ -36,15 +35,15 @@ public function transform(): \Generator $this->batch = []; $line = yield new EmptyResultBucket(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { - if ($line === null) { + if (null === $line) { $line = yield new EmptyResultBucket(); continue; } $this->batch[] = $line; - if (count($this->batch) >= $this->batchSize) { + if (\count($this->batch) >= $this->batchSize) { /** @phpstan-ignore-next-line */ $line = yield new AcceptanceResultBucket($this->batch); $this->batch = []; @@ -58,10 +57,11 @@ public function transform(): \Generator /** @return AcceptanceResultBucket|EmptyResultBucket */ public function flush(): ResultBucketInterface { - if (count($this->batch) <= 0) { + if (\count($this->batch) <= 0) { return new EmptyResultBucket(); } - /** @phpstan-ignore-next-line */ + + /* @phpstan-ignore-next-line */ return new AcceptanceResultBucket($this->batch); } } diff --git a/src/Transformer/CallableTransformer.php b/src/Transformer/CallableTransformer.php index c3ac523..fc78bd6 100644 --- a/src/Transformer/CallableTransformer.php +++ b/src/Transformer/CallableTransformer.php @@ -16,7 +16,7 @@ */ class CallableTransformer implements TransformerInterface { - /** @var callable(InputType|null $item): OutputType */ + /** @var callable(InputType|null): OutputType */ private $callback; /** @@ -36,9 +36,9 @@ public function transform(): \Generator $callback = $this->callback; $line = yield new EmptyResultBucket(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { - if ($line === null) { + if (null === $line) { $line = yield new EmptyResultBucket(); continue; } diff --git a/src/Transformer/ColumnTrimTransformer.php b/src/Transformer/ColumnTrimTransformer.php index 23b500a..1abe117 100644 --- a/src/Transformer/ColumnTrimTransformer.php +++ b/src/Transformer/ColumnTrimTransformer.php @@ -19,14 +19,13 @@ class ColumnTrimTransformer implements TransformerInterface /** @param list $columnsToTrim */ public function __construct( private readonly array $columnsToTrim - ) { - } + ) {} /** @return \Generator, AcceptanceResultBucket|EmptyResultBucket, InputType|null, void> */ public function transform(): \Generator { $line = yield new EmptyResultBucket(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { if (null === $line) { $line = yield new EmptyResultBucket(); diff --git a/src/Transformer/FilterTransformer.php b/src/Transformer/FilterTransformer.php index b10c112..c39174c 100644 --- a/src/Transformer/FilterTransformer.php +++ b/src/Transformer/FilterTransformer.php @@ -15,7 +15,7 @@ */ class FilterTransformer implements TransformerInterface { - /** @var callable(Type $item): bool */ + /** @var callable(Type): bool */ private $callback; /** @param callable(Type $item): bool $callback */ @@ -33,7 +33,7 @@ public function transform(): \Generator $callback = $this->callback; $line = yield new EmptyResultBucket(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ while (true) { if (null === $line || !$callback($line)) { $line = yield new EmptyResultBucket(); diff --git a/src/UnexpectedYieldedValueType.php b/src/UnexpectedYieldedValueType.php index f4c9ba7..acb83c8 100644 --- a/src/UnexpectedYieldedValueType.php +++ b/src/UnexpectedYieldedValueType.php @@ -16,7 +16,7 @@ public function __construct( private readonly \Generator $coroutine, string $message = '', int $code = 0, - ?\Throwable $previous = null + \Throwable $previous = null ) { parent::__construct($message, $code, $previous); } @@ -28,12 +28,11 @@ public function getCoroutine(): \Generator /** * @param \Generator, ResultBucketInterface, InputType, void> $actual - * @param list $expectedTypes - * @param mixed $actual + * @param list $expectedTypes * * @return UnexpectedYieldedValueType */ - public static function expectingTypes(\Generator $coroutine, array $expectedTypes, $actual, int $code = 0, ?\Throwable $previous = null): self + public static function expectingTypes(\Generator $coroutine, array $expectedTypes, $actual, int $code = 0, \Throwable $previous = null): self { try { $re = new \ReflectionGenerator($coroutine); @@ -48,7 +47,7 @@ public static function expectingTypes(\Generator $coroutine, array $expectedType $executionFile = $re->getExecutingFile(); $executionLine = $re->getExecutingLine(); - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ return new self( $coroutine, strtr( @@ -65,7 +64,7 @@ public static function expectingTypes(\Generator $coroutine, array $expectedType $previous ); } catch (\ReflectionException) { - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ return new self( $coroutine, strtr(