🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Wrong array_flip inference #14656

Description

@VincentLanglet

Bug report

In https://phpstan.org/r/4f185506-7a6f-45dc-8082-d717cb448b7d

The inference non-empty-array{a?: 2, b?: 2, c?: 2} is wrong and should be non-empty-array{a?: 0|1|2, b?: 0|1|2, c?: 0|1|2}

Seems like the last key overrides every possible values even if it's an unionType (and therefor cannot override multiple keys at the same time).

Code snippet that reproduces the problem

https://phpstan.org/r/4f185506-7a6f-45dc-8082-d717cb448b7d

Expected output

non-empty-array{a?: 0|1|2, b?: 0|1|2, c?: 0|1|2}

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