Skip to content

[Symfony61] Remove empty configure() method even with empty body#966

Merged
TomasVotruba merged 1 commit into
mainfrom
remove-empty-configure-body
Jul 22, 2026
Merged

[Symfony61] Remove empty configure() method even with empty body#966
TomasVotruba merged 1 commit into
mainfrom
remove-empty-configure-body

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to #965.

CommandConfigureToAttributeRector now removes the configure() method when it has an empty body — and, importantly, no longer adds a useless empty #[AsCommand] attribute when there is nothing to move into it.

 final class EmptyConfigureBody extends \Symfony\Component\Console\Command\Command
 {
-    protected function configure(): void
-    {
-    }
 }

Previously an already-empty configure() would have gained a bogus #[AsCommand] with no arguments. The attribute is now only created/updated when there is at least one resolved argument (name, description, aliases, hidden).

Non-empty configure() bodies are untouched — the method is kept when real leftover calls remain (addOption(), addArgument(), setHelp(), …).

@TomasVotruba
TomasVotruba merged commit 39d5404 into main Jul 22, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the remove-empty-configure-body branch July 22, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant