Skip to content

Commit 000076d

Browse files
committed
Fixing PHPStan level 9 issues
1 parent 2b8bb81 commit 000076d

18 files changed

+466
-694
lines changed

composer.lock

Lines changed: 282 additions & 486 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Extractor/ArrayExtractor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66

77
use Kiboko\Contract\Pipeline\ExtractorInterface;
88

9+
/**
10+
* @template Type
11+
* @implements ExtractorInterface<Type>
12+
*/
913
class ArrayExtractor implements ExtractorInterface
1014
{
15+
/** @param non-empty-array<array-key, Type> $data */
1116
public function __construct(private readonly array $data)
1217
{
1318
}

src/Extractor/IteratorExtractor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44

55
namespace Kiboko\Component\Pipeline\Extractor;
66

7-
use Kiboko\Component\Bucket\AcceptanceResultBucket;
87
use Kiboko\Contract\Pipeline\ExtractorInterface;
98

9+
/**
10+
* @template Type
11+
* @implements ExtractorInterface<Type>
12+
*/
1013
class IteratorExtractor implements ExtractorInterface
1114
{
15+
/** @param \Traversable<mixed, Type> $traversable */
1216
public function __construct(private readonly \Traversable $traversable)
1317
{
1418
}

src/GeneratorWrapper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,30 @@
44

55
namespace Kiboko\Component\Pipeline;
66

7+
use Kiboko\Contract\Bucket\ResultBucketInterface;
8+
9+
/**
10+
* @template Type
11+
*/
712
class GeneratorWrapper
813
{
14+
/** @param \Iterator<mixed, mixed> ...$iterators */
915
public function rewind(\Iterator ...$iterators): void
1016
{
1117
foreach ($iterators as $iterator) {
1218
$iterator->rewind();
1319
}
1420
}
1521

22+
/** @param \Iterator<mixed, mixed> ...$iterators */
1623
public function next(\Iterator ...$iterators): void
1724
{
1825
foreach ($iterators as $iterator) {
1926
$iterator->next();
2027
}
2128
}
2229

30+
/** @param \Iterator<mixed, mixed> ...$iterators */
2331
public function valid(\Iterator ...$iterators): bool
2432
{
2533
foreach ($iterators as $iterator) {
@@ -31,6 +39,10 @@ public function valid(\Iterator ...$iterators): bool
3139
return true;
3240
}
3341

42+
/**
43+
* @param Type $value
44+
* @param \Generator<array-key, ResultBucketInterface<Type>, Type|null, void> ...$generators
45+
*/
3446
public function send($value, \Generator ...$generators): \Generator
3547
{
3648
foreach ($generators as $generator) {

src/IteratorLoggingWrapper.php

Lines changed: 0 additions & 137 deletions
This file was deleted.

src/Loader/DebugLoader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44

55
namespace Kiboko\Component\Pipeline\Loader;
66

7+
/**
8+
* @template Type
9+
*
10+
* @extends StreamLoader<Type>
11+
*/
712
final class DebugLoader extends StreamLoader
813
{
9-
protected function formatLine($line)
14+
/**
15+
* @param Type|null $line
16+
*/
17+
protected function formatLine(mixed $line): string
1018
{
1119
return var_export($line, true).\PHP_EOL;
1220
}

src/Loader/JSONStreamLoader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44

55
namespace Kiboko\Component\Pipeline\Loader;
66

7+
/**
8+
* @template Type
9+
*
10+
* @extends StreamLoader<Type>
11+
*/
712
final class JSONStreamLoader extends StreamLoader
813
{
9-
protected function formatLine($line)
14+
/**
15+
* @param Type|null $line
16+
*/
17+
protected function formatLine(mixed $line): string
1018
{
1119
return json_encode($line, \JSON_THROW_ON_ERROR).\PHP_EOL;
1220
}

src/Loader/LogLoader.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* @template Type
1515
*
16-
* @template-implements LoaderInterface<Type>
16+
* @implements LoaderInterface<Type, Type>
1717
*/
1818
final readonly class LogLoader implements LoaderInterface
1919
{
@@ -25,8 +25,10 @@ public function __construct(private LoggerInterface $logger, private string $log
2525
public function load(): \Generator
2626
{
2727
$line = yield new EmptyResultBucket();
28-
do {
28+
/** @phpstan-ignore-next-line */
29+
while (true) {
2930
$this->logger->log($this->logLevel, var_export($line, true));
30-
} while ($line = yield new AcceptanceResultBucket($line));
31+
$line = yield new AcceptanceResultBucket($line);
32+
}
3133
}
3234
}

src/Loader/StderrLoader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44

55
namespace Kiboko\Component\Pipeline\Loader;
66

7+
/**
8+
* @template Type
9+
*
10+
* @extends StreamLoader<Type>
11+
*/
712
final class StderrLoader extends StreamLoader
813
{
914
public function __construct()
1015
{
1116
parent::__construct(\STDOUT);
1217
}
1318

14-
protected function formatLine($line)
19+
/**
20+
* @param Type|null $line
21+
*/
22+
protected function formatLine(mixed $line): string
1523
{
1624
return var_export($line, true).\PHP_EOL;
1725
}

src/Loader/StdoutLoader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44

55
namespace Kiboko\Component\Pipeline\Loader;
66

7+
/**
8+
* @template Type
9+
*
10+
* @extends StreamLoader<Type>
11+
*/
712
final class StdoutLoader extends StreamLoader
813
{
914
public function __construct()
1015
{
1116
parent::__construct(\STDOUT);
1217
}
1318

14-
protected function formatLine($line)
19+
/**
20+
* @param Type|null $line
21+
*/
22+
protected function formatLine(mixed $line): string
1523
{
1624
return var_export($line, true).\PHP_EOL;
1725
}

0 commit comments

Comments
 (0)