Find the best Rector rule to solve your problem


Configurable

RenameClassRector

Replaces defined classes by new ones.

 namespace App;

-use SomeOldClass;
+use SomeNewClass;

-function someFunction(SomeOldClass $someOldClass): SomeOldClass
+function someFunction(SomeNewClass $someOldClass): SomeNewClass
 {
-    if ($someOldClass instanceof SomeOldClass) {
-        return new SomeOldClass;
+    if ($someOldClass instanceof SomeNewClass) {
+        return new SomeNewClass;
     }
 }

ParamAndEnvAttributeRector

Make param/env use in #[Attribute] more precise

 namespace App\Service;

 use Symfony\Component\DependencyInjection\Attribute\Autowire;

 class MessageGenerator
 {
     public function __construct(
-        #[Autowire('%kernel.debug%')]
+        #[Autowire(param: 'kernel.debug')]
         bool $debugMode,

-        #[Autowire('%env(SOME_ENV_VAR)%')]
+        #[Autowire(env: 'SOME_ENV_VAR')]
         string $senderName,
     ) {
     }
 }
SETS:  symfony/* 6.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/* 6.3