EloquentMagicMethodToQueryBuilderRector transforms class to include namespace
Closed this issue · 2 comments
phh commented
Example from EloquentMagicMethodToQueryBuilderRector prepends query
to the Eloquent magic methods.
Example:
use App\Models\User;
-$user = User::find(1);
+$user = User::query()->find(1);
After trying it:
use App\Models\User;
-$user = User::find(1);
+$user = \App\Models\User::query()->find(1);
Is there a way for the rule to leave the class at the current class name and only prepend the query()
method?
Ruleset is very simple:
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/app',
]);
$rectorConfig->rule(EloquentMagicMethodToQueryBuilderRector::class);
};
phh commented
And I know I can just $rectorConfig->importNames();
but I would rather not include that rule at this point.
clementbirkle commented
Try with this config:
$rectorConfig->importNames(importDocBlockNames: false);
$rectorConfig->importShortClasses(false);
It should works.