Bug report
When iterating over a list<T> using a for loop from 0 until count($list) - 1:
for ($i = 0; $i < count($parts) - 1; $i++)
to handle all but the last element, PHPStan reports:
Offset int<0, max> might not exist on non-empty-list<string>.
It works correctly when iterating over all elements. Apparently PHPStan does not understand that the range stays within the bounds when performing the subtraction.
Code snippet that reproduces the problem
https://phpstan.org/r/0fc0f7ee-7d69-4c45-8ae9-e7204ad89da3
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
No response