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
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 (?) typeclass-string<T> | class-string<T>instead ofclass-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