-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,5 @@ jobs: | |
uses: php-actions/phpstan@v3 | ||
with: | ||
path: src/ | ||
level: 8 | ||
level: 9 | ||
php_version: '8.2' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,5 @@ jobs: | |
uses: php-actions/phpstan@v3 | ||
with: | ||
path: src/ | ||
level: 4 | ||
level: 8 | ||
php_version: '8.2' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,23 +11,23 @@ | |
*/ | ||
class GeneratorWrapper | ||
{ | ||
/** @param \Iterator<int<0, max>, Type> ...$iterators */ | ||
/** @param \Iterator<int, Type> ...$iterators */ | ||
public function rewind(\Iterator ...$iterators): void | ||
{ | ||
foreach ($iterators as $iterator) { | ||
Check warning on line 17 in src/GeneratorWrapper.php GitHub Actions / infection
|
||
$iterator->rewind(); | ||
Check warning on line 18 in src/GeneratorWrapper.php GitHub Actions / infection
|
||
} | ||
} | ||
|
||
/** @param \Iterator<int<0, max>, Type> ...$iterators */ | ||
/** @param \Iterator<int, Type> ...$iterators */ | ||
public function next(\Iterator ...$iterators): void | ||
{ | ||
foreach ($iterators as $iterator) { | ||
$iterator->next(); | ||
} | ||
} | ||
|
||
/** @param \Iterator<int<0, max>, Type> ...$iterators */ | ||
/** @param \Iterator<int, Type> ...$iterators */ | ||
public function valid(\Iterator ...$iterators): bool | ||
{ | ||
foreach ($iterators as $iterator) { | ||
Check warning on line 33 in src/GeneratorWrapper.php GitHub Actions / infection
|
||
|
@@ -40,7 +40,7 @@ public function valid(\Iterator ...$iterators): bool | |
} | ||
|
||
/** | ||
* @param Type $value | ||
* @param Type $value | ||
* @param \Generator<int, ResultBucketInterface<Type>, Type, void> ...$generators | ||
*/ | ||
public function send($value, \Generator ...$generators): \Generator | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,9 @@ | |
|
||
class Pipeline implements PipelineInterface, WalkableInterface, RunnableInterface | ||
{ | ||
/** @var \AppendIterator<int<0, max>, non-empty-array<array-key, mixed>|object, \Iterator<int<0, max>, non-empty-array<array-key, mixed>|object>> */ | ||
/** @var \AppendIterator<int, mixed, \Iterator<int, mixed>> */ | ||
private readonly \AppendIterator $source; | ||
/** @var \Iterator<int<0, max>, non-empty-array<array-key, mixed>|object>|\NoRewindIterator */ | ||
/** @var \Iterator<int, mixed>|\NoRewindIterator */ | ||
private iterable $subject; | ||
|
||
public function __construct( | ||
|
@@ -45,7 +45,9 @@ public function __construct( | |
*/ | ||
public function feed(...$data): void | ||
{ | ||
$this->source->append(new \ArrayIterator($data)); | ||
/** @var \ArrayIterator<int, InputType> $iterator */ | ||
$iterator = new \ArrayIterator($data); | ||
$this->source->append($iterator); | ||
} | ||
|
||
private function passThroughCoroutine(): \Generator | ||
|
@@ -60,8 +62,8 @@ private function passThroughCoroutine(): \Generator | |
/** | ||
* @template Type | ||
* | ||
* @param ExtractorInterface<Type> $extractor | ||
* @param StepRejectionInterface<Type> $rejection | ||
* @param ExtractorInterface<Type> $extractor | ||
* @param StepRejectionInterface<Type|null> $rejection | ||
*/ | ||
public function extract( | ||
StepCodeInterface $stepCode, | ||
|
@@ -71,36 +73,20 @@ public function extract( | |
): ExtractingInterface { | ||
$extract = $extractor->extract(); | ||
if (\is_array($extract)) { | ||
$this->source->append( | ||
$this->runner->run( | ||
new \ArrayIterator($extract), | ||
$this->passThroughCoroutine(), | ||
$rejection, | ||
$state, | ||
) | ||
); | ||
/** @var \ArrayIterator<int, mixed> $iterator */ | ||
$iterator = new \ArrayIterator($extract); | ||
} elseif ($extract instanceof \Iterator) { | ||
Check warning on line 78 in src/Pipeline.php GitHub Actions / infection
Check warning on line 78 in src/Pipeline.php GitHub Actions / infection
|
||
$this->source->append( | ||
$this->runner->run( | ||
$extract, | ||
$this->passThroughCoroutine(), | ||
$rejection, | ||
$state, | ||
) | ||
); | ||
/** @var \Iterator<int, mixed> $iterator */ | ||
$iterator = $extract; | ||
} elseif ($extract instanceof \Traversable) { | ||
$this->source->append( | ||
$this->runner->run( | ||
new \IteratorIterator($extract), | ||
$this->passThroughCoroutine(), | ||
$rejection, | ||
$state, | ||
) | ||
); | ||
/** @var \IteratorIterator<int, mixed, \Iterator<int, mixed>> $iterator */ | ||
$iterator = new \IteratorIterator($extract); | ||
} else { | ||
throw new \RuntimeException('Invalid data source, expecting array or Traversable.'); | ||
} | ||
|
||
$this->source->append($this->runner->run($iterator, $this->passThroughCoroutine(), $rejection, $state)); | ||
Check failure on line 88 in src/Pipeline.php GitHub Actions / phpstan
|
||
|
||
return $this; | ||
} | ||
|
||
|
@@ -109,7 +95,7 @@ public function extract( | |
* @template OutputType | ||
* | ||
* @param TransformerInterface<InputType, OutputType> $transformer | ||
* @param StepRejectionInterface<InputType> $rejection | ||
* @param StepRejectionInterface<InputType|null> $rejection | ||
*/ | ||
public function transform( | ||
StepCodeInterface $stepCode, | ||
|
@@ -118,6 +104,7 @@ public function transform( | |
StepStateInterface $state, | ||
): TransformingInterface { | ||
if ($transformer instanceof FlushableInterface) { | ||
/** @var \AppendIterator<int, mixed, \Iterator<int, mixed>> $iterator */ | ||
$iterator = new \AppendIterator(); | ||
|
||
$iterator->append( | ||
|
@@ -158,7 +145,7 @@ public function transform( | |
* @template OutputType | ||
* | ||
* @param LoaderInterface<InputType, OutputType> $loader | ||
* @param StepRejectionInterface<InputType> $rejection | ||
* @param StepRejectionInterface<InputType|null> $rejection | ||
*/ | ||
public function load( | ||
StepCodeInterface $stepCode, | ||
|