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
For some downstream code, I am constraining a value to be positive-int|0. In the upstream code, this comes from an array for which the only operations are appending a value ($array[] = $value) and removing a value (unset($array[$index])).
However PHPStan doesn't appear to like that very much as it infers int for the index instead of positive-int|0, which is what it is in this specific case where the index is never explicitly set.
Bug report
For some downstream code, I am constraining a value to be
positive-int|0
. In the upstream code, this comes from an array for which the only operations are appending a value ($array[] = $value
) and removing a value (unset($array[$index])
).However PHPStan doesn't appear to like that very much as it infers
int
for the index instead ofpositive-int|0
, which is what it is in this specific case where the index is never explicitly set.Code snippet that reproduces the problem
https://phpstan.org/r/b27d9595-2fb0-4e53-bae6-66728a05a53c
Expected output
No error reported.
Did PHPStan help you today? Did it make you happy in any way?
First PHPStan issue I believe so it works :)
The text was updated successfully, but these errors were encountered: