Bug report
Another related issue for #7000
Adding foreach make a wrong assumption on array type.
Code snippet that reproduces the problem
https://phpstan.org/r/f2f27d58-21fa-480c-a284-d70777f19926
The problem is described in test3. The addition of key in line 30 (compared to test1) and addition of foreach in line 32 (compared to test2) makes the type of $arr as array<'bar'|'baz'|'foo', array<string>> which I think is not correct.
Expected output
Addition of foreach should not change the array type.
Also, it should report on line 32 for non existing offset access.
Did PHPStan help you today? Did it make you happy in any way?
Yes! 😄
Bug report
Another related issue for #7000
Adding foreach make a wrong assumption on array type.
Code snippet that reproduces the problem
https://phpstan.org/r/f2f27d58-21fa-480c-a284-d70777f19926
The problem is described in
test3. The addition of key in line 30 (compared totest1) and addition of foreach in line 32 (compared totest2) makes the type of$arrasarray<'bar'|'baz'|'foo', array<string>>which I think is not correct.Expected output
Addition of foreach should not change the array type.
Also, it should report on line 32 for non existing offset access.
Did PHPStan help you today? Did it make you happy in any way?
Yes! 😄