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 @@ -849,18 +849,27 @@ public function walkSelectExpression($selectExpression): string
849849 // the driver and PHP version.
850850 // Here we assume that the value may or may not be casted to
851851 // string by the driver.
852- $ type = TypeTraverser::map ($ type , static function (Type $ type , callable $ traverse ): Type {
852+ $ casted = false ;
853+ $ type = TypeTraverser::map ($ type , static function (Type $ type , callable $ traverse ) use (&$ casted ): Type {
853854 if ($ type instanceof UnionType || $ type instanceof IntersectionType) {
854855 return $ traverse ($ type );
855856 }
856857 if ($ type instanceof IntegerType || $ type instanceof FloatType) {
858+ $ casted = true ;
857859 return TypeCombinator::union ($ type ->toString (), $ type );
858860 }
859861 if ($ type instanceof BooleanType) {
862+ $ casted = true ;
860863 return TypeCombinator::union ($ type ->toInteger ()->toString (), $ type );
861864 }
862865 return $ traverse ($ type );
863866 });
867+
868+ // Since we made supposition about possibly casted values,
869+ // we can only provide a benevolent union.
870+ if ($ casted && $ type instanceof UnionType) {
871+ $ type = TypeUtils::toBenevolentUnion ($ type );
872+ }
864873 }
865874
866875 $ this ->addScalar ($ resultAlias , $ type );
You can’t perform that action at this time.
0 commit comments