Skip to content

Incorrect type inference about key repeated in multiple list items #2714

@vojtech-dobes

Description

@vojtech-dobes

Bug report

When you check the phpstan.org snippet below, you can see that type key of items in $list can contain 11 different possible strings. But when there is in_array call at the end, the incorrect error report betrays that PhpStan remembers only the unique direct assignment on line 15.

Call to function in_array() with arguments 'x', array('aaa', 'aaaa') and true will always evaluate to false.

Code snippet that reproduces the problem

https://phpstan.org/r/6960352d-cf6e-4607-b034-17abed9aaabc

Expected output

No complaint about in_array call always evaluating to false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions