Replaces the use of call_user_func
and call_user_func_array
method with the CallForwarding trait
class SomeClass
{
+ use ForwardsCalls;
+
public function __call($method, $parameters)
{
- return call_user_func_array([$this->foo, $method], $parameters);
+ return $this->forwardCallTo($this->foo, $method, $parameters);
}
}
Configure your rector.php
:
<?php
use RectorLaravel\Rector\Class_\UseForwardsCallsTraitRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
UseForwardsCallsTraitRector::class,
]);