Find the best Rector rule to solve your problem



Configurable

RenameFunctionRector

Turns defined function call new one.

-view("...", []);
+Laravel\Templating\render("...", []);

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

AuthorizationCheckerIsGrantedExtractorRector

Change $this->authorizationChecker->isGranted([$a, $b]) to $this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b), also updates AbstractController usages

-if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) {
+if ($this->authorizationChecker->isGranted('ROLE_USER') || $this->authorizationChecker->isGranted('ROLE_ADMIN')) {
 }
SETS:  symfony/* 4.4

ConsoleExecuteReturnIntRector

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;
     }
 }
SETS:  symfony/* 4.4