Find the best Rector rule to solve your problem. Searching through 1009 rules.
Found 8 rules:
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';
- }
}
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');
- }
}
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;
}
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');
-
- }
}
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';
}
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;
}
}
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;
}
}
Turns old event name with EXCEPTION to ERROR constant in Console in Symfony
-"console.exception"
+RectorPrefix202608\Symfony\Component\Console\ConsoleEvents::ERROR