-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
Expand unpacked constant array parameter when checking function call #3481
Comments
Fixed: phpstan/phpstan-src@a21012d |
https://phpstan.org/r/7bade35e-c6ba-4f23-918a-3b16aef57f0b This change is now reporting false positives. It works if it knows for sure how many elements are in array but it is reporting error if the array is created with conditions. |
@soukicz I don't think it's a false positive. it can happen that your array is empty, and that throws an exception: https://3v4l.org/NnEhZ |
Damn... I didn't realize that my count condition doesn't handle empty array (because it cannot happen in real use case) |
So is PHPStan correct here, or do you have a better example that shows a false positive? :) |
Here is updated example that shouldn't report error: https://phpstan.org/r/17472a8a-39d9-4542-85fd-2e0772ba5ba9 EDIT: updated to even more specific condition |
Tracked as: #3558 |
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
Code snippet that reproduces the problem
https://phpstan.org/r/3499bb45-63b7-45e6-96ce-4b00b094c553
Expected output
No errors
The text was updated successfully, but these errors were encountered: