Skip to content

Commit

Permalink
Fixing PHPStan level 4 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gplanchat committed Nov 14, 2023
1 parent f5f87d2 commit 2d03f6b
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
uses: php-actions/phpstan@v3
with:
path: src/
level: 3
level: 4
php_version: '8.2'
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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<positive-int, Type> ...$iterators */
/** @param \Iterator<int<0, max>, Type> ...$iterators */
public function rewind(\Iterator ...$iterators): void
{
foreach ($iterators as $iterator) {

Check warning on line 17 in src/GeneratorWrapper.php

View workflow job for this annotation

GitHub Actions / infection

Escaped Mutant for Mutator "Foreach_": --- Original +++ New @@ @@ /** @param \Iterator<int<0, max>, Type> ...$iterators */ public function rewind(\Iterator ...$iterators) : void { - foreach ($iterators as $iterator) { + foreach (array() as $iterator) { $iterator->rewind(); } }
$iterator->rewind();

Check warning on line 18 in src/GeneratorWrapper.php

View workflow job for this annotation

GitHub Actions / infection

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ public function rewind(\Iterator ...$iterators) : void { foreach ($iterators as $iterator) { - $iterator->rewind(); + } } /** @param \Iterator<int<0, max>, Type> ...$iterators */
}
}

/** @param \Iterator<positive-int, Type> ...$iterators */
/** @param \Iterator<int<0, max>, Type> ...$iterators */
public function next(\Iterator ...$iterators): void
{
foreach ($iterators as $iterator) {
$iterator->next();
}
}

/** @param \Iterator<positive-int, Type> ...$iterators */
/** @param \Iterator<int<0, max>, Type> ...$iterators */
public function valid(\Iterator ...$iterators): bool
{
foreach ($iterators as $iterator) {

Check warning on line 33 in src/GeneratorWrapper.php

View workflow job for this annotation

GitHub Actions / infection

Escaped Mutant for Mutator "Foreach_": --- Original +++ New @@ @@ /** @param \Iterator<int<0, max>, Type> ...$iterators */ public function valid(\Iterator ...$iterators) : bool { - foreach ($iterators as $iterator) { + foreach (array() as $iterator) { if (!$iterator->valid()) { return false; }
Expand All @@ -41,7 +41,7 @@ public function valid(\Iterator ...$iterators): bool

/**
* @param Type $value
* @param \Generator<positive-int, ResultBucketInterface<Type>, Type, void> ...$generators
* @param \Generator<int<0, max>, ResultBucketInterface<Type>, Type, void> ...$generators
*/
public function send($value, \Generator ...$generators): \Generator
{
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/LogLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(private LoggerInterface $logger, private string $log
{
}

/** @return \Generator<positive-int, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void> */
/** @return \Generator<int<0, max>, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void> */
public function load(): \Generator

Check failure on line 25 in src/Loader/LogLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Loader\LogLoader::load() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type

Check failure on line 25 in src/Loader/LogLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Loader\LogLoader::load() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type

Check failure on line 25 in src/Loader/LogLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Loader\LogLoader::load() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type
{
$line = yield new EmptyResultBucket();

Check failure on line 27 in src/Loader/LogLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects key type int<0, max>, int given.

Check failure on line 27 in src/Loader/LogLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects key type int<0, max>, int given.
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/StreamLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct($stream)
$this->stream = $stream;
}

/** @return \Generator<positive-int, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void> */
/** @return \Generator<int<0, max>, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void> */
public function load(): \Generator

Check failure on line 32 in src/Loader/StreamLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Loader\StreamLoader::load() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type

Check failure on line 32 in src/Loader/StreamLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Loader\StreamLoader::load() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type

Check failure on line 32 in src/Loader/StreamLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Loader\StreamLoader::load() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type
{
$line = yield new EmptyResultBucket();

Check failure on line 34 in src/Loader/StreamLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects key type int<0, max>, int given.

Check failure on line 34 in src/Loader/StreamLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects key type int<0, max>, int given.
Expand Down
4 changes: 2 additions & 2 deletions src/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

class Pipeline implements PipelineInterface, WalkableInterface, RunnableInterface
{
/** @var \AppendIterator<positive-int, non-empty-array<array-key, mixed>|object, \Iterator<positive-int, non-empty-array<array-key, mixed>|object>> */
/** @var \AppendIterator<int<0, max>, non-empty-array<array-key, mixed>|object, \Iterator<int<0, max>, non-empty-array<array-key, mixed>|object>> */
private readonly \AppendIterator $source;
/** @var \Iterator<positive-int, non-empty-array<array-key, mixed>|object>|\NoRewindIterator */
/** @var \Iterator<int<0, max>, non-empty-array<array-key, mixed>|object>|\NoRewindIterator */
private iterable $subject;

public function __construct(
Expand Down
6 changes: 3 additions & 3 deletions src/PipelineRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function __construct(
* @template InputType of non-empty-array<array-key, mixed>|object
* @template OutputType of non-empty-array<array-key, mixed>|object
*
* @param \Iterator<positive-int, InputType|null> $source
* @param \Generator<positive-int, ResultBucketInterface<OutputType>|AcceptanceResultBucketInterface<InputType>|RejectionResultBucketInterface<InputType>|null, InputType, void> $coroutine
* @param \Iterator<int<0, max>, InputType|null> $source
* @param \Generator<int<0, max>, ResultBucketInterface<OutputType>|AcceptanceResultBucketInterface<InputType>|RejectionResultBucketInterface<InputType>|null, InputType, void> $coroutine
* @param StepRejectionInterface<InputType> $rejection
* @param StepStateInterface $state
* @return \Iterator<positive-int, ResultBucketInterface<OutputType>>
* @return \Iterator<int<0, max>, ResultBucketInterface<OutputType>>
*/
public function run(
\Iterator $source,
Expand Down
4 changes: 2 additions & 2 deletions src/Transformer/BatchingTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
class BatchingTransformer implements TransformerInterface, FlushableInterface
{
/** @var array<array-key, InputType> */
/** @var list<InputType> */
private array $batch = [];

/**
Expand All @@ -30,7 +30,7 @@ public function __construct(
) {
}

/** @return \Generator<positive-int, ResultBucketInterface<OutputType>|EmptyResultBucket, InputType|null, void> */
/** @return \Generator<int<0, max>, ResultBucketInterface<OutputType>|EmptyResultBucket, InputType|null, void> */
public function transform(): \Generator

Check failure on line 34 in src/Transformer/BatchingTransformer.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Pipeline\Transformer\BatchingTransformer::transform() return type with generic class Kiboko\Component\Bucket\EmptyResultBucket does not specify its types: Type
{
$this->batch = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Transformer/CallableTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
}

/**
* @return \Generator<positive-int, AcceptanceResultBucket<OutputType>|EmptyResultBucket, InputType|null, void>
* @return \Generator<int<0, max>, AcceptanceResultBucket<OutputType>|EmptyResultBucket, InputType|null, void>
*/
public function transform(): \Generator
{
Expand Down
2 changes: 1 addition & 1 deletion src/Transformer/ColumnTrimTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
) {
}

/** @return \Generator<positive-int, AcceptanceResultBucket<OutputType>|EmptyResultBucket, InputType|null, void> */
/** @return \Generator<int<0, max>, AcceptanceResultBucket<OutputType>|EmptyResultBucket, InputType|null, void> */
public function transform(): \Generator
{
$line = yield new EmptyResultBucket();
Expand Down
2 changes: 1 addition & 1 deletion src/Transformer/FilterTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
}

/**
* @return \Generator<positive-int, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void>
* @return \Generator<int<0, max>, AcceptanceResultBucket<Type>|EmptyResultBucket, Type|null, void>
*/
public function transform(): \Generator
{
Expand Down
2 changes: 1 addition & 1 deletion src/UnexpectedYieldedValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getCoroutine(): \Generator
}

/**
* @param \Generator<positive-int, ResultBucketInterface<OutputType>, InputType, void> $actual
* @param \Generator<int<0, max>, ResultBucketInterface<OutputType>, InputType, void> $actual
* @param list<string> $expectedTypes
* @param mixed $actual
*
Expand Down

0 comments on commit 2d03f6b

Please sign in to comment.