Skip to content

Commit

Permalink
Merge pull request #12 from php-etl/fix/update-constraints
Browse files Browse the repository at this point in the history
Updated constraints (used new interfaces)
  • Loading branch information
gplanchat authored Nov 21, 2023
2 parents fd1758d + c69f259 commit 5a61287
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 142 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/phpstan-6.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/phpstan-7.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/phpstan-8.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHPStan level 5
name: PHPStan level 9
on: push
jobs:
phpstan:
Expand All @@ -19,5 +19,5 @@ jobs:
uses: php-actions/phpstan@v3
with:
path: src/
level: 5
level: 9
php_version: '8.2'
4 changes: 2 additions & 2 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Quality
name: Quality (PHPSpec level 8)
on: push
jobs:
cs-fixer:
Expand Down Expand Up @@ -34,5 +34,5 @@ jobs:
uses: php-actions/phpstan@v3
with:
path: src/
level: 3
level: 8
php_version: '8.2'
4 changes: 4 additions & 0 deletions src/BuilderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ protected function tearDown(): void

protected function getBuilderCompilePath(): string
{
if ($this->fs === null) {
throw new \RuntimeException('The virtual file system was not initialized. The '.__METHOD__.' method should be called after the '.static::class.'::setUp() method was called and after the '.static::class.'::tearDown() method is called.');
}

return $this->fs->url();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Constraint/Builder/BuilderProducesCodeThat.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class BuilderProducesCodeThat extends UnaryOperator
{
public function __construct(
private readonly string $builderCompilePath,
$constraint,
mixed $constraint,
) {
parent::__construct($constraint);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Constraint/Pipeline/IteratesLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private function asIterator(iterable $iterable): \Iterator
return new \IteratorIterator($iterable);
}

public function matches($other): bool
public function matches(mixed $other): bool

Check warning on line 40 in src/Constraint/Pipeline/IteratesLike.php

View workflow job for this annotation

GitHub Actions / infection

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ } return new \IteratorIterator($iterable); } - public function matches(mixed $other) : bool + protected function matches(mixed $other) : bool { $both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY); $both->attachIterator($this->asIterator($this->expected));
{
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);

Expand All @@ -54,7 +54,7 @@ public function matches($other): bool
return !$iterator->valid();
}

protected function failureDescription($other): string
protected function failureDescription(mixed $other): string
{
return sprintf(
'%s iterates like %s',
Expand Down
19 changes: 11 additions & 8 deletions src/Constraint/Pipeline/PipelineExtractsLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

namespace Kiboko\Component\PHPUnitExtension\Constraint\Pipeline;

use Kiboko\Contract\Bucket\ResultBucketInterface;
use Kiboko\Contract\Pipeline\ExtractorInterface;
use Kiboko\Contract\Pipeline\NullRejection;
use Kiboko\Contract\Pipeline\NullState;
use Kiboko\Contract\Pipeline\NullStepRejection;
use Kiboko\Contract\Pipeline\NullStepState;
use Kiboko\Contract\Pipeline\PipelineRunnerInterface;
use PHPUnit\Framework\Constraint\Constraint;

Expand All @@ -26,9 +27,11 @@ public function __construct(
}

/**
* @param list<Type> $iterable
* @template ItemType
*
* @return \Iterator<Type>
* @param list<ItemType> $iterable
*
* @return \Iterator<ItemType>
*/
private function asIterator(iterable $iterable): \Iterator
{
Expand All @@ -50,7 +53,7 @@ private function passThroughCoroutine(): \Generator
}
}

public function matches($other): bool
public function matches(mixed $other): bool
{
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);

Expand All @@ -67,8 +70,8 @@ public function matches($other): bool
$iterator = $this->runner->run(
$this->asIterator($extract),

Check failure on line 71 in src/Constraint/Pipeline/PipelineExtractsLike.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Kiboko\Contract\Bucket\ResultBucketInterface<mixed>> given.
$this->passThroughCoroutine(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
);
$both->attachIterator($iterator);

Expand All @@ -82,7 +85,7 @@ public function matches($other): bool
return !$iterator->valid();
}

protected function failureDescription($other): string
protected function failureDescription(mixed $other): string
{
return sprintf(
'%s pipeline extracts like %s',
Expand Down
20 changes: 10 additions & 10 deletions src/Constraint/Pipeline/PipelineLoadsLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\LoaderInterface;
use Kiboko\Contract\Pipeline\NullRejection;
use Kiboko\Contract\Pipeline\NullState;
use Kiboko\Contract\Pipeline\NullStepRejection;
use Kiboko\Contract\Pipeline\NullStepState;
use Kiboko\Contract\Pipeline\PipelineRunnerInterface;
use PHPUnit\Framework\Constraint\Constraint;

Expand Down Expand Up @@ -47,7 +47,7 @@ private function asIterator(iterable $iterable): \Iterator
return new \IteratorIterator($iterable);
}

public function matches($other): bool
public function matches(mixed $other): bool
{
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);

Expand All @@ -67,8 +67,8 @@ public function matches($other): bool
$this->runner->run(
$this->asIterator($this->source),

Check failure on line 68 in src/Constraint/Pipeline/PipelineLoadsLike.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Type> given.
$other->load(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
)
);
$iterator->append(
Expand All @@ -78,16 +78,16 @@ public function matches($other): bool
yield;
yield $other->flush();
})(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
)
);
} else {
$iterator = $this->runner->run(
$this->asIterator($this->source),

Check failure on line 87 in src/Constraint/Pipeline/PipelineLoadsLike.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Type> given.
$other->load(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
);
}
$both->attachIterator($iterator);
Expand All @@ -102,7 +102,7 @@ public function matches($other): bool
return !$iterator->valid();
}

