diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php index 74943fcb..6f412bbf 100644 --- a/tests/GeneratorTest.php +++ b/tests/GeneratorTest.php @@ -109,11 +109,11 @@ public function testRemoveProcessor(): void protected function assertOperationIdHash(Generator $generator, bool $expected): void { - foreach ($generator->getProcessors() as $processor) { + $generator->getProcessor()->walk(function ($processor) use ($expected) { if ($processor instanceof OperationId) { $this->assertEquals($expected, $processor->isHash()); } - } + }); } public static function configCases(): iterable diff --git a/tests/OpenApiTestCase.php b/tests/OpenApiTestCase.php index 6fecc379..1950e8e2 100644 --- a/tests/OpenApiTestCase.php +++ b/tests/OpenApiTestCase.php @@ -226,13 +226,17 @@ public static function fixtures(array $files): array }, $files); } - public static function processors(array $strip = [], array $add = []): array + public static function processors(array $strip = []): array { - $processors = (new Generator())->getProcessors(); + $processors = []; - $processors = array_filter($processors, function ($processor) use ($strip) { - return !is_object($processor) || !in_array(get_class($processor), $strip); - }); + (new Generator()) + ->getProcessor() + ->walk(function ($processor) use (&$processors, $strip) { + if (!is_object($processor) || !in_array(get_class($processor), $strip)) { + $processors[] = $processor; + } + }); return $processors; } diff --git a/tools/src/Docs/ProcGenerator.php b/tools/src/Docs/ProcGenerator.php index 702ccac9..8e71cb15 100644 --- a/tools/src/Docs/ProcGenerator.php +++ b/tools/src/Docs/ProcGenerator.php @@ -51,19 +51,21 @@ public function getProcessorsDetails(): array $processors = []; $defaultProcessors = []; - foreach ((new Generator())->getProcessors() as $processor) { - $rc = new \ReflectionClass($processor); - $class = $rc->getName(); + (new Generator()) + ->getProcessor() + ->walk(function ($processor) use (&$processors, &$defaultProcessors) { + $rc = new \ReflectionClass($processor); + $class = $rc->getName(); - $defaultProcessors[] = $class; - $processors[] = [ - 'class' => $class, - 'name' => $rc->getShortName(), - 'default' => true, - 'options' => $this->getOptionsDetails($rc), - 'phpdoc' => $this->extractDocumentation($rc->getDocComment()), - ]; - } + $defaultProcessors[] = $class; + $processors[] = [ + 'class' => $class, + 'name' => $rc->getShortName(), + 'default' => true, + 'options' => $this->getOptionsDetails($rc), + 'phpdoc' => $this->extractDocumentation($rc->getDocComment()), + ]; + }); $proccesorsDir = dirname((new \ReflectionClass(MergeIntoOpenApi::class))->getFileName()); foreach (glob("$proccesorsDir/*.php") as $processor) {