@@ -877,9 +877,9 @@ public function getType(Expr $node): Type
877877 $ key = $ this ->getNodeKey ($ node );
878878
879879 if (!array_key_exists ($ key , $ this ->resolvedTypes )) {
880- $ this ->resolvedTypes [$ key ] = TypeUtils::resolveLateResolvableTypes ($ this ->resolveType ($ key , $ node ));
880+ $ this ->resolvedTypes [$ key ] = ExpressionTypeHolder:: createYes ( $ node , TypeUtils::resolveLateResolvableTypes ($ this ->resolveType ($ key , $ node) ));
881881 }
882- return $ this ->resolvedTypes [$ key ];
882+ return $ this ->resolvedTypes [$ key ]-> getType () ;
883883 }
884884
885885 public function getScopeType (Expr $ expr ): Type
@@ -4357,7 +4357,7 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
43574357 $ this ->parentScope ,
43584358 $ this ->nativeTypesPromoted ,
43594359 );
4360- $ scope ->resolvedTypes = $ this ->preserveResolvedTypes ([$ exprString ]);
4360+ $ scope ->resolvedTypes = $ this ->preserveResolvedTypes ([$ exprString => $ expr ]);
43614361
43624362 if ($ expr instanceof AlwaysRememberedExpr) {
43634363 return $ scope ->specifyExpressionType ($ expr ->expr , $ type , $ nativeType , $ certainty );
@@ -4407,19 +4407,23 @@ public function assignInitializedProperty(Type $fetchedOnType, string $propertyN
44074407 }
44084408
44094409 /**
4410- * @param array<string> $changedExpressions
4410+ * @param array<string, Expr > $changedExpressions
44114411 *
4412- * @return array<string, Type >
4412+ * @return array<string, ExpressionTypeHolder >
44134413 */
44144414 private function preserveResolvedTypes (array $ changedExpressions ): array
44154415 {
44164416 $ preservedTypes = $ this ->resolvedTypes ;
4417- foreach ($ preservedTypes as $ exprStringToInvalidate => $ resolvedType ) {
4418- foreach ($ changedExpressions as $ exprString ) {
4419- if (str_contains ($ exprStringToInvalidate , $ exprString )) {
4420- unset ($ preservedTypes [$ exprStringToInvalidate ]);
4421- continue 2 ;
4417+ foreach ($ preservedTypes as $ exprString => $ exprTypeHolder ) {
4418+ $ exprExpr = $ exprTypeHolder ->getExpr ();
4419+
4420+ foreach ($ changedExpressions as $ exprStringToInvalidate => $ expressionToInvalidate ) {
4421+ if (!$ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ exprExpr , true )) {
4422+ continue ;
44224423 }
4424+
4425+ unset($ preservedTypes [$ exprString ]);
4426+ continue 2 ;
44234427 }
44244428 }
44254429
0 commit comments