Closed eithed closed 3 years ago
I wasn't able to reproduce this in the test suite: https://github.com/psalm/psalm-plugin-laravel/commit/997c3e61447c3a05c219e4fc62a50e707fc0a55b
I believe this may be resolved now. Please reopen if you think I'm incorrect!
Describe the bug When using
find
orfindOrFail
methods within Laravel as such:It will be inferred that
Illuminate\Database\Eloquent\Collection<Illuminate\Database\Eloquent\Model>|Illuminate\Database\Eloquent\Model
is being returned, even though what is actually returned is object ofAccount
type, per declaration withinfind
orfindOrFail
being* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static|static[]
This will cause additional errors to be returned like:
or
It's as if
static
was not being taken into account when considering returned types.As a workaround one needs to preamble with
@var
as such:but I believe the expected behaviour should be inferring that
Account
model is being returned perstatic
Impacted Versions