-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Bug report
If I have a class with an array property declared as list<T> or non-empty-list<T> and if I try to assign a value to an existing element with a non-zero index in that list, e.g. $array[1] = 1, then I get an assign.propertyType error:
non-empty-array<int<0, max>, int> might not be a list.
If the assignment is done to the zero-index element, e.g. $array[0] = 1, then it does not trigger an error. Adding a limit-checking condition, e.g.
if ($index < 0 || $index >= count($array)) return;
does not help.
Code snippet that reproduces the problem
https://phpstan.org/r/a86e92a1-bb03-472f-bce4-f103ddbaf457
Expected output
No conversion from list to array is expected.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable