Find the best Rector rule to solve your problem. Searching through 1009 rules.

Found 8 rules:

CommandDefaultNameAndDescriptionToAsCommandAttributeRector

Replace getDefaultName() and getDefaultDescription() by #[AsCommand] attribute

+use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Command\Command;

+#[AsCommand(
+    name: 'app:some-command',
+    description: 'This is some command description'
+)]
 final class SomeCommand extends Command
 {
-    public static function getDefaultName(): string
-    {
-        return 'app:some-command';
-    }
-
-    public static function getDefaultDescription(): string
-    {
-        return 'This is some command description';
-    }
 }
SETS:  symfony/console
PACKAGE:  symfony/console >=7.3

CommandHelpToAttributeRector

Moves $this->setHelp() to the "help" named argument of #[AsCommand]

 use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Command\Command;

-#[AsCommand(name: 'app:some')]
+#[AsCommand(name: 'app:some', help: <<<'TXT'
+Some help text
+TXT)]
 final class SomeCommand extends Command
 {
-    protected function configure(): void
-    {
-        $this->setHelp('Some help text');
-    }
 }
SETS:  symfony/console
PACKAGE:  symfony/console >=7.3

SignalableCommandInterfaceReturnTypeRector

Return int or false from SignalableCommandInterface::handleSignal() instead of void

-public function handleSignal(int $signal): void
+public function handleSignal(int $signal): int|false
     {
+        return false;
     }
SETS:  symfony/console
PACKAGE:  symfony/console >=6.3

CommandConfigureToAttributeRector

Add Symfony\Component\Console\Attribute\AsCommand to Symfony Commands from configure()

+use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Command\Command;

+#[AsCommand(name: 'sunshine', description: 'Some description')]
 final class SunshineCommand extends Command
 {
-    public function configure()
-    {
-        $this->setName('sunshine');
-        $this->setDescription('Some description');
-
-    }
 }
SETS:  symfony/console
PACKAGE:  symfony/console >=6.1

CommandPropertyToAttributeRector

Add Symfony\Component\Console\Attribute\AsCommand to Symfony Commands and remove the deprecated properties

+use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Command\Command;

+#[AsCommand(name: 'sunshine', description: 'some description')]
 final class SunshineCommand extends Command
 {
-    public static $defaultName = 'sunshine';
-
-    public static $defaultDescription = 'some description';
 }
SETS:  symfony/console
PACKAGE:  symfony/console >=6.1

CommandConstantReturnCodeRector

Changes int return from execute to use Symfony Command constants.

 class SomeCommand extends Command
 {
     protected function execute(InputInterface $input, OutputInterface $output): int
     {
-        return 0;
+        return \Symfony\Component\Console\Command\Command::SUCCESS;
     }

 }
SETS:  symfony/console
PACKAGE:  symfony/console >=5.1

ConsoleExecuteReturnIntRector

Returns int from Command::execute() command

 use Symfony\Component\Console\Command\Command;

 class SomeCommand extends Command
 {
-    public function execute(InputInterface $input, OutputInterface $output)
+    public function execute(InputInterface $input, OutputInterface $output): int
     {
-        return null;
+        return 0;
     }
 }
SETS:  symfony/console
PACKAGE:  symfony/console >=4.4

ConsoleExceptionToErrorEventConstantRector

Turns old event name with EXCEPTION to ERROR constant in Console in Symfony

-"console.exception"
+RectorPrefix202608\Symfony\Component\Console\ConsoleEvents::ERROR
SETS:  symfony/console
PACKAGE:  symfony/console >=3.3