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;
     }
 }

Configurable

RenameAttributeRector

Rename attribute class names

-#[SimpleRoute()]
+#[BasicRoute()]
 class SomeClass
 {
 }

Configurable

AddReturnTypeDeclarationRector

Changes defined return typehint of method and class.

 class SomeClass
 {
-    public function getData()
+    public function getData(): array
     {
     }
 }