Skip to content

foreach-by-reference does not keep list<T> property on reassignment #14083

@TimWolla

Description

@TimWolla

Bug report

When I iterate the values of a list<T> by reference and then reassign them, the array loses its list<T> property (even when it's impossible for the reassignment to change the structure of the array).

Code snippet that reproduces the problem

https://phpstan.org/r/94ed7e0d-6998-4347-b9cf-2f4b7847fa78

Expected output

I expected the dumps in example() and example2() to both be a list<T>.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions