Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'*/Fixture/*',
StringClassNameToClassConstantRector::class => [
__DIR__ . '/src/Enum',
__DIR__ . '/src/Rules/Enum',
__DIR__ . '/src/Testing/PHPUnitTestAnalyser.php',
__DIR__ . '/src/Rules/NoEntityOutsideEntityNamespaceRule.php',
__DIR__ . '/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php',
Expand Down
5 changes: 5 additions & 0 deletions src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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 [];
}

foreach ($node->attrGroups as $attrGroup) {
foreach ($attrGroup->attrs as $attr) {
if ($attr->name->toString() === SymfonyAttribute::AS_COMMAND) {
Expand Down
5 changes: 5 additions & 0 deletions src/Rules/Symfony/ConstraintMustHaveAttributeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

// do not require an attribute when the validator component is not even installed
if (! $this->reflectionProvider->hasClass(SymfonyAttribute::CONSTRAINT)) {
return [];
}

$className = (string) $node->namespacedName;
if (! $this->reflectionProvider->hasClass($className)) {
return [];
Expand Down
Loading