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;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
return RectorConfig::configure()
->withConfiguredRule(RenameClassRector::class, [
'App\SomeOldClass' => 'App\SomeNewClass',
]);