Skip to content

Reassigning nested array values for in-out parameter does not keep list<T> property for inner array #14084

@TimWolla

Description

@TimWolla

Bug report

For array<array-key, list<T>> in-out parameter, I would like to replace the inner T, while maintaining the array and list structure. PHPStan behaves inconsistently.

Related #14083.

Code snippet that reproduces the problem

https://phpstan.org/r/c267f22d-26ab-4e5d-a67b-6a2b9e315054

Expected output

I expected example(), example2() and example3() to have consistently. Either PHPStan should understand that the “current key” is being reassigned (which means that the list property continues to hold) or it should not understand it. But it should not be dependent on nesting level.

The derived type for the “out parameter” should also be consistent with the dumped type at the end of the function (the latter of which is the expected type).

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