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

VarDumperTestTraitMethodArgsRector

Adds a new $filter argument in VarDumperTestTrait->assertDumpEquals() and VarDumperTestTrait->assertDumpMatchesFormat() in Validator in Symfony.

-$varDumperTestTrait->assertDumpEquals($dump, $data, $message = "");
+$varDumperTestTrait->assertDumpEquals($dump, $data, $filter = 0, $message = "");
SETS:  symfony/* 4.0

FormIsValidRector

Adds $form->isSubmitted() validation to all $form->isValid() calls in Form in Symfony

-if ($form->isValid()) {
+if ($form->isSubmitted() && $form->isValid()) {
 }
SETS:  symfony/* 4.0

ContainerBuilderCompileEnvArgumentRector

Turns old default value to parameter in ContainerBuilder->build() method in DI in Symfony

 use Symfony\Component\DependencyInjection\ContainerBuilder;

 $containerBuilder = new ContainerBuilder();
-$containerBuilder->compile();
+$containerBuilder->compile(true);
SETS:  symfony/* 4.0

ConstraintUrlOptionRector

Turns true value to Url::CHECK_DNS_TYPE_ANY in Validator in Symfony.

-$constraint = new Url(["checkDNS" => true]);
+$constraint = new Url(["checkDNS" => Url::CHECK_DNS_TYPE_ANY]);
SETS:  symfony/* 4.0