Change param type based on passed method call type
class SomeTypedService
{
public function run(string $name)
{
}
}
final class UseDependency
{
public function __construct(
private SomeTypedService $someTypedService
) {
}
- public function go($value)
+ public function go(string $value)
{
$this->someTypedService->run($value);
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
return RectorConfig::configure()
->withRules([
ParamTypeByMethodCallTypeRector::class,
]);