Hello,
I needed to update the route naming syntax in my Laravel project. I managed to do it using Rector: https://github.com/rectorphp/rector and the rector-laravel extension package with the specific rules for Laravel: https://github.com/driftingly/rector-laravel
At first I tried setting the rector.php file like this:
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use RectorLaravel\Rector\StaticCall\RouteActionCallableRector;
use Rector\Set\ValueObject\LevelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/routes'
]);
$rectorConfig->ruleWithConfiguration(RouteActionCallableRector::class, [
RouteActionCallableRector::NAMESPACE => 'App\Http\Controllers',
]);
};
But it threw the following error:
[ERROR] Cannot autowire service
"RectorLaravel\Rector\StaticCall\RouteActionCallableRector": argument
"$routerRegisterNodeAnalyzer" of method "__construct()" references class
"RectorLaravel\NodeFactory\RouterRegisterNodeAnalyzer" but no such service exists.
Then I noticed I do not have a setList like the examples, so I added the first setList I found randomly:
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/routes'
]);
$rectorConfig->ruleWithConfiguration(RouteActionCallableRector::class, [
RouteActionCallableRector::NAMESPACE => 'App\Http\Controllers',
]);
// added this
$rectorConfig->sets([
LaravelSetList::LARAVEL_CODE_QUALITY
]);
};
And it worked. But what exactly is the purpose of this setList? I just picked the first one that was autocompleted by the IDE. But there are many others like LaravelSetList::LARAVEL_100, LaravelSetList::LARAVEL_80, and so on.
Why was it necessary for the RouteActionCallableRector to work?
thanks