diff --git a/packages/ReflectionDocBlock/tests/NodeAnalyzer/DocBlockAnalyzerTest.php b/packages/ReflectionDocBlock/tests/NodeAnalyzer/DocBlockAnalyzerTest.php index c79757b12d0..59e5406037f 100644 --- a/packages/ReflectionDocBlock/tests/NodeAnalyzer/DocBlockAnalyzerTest.php +++ b/packages/ReflectionDocBlock/tests/NodeAnalyzer/DocBlockAnalyzerTest.php @@ -35,6 +35,7 @@ final class DocBlockAnalyzerTest extends AbstractContainerAwareTestCase $this->docBlockAnalyzer->removeAnnotationFromNode($node, 'param'); $emptyDoc = <<<'EOT' /** + * */ EOT; $this->assertSame($emptyDoc, $node->getDocComment()->getText()); diff --git a/packages/YamlParser/src/Rector/Contrib/Symfony/AutoconfigureRector.php b/packages/YamlParser/src/Rector/Contrib/Symfony/AutoconfigureRector.php index f336b810111..2c95704115e 100644 --- a/packages/YamlParser/src/Rector/Contrib/Symfony/AutoconfigureRector.php +++ b/packages/YamlParser/src/Rector/Contrib/Symfony/AutoconfigureRector.php @@ -68,23 +68,7 @@ final class AutoconfigureRector implements YamlRectorInterface // find class with system tags foreach ($services as $key => $service) { - if (! isset($service['tags'])) { - continue; - } - - $tags = $service['tags']; - // more tags or more than tag name - if (count($tags) !== 1 || count($tags[0]) !== 1) { - continue; - } - - if (! isset($tags[0]['name'])) { - continue; - } - - // is system tag name - $tagName = $tags[0]['name']; - if (! in_array($tagName, $this->systemTags, true)) { + if ($this->shouldSkip($service)) { continue; } @@ -115,4 +99,32 @@ final class AutoconfigureRector implements YamlRectorInterface return array_merge($defaultsAutowire, $services); } + + /** + * @param mixed[] $service + */ + private function shouldSkip(array $service): bool + { + if (! isset($service['tags'])) { + return true; + } + + $tags = $service['tags']; + // more tags or more than tag name + if (count($tags) !== 1 || count($tags[0]) !== 1) { + return true; + } + + if (! isset($tags[0]['name'])) { + return true; + } + + // is system tag name + $tagName = $tags[0]['name']; + if (! in_array($tagName, $this->systemTags, true)) { + return true; + } + + return false; + } }