Conversation
There was a problem hiding this comment.
Better comparison would be:
(new UnionType([new IntegerType(), new FloatType()]))->isSuperTypeOf($itemType)->yes()
There was a problem hiding this comment.
I don't think it makes sense to modify this.
There was a problem hiding this comment.
For an array of string, $itemType is a stringType.
So TypeCombinator::intersect($itemType, new UnionType([new IntegerType(), new FloatType()]) is nothing.
That's why the dynamic return type return new ConstantIntegerType(0).
The intersect seems to be the reason of the bug.
There was a problem hiding this comment.
But on the other hand, this intersect allows us to specify that when we only have array<int>, the result is going to be int.
There was a problem hiding this comment.
Isn't this handle by the previous check
if ($intUnionFloat->isSuperTypeOf($itemType)->yes()) {
return TypeCombinator::union(new ConstantIntegerType(0), $itemType);
}
?
e52a6e7 to
80eee3c
Compare
|
Awesome! 👍 |
No description provided.