-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Bug report
To reproduce the unexpected behavior, I made a simplified snippet that contains essentially a method that iterates over two indices in a single for loop. Originally it comes from a piece of code dealing with 2D arrays (a matrix/linear algebra library). This snippet triggers Parameter #1 of method expects int<0, max>, int given, although I added a set of checks to make sure that both indices are non-negative during the iteration.
Interestingly, the error disappeared if:
either we replace $columnIndex = 0; with e.g. $columnIndex = 1; (a value that is > 0) on Line 20 before the loop
or we replace $columnIndex = 0; with e.g. $columnIndex = 1; (a value that is > 0) on Line 27 inside the loop
Code snippet that reproduces the problem
https://phpstan.org/r/3471ec19-7077-4e36-a3d4-27d2dc643fa8
Expected output
It is expected that the parameter/variable remains non-negative-int.
Did PHPStan help you today? Did it make you happy in any way?
Excellent tools for checking/dealing with non-empty-list and non-negative-int in my linear algebra objects :)