File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -847,18 +847,27 @@ public function walkSelectExpression($selectExpression)
847847 // the driver and PHP version.
848848 // Here we assume that the value may or may not be casted to
849849 // string by the driver.
850- $ type = TypeTraverser::map ($ type , static function (Type $ type , callable $ traverse ): Type {
850+ $ casted = false ;
851+ $ type = TypeTraverser::map ($ type , static function (Type $ type , callable $ traverse ) use (&$ casted ): Type {
851852 if ($ type instanceof UnionType || $ type instanceof IntersectionType) {
852853 return $ traverse ($ type );
853854 }
854855 if ($ type instanceof IntegerType || $ type instanceof FloatType) {
856+ $ casted = true ;
855857 return TypeCombinator::union ($ type ->toString (), $ type );
856858 }
857859 if ($ type instanceof BooleanType) {
860+ $ casted = true ;
858861 return TypeCombinator::union ($ type ->toInteger ()->toString (), $ type );
859862 }
860863 return $ traverse ($ type );
861864 });
865+
866+ // Since we made supposition about possibly casted values,
867+ // we can only provide a benevolent union.
868+ if ($ casted && $ type instanceof UnionType) {
869+ $ type = TypeUtils::toBenevolentUnion ($ type );
870+ }
862871 }
863872
864873 $ this ->addScalar ($ resultAlias , $ type );
You can’t perform that action at this time.
0 commit comments