Skip to content

Array shape intersection incorrect when a value is a union of constants #11234

@lkrms

Description

@lkrms

Bug report

The examples below are derived from code where this issue surfaced for me and may be more complicated than necessary.

This works because the array shapes in question have an int at index 0: https://phpstan.org/r/b065b44f-5f92-4462-a5ca-b5d312280772

But when the value at index 0 is 0|1|2|3, int leaks into the resolved type of the adjacent value:

Code snippet that reproduces the problem

https://phpstan.org/r/edd0a6b2-b1f7-452a-88c2-8a9342e91781

Expected output

The intersection of array{0|1|2|3, int|Payload|string|null} and array{0|1|2|3, Payload} should be array{0|1|2|3, Payload}, not array{0|1|2|3, int|Payload}

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