Skip to content

Cannot rule out types by checking for present key in array shape union #5128

@simPod

Description

@simPod

Bug report

Having array{a: string}|array{b: string}, checking for isset($arr['a']) should narrow the type to array{a: string}

Code snippet that reproduces the problem

https://phpstan.org/r/e3af8d32-e114-49bd-a4ef-469e46ab03e1

Expected output

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions