-
-
Notifications
You must be signed in to change notification settings - Fork 947
PHPStan loses type resolution when creating a union of int and numeric-string #10092
Copy link
Copy link
Closed
Description
Bug report
When using azjezz/psl, the Psl\Type\union() is used to create a union type out of two (or more) Psl\Type\TypeInterface<T> instances.
Roughly: function union(TypeInterface<T>, TypeInterface<U>): TypeInterface<T|U>.
This works fine, but PHPStan seems to have trouble in computing union types for somehow close types like int and numeric-string, leading to inference of int|string rather than int|numeric-string.
Similarly, it cannot compute 0 and positive-int, leading to int being inferred, rather than 0|int<1, max> or int<0, max>.
Code snippet that reproduces the problem
Expected output
union(int, numeric-string)should becomeint|numeric-string(currently producesint|string)union(0, int<1, max>)should become0|int<1, max>(currently producesint)
Did PHPStan help you today? Did it make you happy in any way?
Thanks for your continued work on this: makes PHP bearable :-)
Reactions are currently unavailable