Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generic union types not resolved correctly #3894

@nmokkenstorm

Description

@nmokkenstorm

Bug report

I'm working on a project that does some magic with dependency injection containers, and I ran into the following problem:

Given I have an array with type array<class-string<T>, class-string<T>>, and a method that does a lookup in that map but returns the original key if it wasn't found, I get a compound/union (?) type class-string<T> | class-string<T> instead of class-string<T>. I'd expect those to resolve to the same thing, but it does not. This doesn't occur when not using generic class strings but regular strings, so I suspect there's something in the generic resolution that trips up.

Code snippet that reproduces the problem

https://phpstan.org/r/c9268355-731a-44cc-a790-815994a3bd05

Expected output

I expect class-string | class-string to equal class-string as a return type

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions