Bug report
When foreach's iterable variable is overwritten in the loop body, it no longer understands the element type.
Possibly related to #4907. Sample code:
/**
* @param list<int> $array
*/
function foo(array $array): void {
foreach ($array as $element) {
PHPStan\dumpType($element);
$array = null;
}
}
https://phpstan.org/r/28c10452-0fd4-49bf-9f5e-e292cd31b586
Actual output
Expected output
$element is int.
The loop correctly loops over all elements of $array. (However, note that it doesn't do so when using &$element.)