diff --git a/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php b/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php index ee327a55..fa3c0a75 100644 --- a/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php +++ b/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php @@ -71,6 +71,11 @@ public function processNode(Node $node, Scope $scope): array return []; } + // do not require an attribute the project does not even have + if (! $this->reflectionProvider->hasClass(SymfonyAttribute::AS_COMMAND)) { + return []; + } + // symfony/console must be a direct production dependency, require-dev is skipped if (! $this->composerRequireResolver->hasRequiredPackage(self::SYMFONY_CONSOLE_PACKAGE)) { return []; @@ -95,11 +100,6 @@ public function processNode(Node $node, Scope $scope): array return []; } - // do not require an attribute the project does not even have - if (! $this->reflectionProvider->hasClass(SymfonyAttribute::AS_COMMAND)) { - return []; - } - foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { if ($attr->name->toString() === SymfonyAttribute::AS_COMMAND) {