Skip to content

BenevolentUnionType with generics produce confusing errors #9732

@dktapps

Description

@dktapps

Bug report

When passing $GLOBALS to a function which accepts array<K of string, V>, K is not able to be inferred for some reason.

This started getting reported around 1.10.17 or so.

Code snippet that reproduces the problem

https://phpstan.org/r/63496f72-9ba6-4b08-b393-1442222c6e39

Expected output

The error on line 23 should not be reported, as the type of $GLOBALS is array<string, mixed>.

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