diff --git a/packages/documentator/src/Processor/Contracts/Dependency.php b/packages/documentator/src/Processor/Contracts/Dependency.php index c8a36604..24d4c47d 100644 --- a/packages/documentator/src/Processor/Contracts/Dependency.php +++ b/packages/documentator/src/Processor/Contracts/Dependency.php @@ -2,17 +2,17 @@ namespace LastDragon_ru\LaraASP\Documentator\Processor\Contracts; -use Iterator; use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\DependencyNotFound; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\FileSystem; use Stringable; +use Traversable; /** * Task dependency (= another file). * - * @template TValue of Iterator|Directory|File|null + * @template TValue of Traversable|Directory|File|null */ interface Dependency extends Stringable { /** diff --git a/packages/documentator/src/Processor/Dependencies/Optional.php b/packages/documentator/src/Processor/Dependencies/Optional.php index 47a4ab77..8126dd05 100644 --- a/packages/documentator/src/Processor/Dependencies/Optional.php +++ b/packages/documentator/src/Processor/Dependencies/Optional.php @@ -2,16 +2,16 @@ namespace LastDragon_ru\LaraASP\Documentator\Processor\Dependencies; -use Iterator; use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Dependency; use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\DependencyNotFound; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\FileSystem; use Override; +use Traversable; /** - * @template TValue of Iterator|Directory|File|null + * @template TValue of Traversable|Directory|File|null * * @implements Dependency */ diff --git a/packages/documentator/src/Processor/Executor.php b/packages/documentator/src/Processor/Executor.php index c44261ef..cf368908 100644 --- a/packages/documentator/src/Processor/Executor.php +++ b/packages/documentator/src/Processor/Executor.php @@ -19,6 +19,7 @@ use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\FileSystem; use Throwable; +use Traversable; use function array_merge; use function array_values; @@ -124,15 +125,15 @@ private function runFile(File $file): float { $dependency = $generator->current(); $resolved = $dependency($this->fs, $this->root, $file); - if ($resolved instanceof Iterator) { - $resolved = new ExecutorIterator($dependency, $resolved, $this->runDependency(...)); + if ($resolved instanceof Traversable) { + $resolved = new ExecutorTraversable($dependency, $resolved, $this->runDependency(...)); } else { $paused += $this->runDependency($dependency, $resolved); } $generator->send($resolved); - if ($resolved instanceof ExecutorIterator) { + if ($resolved instanceof ExecutorTraversable) { $paused += $resolved->getDuration(); } } diff --git a/packages/documentator/src/Processor/ExecutorIterator.php b/packages/documentator/src/Processor/ExecutorTraversable.php similarity index 79% rename from packages/documentator/src/Processor/ExecutorIterator.php rename to packages/documentator/src/Processor/ExecutorTraversable.php index 1a2063f5..66ac93bb 100644 --- a/packages/documentator/src/Processor/ExecutorIterator.php +++ b/packages/documentator/src/Processor/ExecutorTraversable.php @@ -4,12 +4,12 @@ use Closure; use Generator; -use Iterator; use IteratorAggregate; use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Dependency; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; use Override; +use Traversable; /** * @internal @@ -19,20 +19,20 @@ * * @implements IteratorAggregate */ -class ExecutorIterator implements IteratorAggregate { +class ExecutorTraversable implements IteratorAggregate { private float $duration = 0; public function __construct( /** - * @var Dependency> + * @var Dependency> */ private readonly Dependency $dependency, /** - * @var Iterator + * @var Traversable */ - private readonly Iterator $resolved, + private readonly Traversable $resolved, /** - * @var Closure(Dependency>, TValue): float + * @var Closure(Dependency>, TValue): float */ private readonly Closure $handler, ) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0d369b61..7e18b431 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6,7 +6,7 @@ parameters: path: packages/core/src/Observer/DispatcherTest.php - - message: "#^Parameter \\#1 \\$dependency of class LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\ExecutorIterator constructor expects LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\Contracts\\\\Dependency\\\\>, LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\Contracts\\\\Dependency\\<\\*\\> given\\.$#" + message: "#^Parameter \\#1 \\$dependency of class LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\ExecutorTraversable constructor expects LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\Contracts\\\\Dependency\\\\>, LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\Contracts\\\\Dependency\\<\\*\\> given\\.$#" count: 1 path: packages/documentator/src/Processor/Executor.php