diff --git a/packages/documentator/src/Processor/Contracts/Task.php b/packages/documentator/src/Processor/Contracts/Task.php index f1f407ed..abbaee60 100644 --- a/packages/documentator/src/Processor/Contracts/Task.php +++ b/packages/documentator/src/Processor/Contracts/Task.php @@ -22,19 +22,13 @@ public static function getExtensions(): array; * or failed (`false`). * * The {@see Generator} means that the task has dependencies (= other files - * which should be processed before the task). Each returned value will be + * which should be processed before the current). Each returned value will be * resolved relative to the directory where the `$file` located, processed, * and then send back into the generator. * - * And, finally, the `null`. Special value that will postpone processing - * until all other files (and their dependencies) are processed. It may be - * useful, for example, if the task should collect information from all - * other files. Please note, the `null` can be returned only once, the - * second time will automatically mark the task as failed. - * - * @return Generator, mixed, bool>|bool|null - * fixme(documentator): The correct type is `Generator, V, bool>|bool|null` + * @return Generator, mixed, bool>|bool + * fixme(documentator): The correct type is `Generator, V, bool>|bool` * but it is not yet supported by phpstan (see https://github.com/phpstan/phpstan/issues/4245) */ - public function __invoke(Directory $root, File $file): Generator|bool|null; + public function __invoke(Directory $root, File $file): Generator|bool; } diff --git a/packages/documentator/src/Processor/Executor.php b/packages/documentator/src/Processor/Executor.php index 175ab6f0..adf3020a 100644 --- a/packages/documentator/src/Processor/Executor.php +++ b/packages/documentator/src/Processor/Executor.php @@ -107,17 +107,10 @@ private function runFile(File $file): float { foreach ($tasks as $task) { try { // Run + $result = false; $generator = $task($this->root, $file); - // Postponed? - if ($generator === null) { - $paused += $this->runIterator(); - $generator = $task($this->root, $file) ?? false; - } - // Dependencies? - $result = false; - if ($generator instanceof Generator) { while ($generator->valid()) { $dependency = $generator->current(); diff --git a/packages/documentator/src/Processor/ProcessorTest.php b/packages/documentator/src/Processor/ProcessorTest.php index 7f5412c5..4f8fbe14 100644 --- a/packages/documentator/src/Processor/ProcessorTest.php +++ b/packages/documentator/src/Processor/ProcessorTest.php @@ -179,104 +179,6 @@ static function (FilePath $path, Result $result) use (&$count, &$events): void { ); } - public function testRunPostpone(): void { - $task = new class() implements Task { - /** - * @var array - */ - public array $processed = []; - /** - * @var array - */ - public array $postponed = []; - - /** - * @inheritDoc - */ - #[Override] - public static function getExtensions(): array { - return ['txt', 'htm', 'html']; - } - - /** - * @inheritDoc - */ - #[Override] - public function __invoke(Directory $root, File $file): ?bool { - // Postponed? - $path = (string) $root->getRelativePath($file); - - if ($file->getExtension() === 'html' && !isset($this->postponed[$path])) { - $this->postponed[$path] = true; - - return null; - } - - // Process - $this->processed[] = $path; - - return true; - } - }; - - $root = (new DirectoryPath(self::getTestData()->path('')))->getNormalizedPath(); - $count = 0; - $events = []; - - (new Processor($this->app()->make(ContainerResolver::class))) - ->task($task) - ->exclude(['excluded.txt', '**/**/excluded.txt']) - ->run( - $root, - static function (FilePath $path, Result $result) use (&$count, &$events): void { - $events[(string) $path] = $result; - $count++; - }, - ); - - self::assertEquals( - [ - 'b/a/ba.txt' => Result::Success, - 'c.txt' => Result::Success, - 'b/b/bb.txt' => Result::Success, - 'a/a.txt' => Result::Success, - 'a/a/aa.txt' => Result::Success, - 'a/b/ab.txt' => Result::Success, - 'b/b.txt' => Result::Success, - 'c.htm' => Result::Success, - 'c.html' => Result::Success, - 'b/b.html' => Result::Success, - 'a/a.html' => Result::Success, - ], - $events, - ); - self::assertCount($count, $events); - self::assertEquals( - [ - 'a/a.txt', - 'a/a/aa.txt', - 'a/b/ab.txt', - 'b/a/ba.txt', - 'b/b.txt', - 'b/b/bb.txt', - 'c.htm', - 'c.txt', - 'c.html', - 'b/b.html', - 'a/a.html', - ], - $task->processed, - ); - self::assertEquals( - [ - 'c.html' => true, - 'b/b.html' => true, - 'a/a.html' => true, - ], - $task->postponed, - ); - } - public function testRunWildcard(): void { $taskA = new class([ 'b.html' => [