protected function failureDescription($other): string
protected function failureDescription(mixed $other): string
{
return sprintf(
'%s pipeline loads like %s',
Expand Down
20 changes: 10 additions & 10 deletions src/Constraint/Pipeline/PipelineTransformsLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Kiboko\Component\PHPUnitExtension\Constraint\Pipeline;

use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\NullRejection;
use Kiboko\Contract\Pipeline\NullState;
use Kiboko\Contract\Pipeline\NullStepRejection;
use Kiboko\Contract\Pipeline\NullStepState;
use Kiboko\Contract\Pipeline\PipelineRunnerInterface;
use Kiboko\Contract\Pipeline\TransformerInterface;
use PHPUnit\Framework\Constraint\Constraint;
Expand Down Expand Up @@ -47,7 +47,7 @@ private function asIterator(iterable $iterable): \Iterator
return new \IteratorIterator($iterable);
}

public function matches($other): bool
public function matches(mixed $other): bool
{
$both = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY);

Expand All @@ -67,8 +67,8 @@ public function matches($other): bool
$this->runner->run(
$this->asIterator($this->source),

Check failure on line 68 in src/Constraint/Pipeline/PipelineTransformsLike.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Type> given.
$other->transform(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
)
);
$iterator->append(
Expand All @@ -78,16 +78,16 @@ public function matches($other): bool
yield;
yield $other->flush();
})(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
)
);
} else {
$iterator = $this->runner->run(
$this->asIterator($this->source),

Check failure on line 87 in src/Constraint/Pipeline/PipelineTransformsLike.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Type> given.
$other->transform(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
);
}
$both->attachIterator($iterator);
Expand All @@ -102,7 +102,7 @@ public function matches($other): bool
return !$iterator->valid();
}

protected function failureDescription($other): string
protected function failureDescription(mixed $other): string
{
return sprintf(
'%s pipeline transforms like %s',
Expand Down
25 changes: 11 additions & 14 deletions src/Constraint/Pipeline/PipelineWritesFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Kiboko\Contract\Pipeline\FlushableInterface;
use Kiboko\Contract\Pipeline\LoaderInterface;
use Kiboko\Contract\Pipeline\NullRejection;
use Kiboko\Contract\Pipeline\NullState;
use Kiboko\Contract\Pipeline\NullStepRejection;
use Kiboko\Contract\Pipeline\NullStepState;
use Kiboko\Contract\Pipeline\PipelineRunnerInterface;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\Constraint\FileExists;
Expand All @@ -22,8 +22,7 @@ public function __construct(
private readonly iterable $source,
private readonly string $expected,
private readonly PipelineRunnerInterface $runner,
) {
}
) {}

/**
* @param list<Type> $iterable
Expand All @@ -42,7 +41,7 @@ private function asIterator(iterable $iterable): \Iterator
return new \IteratorIterator($iterable);
}

public function matches($other): bool
public function matches(mixed $other): bool
{
if (!$other instanceof LoaderInterface) {
$this->fail($other, strtr('Expected an instance of %expected%, but got %actual%.', [
Expand All @@ -58,8 +57,8 @@ public function matches($other): bool
$this->runner->run(
$this->asIterator($this->source),

Check failure on line 58 in src/Constraint/Pipeline/PipelineWritesFile.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Type> given.
$other->load(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
)
);
$iterator->append(
Expand All @@ -69,28 +68,26 @@ public function matches($other): bool
yield;
yield $other->flush();
})(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
)
);
} else {
$iterator = $this->runner->run(
$this->asIterator($this->source),

Check failure on line 77 in src/Constraint/Pipeline/PipelineWritesFile.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $source of method Kiboko\Contract\Pipeline\PipelineRunnerInterface::run() expects Iterator<int, mixed>, Iterator<mixed, Type> given.
$other->load(),
new NullRejection(),
new NullState(),
new NullStepRejection(),
new NullStepState(),
);
}

iterator_count($iterator);

$constraint = new FileExists();
$constraint->evaluate($this->expected);

return !$iterator->valid();
}

protected function failureDescription($other): string
protected function failureDescription(mixed $other): string
{
return sprintf(
'%s pipeline writes file %s',
Expand Down
Loading

0 comments on commit 5a61287

Please sign in to comment.