New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return enums as collection requires all individual cases #1129
Comments
Mainly wondering if this is the expected behavior or not. If not I would love to come up with a suggestion for a fix! |
Hi, I don't understand the issue.
What is the error you are getting? |
Sorry, forgot the error. Added to the description as well:
|
Ok, this looks like a PHPStan issue. Here is a simple reproduction: https://phpstan.org/r/e7c7fd51-04fc-4f4f-a63e-3794812f3065 Feel free to create an issue there with the playground link I gave. |
@canvural Thanks for reproducing the error in phpstan.org 🙏 |
Fixed here phpstan/phpstan#6695 / phpstan/phpstan-src@9e42896 Thank you again. |
--level
used: 6Description
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
The text was updated successfully, but these errors were encountered: