Skip to content

Commit

Permalink
Fixing PHPStan level 9 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gplanchat committed Nov 13, 2023
1 parent 000076d commit 141ef98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/GeneratorWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
*/
class GeneratorWrapper
{
/** @param \Iterator<mixed, mixed> ...$iterators */
/** @param \Iterator<array-key, Type> ...$iterators */
public function rewind(\Iterator ...$iterators): void
{
foreach ($iterators as $iterator) {
$iterator->rewind();
}
}

/** @param \Iterator<mixed, mixed> ...$iterators */
/** @param \Iterator<array-key, Type> ...$iterators */
public function next(\Iterator ...$iterators): void
{
foreach ($iterators as $iterator) {
$iterator->next();
}
}

/** @param \Iterator<mixed, mixed> ...$iterators */
/** @param \Iterator<array-key, Type> ...$iterators */
public function valid(\Iterator ...$iterators): bool
{
foreach ($iterators as $iterator) {
Expand All @@ -41,7 +41,7 @@ public function valid(\Iterator ...$iterators): bool

/**
* @param Type $value
* @param \Generator<array-key, ResultBucketInterface<Type>, Type|null, void> ...$generators
* @param \Generator<array-key, ResultBucketInterface<Type>, Type, void> ...$generators
*/
public function send($value, \Generator ...$generators): \Generator
{
Expand Down
4 changes: 1 addition & 3 deletions src/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class Pipeline implements PipelineInterface, WalkableInterface, RunnableInterfac
/** @var iterable<mixed>|\NoRewindIterator */
private iterable $subject;

/**
* @param PipelineRunnerInterface<mixed> $runner
*/
public function __construct(

Check failure on line 30 in src/Pipeline.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Pipeline::__construct() has parameter $runner with generic interface Kiboko\Contract\Pipeline\PipelineRunnerInterface but does not specify its types: Type

Check failure on line 30 in src/Pipeline.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Pipeline::__construct() has parameter $runner with generic interface Kiboko\Contract\Pipeline\PipelineRunnerInterface but does not specify its types: Type

Check failure on line 30 in src/Pipeline.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Pipeline::__construct() has parameter $runner with generic interface Kiboko\Contract\Pipeline\PipelineRunnerInterface but does not specify its types: Type
private readonly PipelineRunnerInterface $runner,
private readonly StateInterface $state,
Expand All @@ -49,6 +46,7 @@ public function feed(...$data): void
private function passThroughCoroutine(): \Generator
{
$line = yield;
/** @phpstan-ignore-next-line */
while (true) {

Check failure on line 50 in src/Pipeline.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 50.
$line = yield $line;
}
Expand Down
13 changes: 6 additions & 7 deletions src/PipelineRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
use Psr\Log\LogLevel;
use Psr\Log\NullLogger;

/**
* @template Type
*
* @implements PipelineRunnerInterface<Type>
*/
class PipelineRunner implements PipelineRunnerInterface

Check failure on line 21 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Kiboko\Component\Pipeline\PipelineRunner implements generic interface Kiboko\Contract\Pipeline\PipelineRunnerInterface but does not specify its types: Type
{
public function __construct(
Expand Down Expand Up @@ -52,9 +47,13 @@ public function run(
}

if ($bucket instanceof RejectionResultBucketInterface) {
$reasons = $bucket->reasons();

Check failure on line 50 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Kiboko\Contract\Bucket\RejectionResultBucketInterface::reasons().

Check failure on line 50 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Kiboko\Contract\Bucket\RejectionResultBucketInterface::reasons().

Check failure on line 50 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Kiboko\Contract\Bucket\RejectionResultBucketInterface::reasons().
foreach ($bucket->walkRejection() as $line) {
$rejection->reject($line);
$rejection->rejectWithReason($line, implode('', $bucket->reasons()));
if ($reasons !== null) {
$rejection->rejectWithReason($line, implode(PHP_EOL, $reasons));
} else {
$rejection->reject($line);
}
$state->reject();

$this->logger->log(
Expand Down

0 comments on commit 141ef98

Please sign in to comment.