@@ -204,6 +204,7 @@ public function __construct(
204204 private PropertyReflectionFinder $ propertyReflectionFinder ,
205205 private Parser $ parser ,
206206 private NodeScopeResolver $ nodeScopeResolver ,
207+ private RicherScopeGetTypeHelper $ richerScopeGetTypeHelper ,
207208 private ConstantResolver $ constantResolver ,
208209 private ScopeContext $ context ,
209210 private PhpVersion $ phpVersion ,
@@ -924,46 +925,11 @@ private function resolveType(string $exprString, Expr $node): Type
924925 }
925926
926927 if ($ node instanceof Expr \BinaryOp \Identical) {
927- if (
928- $ node ->left instanceof Variable
929- && is_string ($ node ->left ->name )
930- && $ node ->right instanceof Variable
931- && is_string ($ node ->right ->name )
932- && $ node ->left ->name === $ node ->right ->name
933- ) {
934- return new ConstantBooleanType (true );
935- }
936-
937- $ leftType = $ this ->getType ($ node ->left );
938- $ rightType = $ this ->getType ($ node ->right );
939-
940- if (
941- (
942- $ node ->left instanceof Node \Expr \PropertyFetch
943- || $ node ->left instanceof Node \Expr \StaticPropertyFetch
944- )
945- && $ rightType ->isNull ()->yes ()
946- && !$ this ->hasPropertyNativeType ($ node ->left )
947- ) {
948- return new BooleanType ();
949- }
950-
951- if (
952- (
953- $ node ->right instanceof Node \Expr \PropertyFetch
954- || $ node ->right instanceof Node \Expr \StaticPropertyFetch
955- )
956- && $ leftType ->isNull ()->yes ()
957- && !$ this ->hasPropertyNativeType ($ node ->right )
958- ) {
959- return new BooleanType ();
960- }
961-
962- return $ this ->initializerExprTypeResolver ->resolveIdenticalType ($ leftType , $ rightType )->type ;
928+ return $ this ->richerScopeGetTypeHelper ->getIdenticalResult ($ this , $ node )->type ;
963929 }
964930
965931 if ($ node instanceof Expr \BinaryOp \NotIdentical) {
966- return $ this ->getType ( new Expr \ BooleanNot ( new BinaryOp \ Identical ( $ node -> left , $ node-> right ))) ;
932+ return $ this ->richerScopeGetTypeHelper -> getNotIdenticalResult ( $ this , $ node)-> type ;
967933 }
968934
969935 if ($ node instanceof Expr \Instanceof_) {
@@ -2654,7 +2620,7 @@ private function promoteNativeTypes(): self
26542620 /**
26552621 * @param Node\Expr\PropertyFetch|Node\Expr\StaticPropertyFetch $propertyFetch
26562622 */
2657- private function hasPropertyNativeType ($ propertyFetch ): bool
2623+ public function hasPropertyNativeType ($ propertyFetch ): bool
26582624 {
26592625 $ propertyReflection = $ this ->propertyReflectionFinder ->findPropertyReflectionFromNode ($ propertyFetch , $ this );
26602626 if ($ propertyReflection === null ) {
0 commit comments