Caleb White
Caleb White
This is expected behaviour: - https://github.com/calebdw/larastan/issues/17#issuecomment-2355784416 - https://github.com/phpstan/phpstan/issues/11707 This can only be fixed when PHPStan adds more generic `*DynamicParameterTypeExtension` (as opposed to just `*ClosureTypeExtensions`).
You can: - remove the closure type - use `Relation` as the type - override the type with an `@var` *inside* the closure - ignore the error
Do you mind testing this on my fork to see if it's an issue?
This is a PHPStan bug/limitation---I've opened an issue
From the PHPStan issue, final classes need to use `#[AllowDynamicProperties]` in order for this to work
This works on my [fork](https://github.com/calebdw/larastan) (needs #2048). Or you can add the type yourself: ```php Post::whereHas('comments', function($query) use($search): void { /** @var Builder $query */ $query->where('content', 'like', '%'.$search.'%') ->whereDate('created_at', '>=',...
It does work, you just need to ignore that particular error (parameter types are contravariant)
The problem is the parameter type in the closure
@canvural, > Looks like Laravel 11.42 broke this. The types they've added are wrong. I'll fix them in the stubs. If you're talking about my changes in https://github.com/laravel/framework/pull/54452, then the...
> The fact that parameter types are contravariant proves the types in the framework are wrong. Custom builders and specific relations are still a Builder and Relation. We should not...