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
A property marked as non-empty-array seems to be incorrectly identified as possibly empty. This is after explicitly checking if the array has at least two items before using unset() on it.
/cc @herndlm Hypothetical "AccessoryArraySizeType" would be really helpful for this and other cases. I'd be able to use it in phpstan/phpstan-src#3865 too which fixes about 5-6 issues now.
The accompanying Type::getArraySize() method is already there. The new type could be used to track the precise sizes of general arrays. Of course the biggest challenge would be to have it always up-to-date, after all operations.
Bug report
A property marked as non-empty-array seems to be incorrectly identified as possibly empty. This is after explicitly checking if the array has at least two items before using unset() on it.
Code snippet that reproduces the problem
https://phpstan.org/r/8d223a39-663d-42ba-803d-1ae7644ded48
Expected output
No errors as the array should have at least one item left.
Did PHPStan help you today? Did it make you happy in any way?
Very happy with PHPStan! Prevented a lot of headaches so far.
The text was updated successfully, but these errors were encountered: