mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
improve complexity
This commit is contained in:
parent
3fa22870f7
commit
dbd515df9c
@ -35,6 +35,7 @@ final class DocBlockAnalyzerTest extends AbstractContainerAwareTestCase
|
||||
$this->docBlockAnalyzer->removeAnnotationFromNode($node, 'param');
|
||||
$emptyDoc = <<<'EOT'
|
||||
/**
|
||||
*
|
||||
*/
|
||||
EOT;
|
||||
$this->assertSame($emptyDoc, $node->getDocComment()->getText());
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user