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
{{ message }}
Repository navigation
Iterating over all except the last element of a list<T> reports that the offset might not exist #14234
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.
Activity
phpstan-bot commentedon Mar 6, 2026
Closed via merging phpstan/phpstan-src#5137
github-actions commentedon Apr 7, 2026
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.