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
Can't override mixed to iterable #6564
Comments
Couldn't you just check with |
Fixed: phpstan/phpstan-src@b6bbbaf |
No errors now on bleeding edge! Thanks! :) @staabm I could, but I tend to not add code for static analysis purposes. The code already does enough checks to make sure it's iterable. It just has been hard to tell PHPStan. In such cases my heuristic is to not add code, but rather a typehint. In cases where I (the developer) know that the variable is indeed iterable based on business rules, but I make no effort to enforce it - that's where I'll add the code. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
When a variable is mixed I can't make it iterable. The "iterability" is checked by outside factors. In my particular case it's where I need to iterate the value in Symfony validator. And the value's iterability is determined by \Symfony\Component\Validator\Constraints\Choice::$multiple (https://github.com/symfony/validator/blob/5.4/Constraints/ChoiceValidator.php#L67).
Code snippet that reproduces the problem
https://phpstan.org/r/ee58cb2e-38b4-4fb4-82d9-3250a9691deb
Expected output
Ideally I would hint that inside the condition the variable contains
mixed[]
The text was updated successfully, but these errors were encountered: