Skip to content

Commit e61319b

Browse files
committed
CS Fixing classes
1 parent d1e6ba2 commit e61319b

13 files changed

+41
-55
lines changed

src/Extractor/ArrayExtractor.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
/**
1010
* @template Type of non-empty-array<array-key, mixed>|object
11+
*
1112
* @implements ExtractorInterface<Type>
1213
*/
1314
class ArrayExtractor implements ExtractorInterface
1415
{
1516
/** @param non-empty-array<array-key, Type> $data */
16-
public function __construct(private readonly array $data)
17-
{
18-
}
17+
public function __construct(private readonly array $data) {}
1918

2019
/**
2120
* @return \Generator

src/Extractor/IteratorExtractor.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
/**
1010
* @template Type of non-empty-array<array-key, mixed>|object
11+
*
1112
* @implements ExtractorInterface<Type>
1213
*/
1314
class IteratorExtractor implements ExtractorInterface
1415
{
1516
/** @param \Traversable<mixed, Type> $traversable */
16-
public function __construct(private readonly \Traversable $traversable)
17-
{
18-
}
17+
public function __construct(private readonly \Traversable $traversable) {}
1918

2019
/**
2120
* @return \Generator

src/GeneratorWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function valid(\Iterator ...$iterators): bool
4040
}
4141

4242
/**
43-
* @param Type $value
43+
* @param Type $value
4444
* @param \Generator<int<0, max>, ResultBucketInterface<Type>, Type, void> ...$generators
4545
*/
4646
public function send($value, \Generator ...$generators): \Generator

src/Loader/LogLoader.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
*/
1818
final readonly class LogLoader implements LoaderInterface
1919
{
20-
public function __construct(private LoggerInterface $logger, private string $logLevel = LogLevel::DEBUG)
21-
{
22-
}
20+
public function __construct(private LoggerInterface $logger, private string $logLevel = LogLevel::DEBUG) {}
2321

2422
/** @return \Generator<int<0, max>, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void> */
2523
public function load(): \Generator
2624
{
2725
$line = yield new EmptyResultBucket();
28-
/** @phpstan-ignore-next-line */
26+
/* @phpstan-ignore-next-line */
2927
while (true) {
30-
if ($line === null) {
28+
if (null === $line) {
3129
$line = yield new EmptyResultBucket();
3230
continue;
3331
}

src/Loader/StreamLoader.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function __construct($stream)
3232
public function load(): \Generator
3333
{
3434
$line = yield new EmptyResultBucket();
35-
/** @phpstan-ignore-next-line */
35+
/* @phpstan-ignore-next-line */
3636
while (true) {
37-
if ($line === null) {
37+
if (null === $line) {
3838
$line = yield new EmptyResultBucket();
3939
continue;
4040
}
@@ -46,7 +46,6 @@ public function load(): \Generator
4646

4747
/**
4848
* @param Type|null $line
49-
* @return string
5049
*/
5150
abstract protected function formatLine(mixed $line): string;
5251
}

src/Pipeline.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Pipeline implements PipelineInterface, WalkableInterface, RunnableInterfac
3030
public function __construct(
3131
private readonly PipelineRunnerInterface $runner,
3232
private readonly StateInterface $state,
33-
?\Iterator $source = null
33+
\Iterator $source = null
3434
) {
3535
$this->source = new \AppendIterator();
3636
$this->source->append($source ?? new \EmptyIterator());
@@ -42,7 +42,6 @@ public function __construct(
4242
* @template InputType of non-empty-array<array-key, mixed>|object
4343
*
4444
* @param InputType ...$data
45-
* @return void
4645
*/
4746
public function feed(...$data): void
4847
{
@@ -52,7 +51,7 @@ public function feed(...$data): void
5251
private function passThroughCoroutine(): \Generator
5352
{
5453
$line = yield;
55-
/** @phpstan-ignore-next-line */
54+
/* @phpstan-ignore-next-line */
5655
while (true) {
5756
$line = yield $line;
5857
}
@@ -61,7 +60,7 @@ private function passThroughCoroutine(): \Generator
6160
/**
6261
* @template Type of non-empty-array<array-key, mixed>|object
6362
*
64-
* @param ExtractorInterface<Type> $extractor
63+
* @param ExtractorInterface<Type> $extractor
6564
* @param StepRejectionInterface<Type> $rejection
6665
*/
6766
public function extract(
@@ -110,7 +109,7 @@ public function extract(
110109
* @template OutputType of non-empty-array<array-key, mixed>|object
111110
*
112111
* @param TransformerInterface<InputType, OutputType> $transformer
113-
* @param StepRejectionInterface<InputType> $rejection
112+
* @param StepRejectionInterface<InputType> $rejection
114113
*/
115114
public function transform(
116115
StepCodeInterface $stepCode,
@@ -159,7 +158,7 @@ public function transform(
159158
* @template OutputType of non-empty-array<array-key, mixed>|object
160159
*
161160
* @param LoaderInterface<InputType, OutputType> $loader
162-
* @param StepRejectionInterface<InputType> $rejection
161+
* @param StepRejectionInterface<InputType> $rejection
163162
*/
164163
public function load(
165164
StepCodeInterface $stepCode,

src/PipelineRunner.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44

55
namespace Kiboko\Component\Pipeline;
66

7-
use Kiboko\Component\Bucket\RejectionResultBucket;
8-
use Kiboko\Component\Bucket\RejectionWithReasonResultBucket;
97
use Kiboko\Contract\Bucket\AcceptanceResultBucketInterface;
108
use Kiboko\Contract\Bucket\RejectionResultBucketInterface;
119
use Kiboko\Contract\Bucket\ResultBucketInterface;
1210
use Kiboko\Contract\Pipeline\PipelineRunnerInterface;
13-
use Kiboko\Contract\Pipeline\RejectionInterface;
14-
use Kiboko\Contract\Pipeline\StateInterface;
1511
use Kiboko\Contract\Pipeline\StepRejectionInterface;
1612
use Kiboko\Contract\Pipeline\StepStateInterface;
1713
use Psr\Log\LoggerInterface;
@@ -23,17 +19,16 @@ class PipelineRunner implements PipelineRunnerInterface
2319
public function __construct(
2420
private readonly LoggerInterface $logger = new NullLogger(),
2521
private readonly LogLevel|string $rejectionLevel = LogLevel::WARNING
26-
) {
27-
}
22+
) {}
2823

2924
/**
3025
* @template InputType of non-empty-array<array-key, mixed>|object
3126
* @template OutputType of non-empty-array<array-key, mixed>|object
3227
*
33-
* @param \Iterator<int<0, max>, InputType|null> $source
28+
* @param \Iterator<int<0, max>, InputType|null> $source
3429
* @param \Generator<int<0, max>, ResultBucketInterface<OutputType>|AcceptanceResultBucketInterface<InputType>|RejectionResultBucketInterface<InputType>|null, InputType, void> $coroutine
35-
* @param StepRejectionInterface<InputType> $rejection
36-
* @param StepStateInterface $state
30+
* @param StepRejectionInterface<InputType> $rejection
31+
*
3732
* @return \Iterator<int<0, max>, ResultBucketInterface<OutputType>>
3833
*/
3934
public function run(
@@ -59,8 +54,8 @@ public function run(
5954
if ($bucket instanceof RejectionResultBucketInterface) {
6055
$reasons = $bucket->reasons();
6156
foreach ($bucket->walkRejection() as $line) {
62-
if ($reasons !== null) {
63-
$rejection->rejectWithReason($line, implode(PHP_EOL, $reasons));
57+
if (null !== $reasons) {
58+
$rejection->rejectWithReason($line, implode(\PHP_EOL, $reasons));
6459
} else {
6560
$rejection->reject($line);
6661
}

src/StepCode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
{
1111
private function __construct(
1212
private string $reference,
13-
) {
14-
}
13+
) {}
1514

1615
public static function fromString(string $reference): self
1716
{

src/Transformer/BatchingTransformer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,23 @@ class BatchingTransformer implements TransformerInterface, FlushableInterface
2727
*/
2828
public function __construct(
2929
private readonly int $batchSize
30-
) {
31-
}
30+
) {}
3231

3332
/** @return \Generator<int<0, max>, ResultBucketInterface<OutputType>|EmptyResultBucket, InputType|null, void> */
3433
public function transform(): \Generator
3534
{
3635
$this->batch = [];
3736

3837
$line = yield new EmptyResultBucket();
39-
/** @phpstan-ignore-next-line */
38+
/* @phpstan-ignore-next-line */
4039
while (true) {
41-
if ($line === null) {
40+
if (null === $line) {
4241
$line = yield new EmptyResultBucket();
4342
continue;
4443
}
4544
$this->batch[] = $line;
4645

47-
if (count($this->batch) >= $this->batchSize) {
46+
if (\count($this->batch) >= $this->batchSize) {
4847
/** @phpstan-ignore-next-line */
4948
$line = yield new AcceptanceResultBucket($this->batch);
5049
$this->batch = [];
@@ -58,10 +57,11 @@ public function transform(): \Generator
5857
/** @return AcceptanceResultBucket<OutputType>|EmptyResultBucket */
5958
public function flush(): ResultBucketInterface
6059
{
61-
if (count($this->batch) <= 0) {
60+
if (\count($this->batch) <= 0) {
6261
return new EmptyResultBucket();
6362
}
64-
/** @phpstan-ignore-next-line */
63+
64+
/* @phpstan-ignore-next-line */
6565
return new AcceptanceResultBucket($this->batch);
6666
}
6767
}

src/Transformer/CallableTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class CallableTransformer implements TransformerInterface
1818
{
19-
/** @var callable(InputType|null $item): OutputType */
19+
/** @var callable(InputType|null): OutputType */
2020
private $callback;
2121

2222
/**
@@ -36,9 +36,9 @@ public function transform(): \Generator
3636
$callback = $this->callback;
3737

3838
$line = yield new EmptyResultBucket();
39-
/** @phpstan-ignore-next-line */
39+
/* @phpstan-ignore-next-line */
4040
while (true) {
41-
if ($line === null) {
41+
if (null === $line) {
4242
$line = yield new EmptyResultBucket();
4343
continue;
4444
}

src/Transformer/ColumnTrimTransformer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ class ColumnTrimTransformer implements TransformerInterface
1919
/** @param list<string> $columnsToTrim */
2020
public function __construct(
2121
private readonly array $columnsToTrim
22-
) {
23-
}
22+
) {}
2423

2524
/** @return \Generator<int<0, max>, AcceptanceResultBucket<OutputType>|EmptyResultBucket, InputType|null, void> */
2625
public function transform(): \Generator
2726
{
2827
$line = yield new EmptyResultBucket();
29-
/** @phpstan-ignore-next-line */
28+
/* @phpstan-ignore-next-line */
3029
while (true) {
3130
if (null === $line) {
3231
$line = yield new EmptyResultBucket();

src/Transformer/FilterTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class FilterTransformer implements TransformerInterface
1717
{
18-
/** @var callable(Type $item): bool */
18+
/** @var callable(Type): bool */
1919
private $callback;
2020

2121
/** @param callable(Type $item): bool $callback */
@@ -33,7 +33,7 @@ public function transform(): \Generator
3333
$callback = $this->callback;
3434

3535
$line = yield new EmptyResultBucket();
36-
/** @phpstan-ignore-next-line */
36+
/* @phpstan-ignore-next-line */
3737
while (true) {
3838
if (null === $line || !$callback($line)) {
3939
$line = yield new EmptyResultBucket();

src/UnexpectedYieldedValueType.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(
1616
private readonly \Generator $coroutine,
1717
string $message = '',
1818
int $code = 0,
19-
?\Throwable $previous = null
19+
\Throwable $previous = null
2020
) {
2121
parent::__construct($message, $code, $previous);
2222
}
@@ -28,12 +28,11 @@ public function getCoroutine(): \Generator
2828

2929
/**
3030
* @param \Generator<int<0, max>, ResultBucketInterface<OutputType>, InputType, void> $actual
31-
* @param list<string> $expectedTypes
32-
* @param mixed $actual
31+
* @param list<string> $expectedTypes
3332
*
3433
* @return UnexpectedYieldedValueType<InputType, OutputType>
3534
*/
36-
public static function expectingTypes(\Generator $coroutine, array $expectedTypes, $actual, int $code = 0, ?\Throwable $previous = null): self
35+
public static function expectingTypes(\Generator $coroutine, array $expectedTypes, $actual, int $code = 0, \Throwable $previous = null): self
3736
{
3837
try {
3938
$re = new \ReflectionGenerator($coroutine);
@@ -48,7 +47,7 @@ public static function expectingTypes(\Generator $coroutine, array $expectedType
4847
$executionFile = $re->getExecutingFile();
4948
$executionLine = $re->getExecutingLine();
5049

51-
/** @phpstan-ignore-next-line */
50+
/* @phpstan-ignore-next-line */
5251
return new self(
5352
$coroutine,
5453
strtr(
@@ -65,7 +64,7 @@ public static function expectingTypes(\Generator $coroutine, array $expectedType
6564
$previous
6665
);
6766
} catch (\ReflectionException) {
68-
/** @phpstan-ignore-next-line */
67+
/* @phpstan-ignore-next-line */
6968
return new self(
7069
$coroutine,
7170
strtr(

0 commit comments

Comments
 (0)