Run Rector on your code to see what it can do for you:

 <?php
 
 use Symfony\Component\Console\Attribute\AsCommand;
 use Symfony\Component\Console\Style\SymfonyStyle;
 
 #[AsCommand('app:my-command')]
-final class MyCommand extends Command
+final class MyCommand
 {
-    #[\Override]
-    protected function execute(InputInterface $input, OutputInterface $output): int
-    {
-        $io = new SymfonyStyle($input, $output);
-		$io->info('Great success!');
-
-		return 1;
+    public function __invoke(OutputInterface $output): int
+    {
+        $io = new SymfonyStyle($input, $output);
+        $io->info('Great success!');
+        return 1;
     }
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: 826973 - released at 2025-07-25 17:52