Cannot autowire service "RectorLaravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector": argument "$nodesToAddCollector" of method "__construct()" has type "Rector\PostRector\Collector\NodesToAddCollector" but this class was not found.
Closed this issue · 8 comments
I just upgraded to rector 0.17.1
and I have this error when running rector process --dry-run
rector process --dry-run
[ERROR] Cannot autowire service "RectorLaravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector": argument
"$nodesToAddCollector" of method "__construct()" has type "Rector\PostRector\Collector\NodesToAddCollector" but
this class was not found.
Script rector process --dry-run handling the scan event returned with error code 1
Here is my rector.php
file
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
use Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector;
use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\MethodCall\SpatieEnumMethodCallToEnumConstRector;
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
use Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use RectorLaravel\Set\LaravelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . "/app",
__DIR__ . "/config",
/**
* @todo Try to uncomment and see if it still gets stuck in infinite loop (since 0.15.10)
*/
// __DIR__ . "/database",
__DIR__ . "/lang",
__DIR__ . "/resources/views",
__DIR__ . "/routes",
__DIR__ . "/tests",
]);
$rectorConfig->skip([
ClassOnObjectRector::class,
StaticCallOnNonStaticToInstanceCallRector::class,
FirstClassCallableRector::class,
RemoveNonExistingVarAnnotationRector::class,
RemoveLastReturnRector::class,
ChangeReadOnlyVariableWithDefaultValueToConstantRector::class,
__DIR__ . "/database/migrations/*",
ReadOnlyClassRector::class => [
__DIR__ . "/app/Events", // Because Laravel trait "InteractsWithSockets" have non read only property.
__DIR__ . "/app/Jobs", // Because Laravel trait "InteractsWithQueue" have non read only property.
],
SpatieEnumMethodCallToEnumConstRector::class,
]);
// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,
SetList::DEAD_CODE,
SetList::PRIVATIZATION,
SetList::EARLY_RETURN,
SetList::TYPE_DECLARATION,
LaravelSetList::LARAVEL_90,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
]);
};
I just tried to require rector/rector:0.17.0
and there is no issue. I guess 0.17.1
contains breaking changes for package maintainers.
Same problem here after upgrading rector from 0.17.0
to 0.17.1
on Laravel 10.
Error happens even if I don't declare any LaravelSetList
on rector.php
file.
same...
Please try to reconfigure it like this:
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('RectorLaravel\\', './vendor/driftingly/rector-laravel/src')
->exclude(['./vendor/driftingly/rector-laravel/src/{Rector,ValueObject}']);
@egorbwork
Can you explain... Where to use this?
@egorbwork Can you explain... Where to use this?
Something like:
return static function (RectorConfig $rectorConfig): void {
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('RectorLaravel\\', './vendor/driftingly/rector-laravel/src')
->exclude(['./vendor/driftingly/rector-laravel/src/{Rector,ValueObject}']);
// ...
Unfortunately no solution at the moment but a workaround.
Comment out the line LaravelSetList::LARAVEL_CODE_QUALITY
.
On rector:0.17.7
I note that after commenting the LaravelSetList::LARAVEL_CODE_QUALITY
, I get these errors:
Could not process "/home/ubuntu/tests/Feature/Mails/ContactMessageNotificationTest.php" file, due to:
"System error: "Call to undefined method Rector\Core\PhpParser\Node\BetterNodeFinder::findParentType()"
Freezing to version rector:0.17.0
fixes all the issues (and I do not have to comment LaravelSetList::LARAVEL_CODE_QUALITY
).
We just released an update that should fix these issues - let me know.