@@ -986,6 +986,12 @@ public function getBitwiseAndType(Expr $left, Expr $right, callable $getTypeCall
986986 $ leftType = $ getTypeCallback ($ left );
987987 $ rightType = $ getTypeCallback ($ right );
988988
989+ $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
990+ ->callOperatorTypeSpecifyingExtensions (new BinaryOp \BitwiseAnd ($ left , $ right ), $ leftType , $ rightType );
991+ if ($ specifiedTypes !== null ) {
992+ return $ specifiedTypes ;
993+ }
994+
989995 return $ this ->getBitwiseAndTypeFromTypes ($ leftType , $ rightType );
990996 }
991997
@@ -1044,6 +1050,12 @@ public function getBitwiseOrType(Expr $left, Expr $right, callable $getTypeCallb
10441050 $ leftType = $ getTypeCallback ($ left );
10451051 $ rightType = $ getTypeCallback ($ right );
10461052
1053+ $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
1054+ ->callOperatorTypeSpecifyingExtensions (new BinaryOp \BitwiseOr ($ left , $ right ), $ leftType , $ rightType );
1055+ if ($ specifiedTypes !== null ) {
1056+ return $ specifiedTypes ;
1057+ }
1058+
10471059 return $ this ->getBitwiseOrTypeFromTypes ($ leftType , $ rightType );
10481060 }
10491061
@@ -1092,6 +1104,12 @@ public function getBitwiseXorType(Expr $left, Expr $right, callable $getTypeCall
10921104 $ leftType = $ getTypeCallback ($ left );
10931105 $ rightType = $ getTypeCallback ($ right );
10941106
1107+ $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
1108+ ->callOperatorTypeSpecifyingExtensions (new BinaryOp \BitwiseXor ($ left , $ right ), $ leftType , $ rightType );
1109+ if ($ specifiedTypes !== null ) {
1110+ return $ specifiedTypes ;
1111+ }
1112+
10951113 return $ this ->getBitwiseXorTypeFromTypes ($ leftType , $ rightType );
10961114 }
10971115
@@ -1756,6 +1774,12 @@ public function getShiftLeftType(Expr $left, Expr $right, callable $getTypeCallb
17561774 $ leftType = $ getTypeCallback ($ left );
17571775 $ rightType = $ getTypeCallback ($ right );
17581776
1777+ $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
1778+ ->callOperatorTypeSpecifyingExtensions (new BinaryOp \ShiftLeft ($ left , $ right ), $ leftType , $ rightType );
1779+ if ($ specifiedTypes !== null ) {
1780+ return $ specifiedTypes ;
1781+ }
1782+
17591783 return $ this ->getShiftLeftTypeFromTypes ($ left , $ right , $ leftType , $ rightType );
17601784 }
17611785
@@ -1820,6 +1844,12 @@ public function getShiftRightType(Expr $left, Expr $right, callable $getTypeCall
18201844 $ leftType = $ getTypeCallback ($ left );
18211845 $ rightType = $ getTypeCallback ($ right );
18221846
1847+ $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
1848+ ->callOperatorTypeSpecifyingExtensions (new BinaryOp \ShiftRight ($ left , $ right ), $ leftType , $ rightType );
1849+ if ($ specifiedTypes !== null ) {
1850+ return $ specifiedTypes ;
1851+ }
1852+
18231853 return $ this ->getShiftRightTypeFromTypes ($ left , $ right , $ leftType , $ rightType );
18241854 }
18251855
@@ -2034,6 +2064,12 @@ private function resolveConstantArrayTypeComparison(ConstantArrayType $leftType,
20342064 */
20352065 private function resolveCommonMath (Expr \BinaryOp $ expr , Type $ leftType , Type $ rightType ): Type
20362066 {
2067+ $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
2068+ ->callOperatorTypeSpecifyingExtensions ($ expr , $ leftType , $ rightType );
2069+ if ($ specifiedTypes !== null ) {
2070+ return $ specifiedTypes ;
2071+ }
2072+
20372073 $ types = TypeCombinator::union ($ leftType , $ rightType );
20382074 $ leftNumberType = $ leftType ->toNumber ();
20392075 $ rightNumberType = $ rightType ->toNumber ();
@@ -2073,12 +2109,6 @@ private function resolveCommonMath(Expr\BinaryOp $expr, Type $leftType, Type $ri
20732109 }
20742110 }
20752111
2076- $ specifiedTypes = $ this ->operatorTypeSpecifyingExtensionRegistryProvider ->getRegistry ()
2077- ->callOperatorTypeSpecifyingExtensions ($ expr , $ leftType , $ rightType );
2078- if ($ specifiedTypes !== null ) {
2079- return $ specifiedTypes ;
2080- }
2081-
20822112 if (
20832113 $ leftType ->isArray ()->yes ()
20842114 || $ rightType ->isArray ()->yes ()
0 commit comments