Skip to content

Use explicit Symfony attribute allowlist in StandaloneLineSymfonyAttributeParamFixer#58

Merged
TomasVotruba merged 1 commit into
mainfrom
symfony-attribute-explicit-allowlist
Jul 22, 2026
Merged

Use explicit Symfony attribute allowlist in StandaloneLineSymfonyAttributeParamFixer#58
TomasVotruba merged 1 commit into
mainfrom
symfony-attribute-explicit-allowlist

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Replaces the str_contains($name, 'Symfony') heuristic in StandaloneLineSymfonyAttributeParamFixer with an explicit allowlist of Symfony attribute classes (SYMFONY_ATTRIBUTE_CLASSES), AsCommand first.

Why

Substring match on "Symfony" is too broad — any third-party attribute whose FQCN happens to contain Symfony (e.g. a App\Symfony\... namespace) would be reformatted. An explicit class list keeps the fixer scoped to real Symfony attributes.

Behavior

Matches a fixed set of 17 common Symfony attributes (Console, Routing, DependencyInjection, EventDispatcher, Messenger, HttpKernel, Security). Both forms recognized:

  • fully-qualified: #[\Symfony\Component\Console\Attribute\AsCommand(...)]
  • short name via use: #[AsCommand(...)]

Partially-qualified names no longer match (only fully-qualified or use-imported).

-#[\Symfony\Component\Console\Attribute\AsCommand(name: 'app:some', description: 'Some description')]
+#[\Symfony\Component\Console\Attribute\AsCommand(
+    name: 'app:some',
+    description: 'Some description'
+)]
 final class SomeCommand
 {
 }

@TomasVotruba
TomasVotruba merged commit 4697d50 into main Jul 22, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the symfony-attribute-explicit-allowlist branch July 22, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant