Change method call to desired static call
final class SomeClass
{
private $anotherDependency;
public function __construct(AnotherDependency $anotherDependency)
{
$this->anotherDependency = $anotherDependency;
}
public function loadConfiguration()
{
- return $this->anotherDependency->process('value');
+ return StaticCaller::anotherMethod('value');
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\Transform\Rector\MethodCall\MethodCallToStaticCallRector;
use Rector\Transform\ValueObject\MethodCallToStaticCall;
return RectorConfig::configure()
->withConfiguredRule(MethodCallToStaticCallRector::class, [
new MethodCallToStaticCall('AnotherDependency', 'process', 'StaticCaller', 'anotherMethod'),
]);