Skip to content

[Symfony61] Remove now empty configure() method in CommandConfigureToAttributeRector#965

Merged
TomasVotruba merged 2 commits into
mainfrom
remove-empty-configure-method
Jul 22, 2026
Merged

[Symfony61] Remove now empty configure() method in CommandConfigureToAttributeRector#965
TomasVotruba merged 2 commits into
mainfrom
remove-empty-configure-method

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

When CommandConfigureToAttributeRector moves setName()/setDescription()/setAliases()/setHidden() into the #[AsCommand] attribute, the configure() method is often left empty (or with only a parent::configure() call).

This extends the rule to remove the whole configure() method when nothing meaningful remains — either fully empty, or only a parent::configure() call left.

 use Symfony\Component\Console\Command\Command;

-final class SunshineCommand extends Command
+#[\Symfony\Component\Console\Attribute\AsCommand(name: 'mautic:fake:command')]
+final class SunshineCommand extends Command
 {
-    protected function configure(): void
-    {
-        $this->setName('mautic:fake:command');
-
-        parent::configure();
-    }
 }

The method is kept when real leftover calls remain (addOption(), addArgument(), setHelp(), …):

+#[\Symfony\Component\Console\Attribute\AsCommand(name: 'sunshine', aliases: ['first', 'second'])]
 final class OtherCalls extends Command
 {
     public function configure()
     {
-        $this->setName('sunshine')
-            ->setAliases(['first', 'second'])
-            ->addArgument('argument name');
+        $this
+            ->addArgument('argument name');
     }
 }

@TomasVotruba
TomasVotruba merged commit eb07f5e into main Jul 22, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the remove-empty-configure-method branch July 22, 2026 10: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