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
Method App\Enums\Role::toCollection() should return Illuminate\Support\Collection<int, App\Enums\Role>
but returns Illuminate\Support\Collection<int, App\Enums\Role::Admin|App\Enums\Role::Supporter|App\Enums\Role::User>
Bug report
Originally created here: larastan/larastan#1129
When adding enums to my project, I'd like to return all the cases as a collection.
I kinda would expect this return type would work:
/** @return Collection<int, Role> */
Since the returned value of
Role::cases()[0]
isRole
.However, it requires all possible cases set:
/** @return Collection<int, Role::Admin|Role::Supporter|Role::User> */
So I'm getting this error:
Is this the intended behavior?
Laravel code where the issue was found
Code snippet that reproduces the problem
https://phpstan.org/r/e7c7fd51-04fc-4f4f-a63e-3794812f3065
Expected output
I was expecting that return type
Enum
would be enough, not the individual Enumcase
.Did PHPStan help you today? Did it make you happy in any way?
Happy to use PHPStan as a part of our CI. Thank you so much for making code cleaner and my IDE happier :>
The text was updated successfully, but these errors were encountered: