Add type hinting to where relation has methods e.g. whereHas, orWhereHas, whereDoesntHave, orWhereDoesntHave, whereHasMorph, orWhereHasMorph, whereDoesntHaveMorph, orWhereDoesntHaveMorph
-User::whereHas('posts', function ($query) {
+User::whereHas('posts', function (\Illuminate\Contracts\Database\Eloquent\Builder $query) {
$query->where('is_published', true);
});
-$query->whereHas('posts', function ($query) {
+$query->whereHas('posts', function (\Illuminate\Contracts\Database\Eloquent\Builder $query) {
$query->where('is_published', true);
});
This rule covers scenarios where the Model static proxy passes the method call to a query builder by forwarded calls and on the Builder contract. This will refactor both closures and arrow functions.
Adds the following rule:
EloquentWhereRelationTypeHintingParameterRector
Add type hinting to where relation has methods e.g. whereHas, orWhereHas, whereDoesntHave, orWhereDoesntHave, whereHasMorph, orWhereHasMorph, whereDoesntHaveMorph, orWhereDoesntHaveMorph
RectorLaravel\Rector\MethodCall\EloquentWhereRelationTypeHintingParameterRector
This rule covers scenarios where the Model static proxy passes the method call to a query builder by forwarded calls and on the Builder contract. This will refactor both closures and arrow functions.