RouteActionCallableRector (Cannot autowire service)
Closed this issue · 7 comments
fridzema commented
<?php
use Rector\Config\RectorConfig;
use RectorLaravel\Rector\StaticCall\RouteActionCallableRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/routes',
]);
$rectorConfig->ruleWithConfiguration(RouteActionCallableRector::class, [
RouteActionCallableRector::NAMESPACE => 'App\Http\Controllers',
]);
};
[ERROR] Cannot autowire service "RectorLaravel\Rector\StaticCall\RouteActionCallableRector": argument
"$routerRegisterNodeAnalyzer" of method "__construct()" references class
"RectorLaravel\NodeFactory\RouterRegisterNodeAnalyzer" but no such service exists.
Tested with both PHP 8.1.17
,8.2.4
rector/rector: 0.15.24
driftingly/rector-laravel: 0.17.0
Any idea what i am doing wrong?
egorbwork commented
Encountered same issue
egorbwork commented
Added in the configuration:
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('RectorLaravel\\', './vendor/driftingly/rector-laravel/src')
->exclude(['./vendor/driftingly/rector-laravel/src/{Rector,ValueObject}']);
Helps to run it, not sure that the command works for my routes, maybe my configurations are not correct.
fridzema commented
@egorbwork Thanks for the suggestion. Seems to avoid the error, although it seems to do nothing...
egorbwork commented
@egorbwork Thanks for the suggestion. It seems to avoid the error, although it seems to do nothing...
Yes, I have rewritten for my need this rule, to cover more cases. I will open a pr in this repository later in 24 hours. You could check if my adjustments covered your needs too.
fridzema commented
@egorbwork Thanks, works perfect now!