You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR: #54452
Fixes the typehint of the callback in the has function. But when $relation is passed as a string the 'TRelatedModel' is left 'anonymous' and the typehint fails to resolve to the related model.
When then using e.g. scopes in the closure, static analysis says (larastan in this case) the type is wrong.
I'm also doubting if this is something Larastan 'should fix'.
Steps To Reproduce
So to stay with the examples from the PR:
This works:
$query->whereHas($user->posts(), function ($query) {
// Knows that it's a Post Builder!
assertType('Illuminate\Database\Eloquent\Builder<Illuminate\Types\Builder\Post>', $query);
});
But this doesnt:
$query->whereHas('posts', function ($query) {
// Doesnt know what builder it is when first argument is a string, only that its a Model of some kind.
assertType('Builder<Model>', $query);
});
The text was updated successfully, but these errors were encountered:
Laravel Version
11.42.0
PHP Version
8.3.16
Database Driver & Version
n/a
Description
This PR: #54452
Fixes the typehint of the callback in the has function. But when $relation is passed as a string the 'TRelatedModel' is left 'anonymous' and the typehint fails to resolve to the related model.
When then using e.g. scopes in the closure, static analysis says (larastan in this case) the type is wrong.
I'm also doubting if this is something Larastan 'should fix'.
Steps To Reproduce
So to stay with the examples from the PR:
This works:
But this doesnt:
The text was updated successfully, but these errors were encountered: