@@ -2857,7 +2857,7 @@ public function assignInitializedProperty(Type $fetchedOnType, string $propertyN
28572857 return $ this ->assignExpression (new PropertyInitializationExpr ($ propertyName ), new MixedType (), new MixedType ());
28582858 }
28592859
2860- public function invalidateExpression (Expr $ expressionToInvalidate , bool $ requireMoreCharacters = false , ?ClassReflection $ invalidatingClass = null ): self
2860+ public function invalidateExpression (Expr $ expressionToInvalidate , bool $ requireMoreCharacters = false , ?ClassReflection $ invalidatingClass = null , bool $ fromStaticCall = false ): self
28612861 {
28622862 $ expressionTypes = $ this ->expressionTypes ;
28632863 $ nativeExpressionTypes = $ this ->nativeExpressionTypes ;
@@ -2866,7 +2866,7 @@ public function invalidateExpression(Expr $expressionToInvalidate, bool $require
28662866
28672867 foreach ($ expressionTypes as $ exprString => $ exprTypeHolder ) {
28682868 $ exprExpr = $ exprTypeHolder ->getExpr ();
2869- if (!$ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ exprExpr , $ exprString , $ requireMoreCharacters , $ invalidatingClass )) {
2869+ if (!$ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ exprExpr , $ exprString , $ requireMoreCharacters , $ invalidatingClass, $ fromStaticCall )) {
28702870 continue ;
28712871 }
28722872
@@ -2881,7 +2881,7 @@ public function invalidateExpression(Expr $expressionToInvalidate, bool $require
28812881 continue ;
28822882 }
28832883 $ firstExpr = $ holders [array_key_first ($ holders )]->getTypeHolder ()->getExpr ();
2884- if ($ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ firstExpr , $ this ->getNodeKey ($ firstExpr ), false , $ invalidatingClass )) {
2884+ if ($ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ firstExpr , $ this ->getNodeKey ($ firstExpr ), false , $ invalidatingClass, $ fromStaticCall )) {
28852885 $ invalidated = true ;
28862886 continue ;
28872887 }
@@ -2890,7 +2890,7 @@ public function invalidateExpression(Expr $expressionToInvalidate, bool $require
28902890 $ shouldKeep = true ;
28912891 $ conditionalTypeHolders = $ holder ->getConditionExpressionTypeHolders ();
28922892 foreach ($ conditionalTypeHolders as $ conditionalTypeHolderExprString => $ conditionalTypeHolder ) {
2893- if ($ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ conditionalTypeHolder ->getExpr (), $ conditionalTypeHolderExprString , false , $ invalidatingClass )) {
2893+ if ($ this ->shouldInvalidateExpression ($ exprStringToInvalidate , $ expressionToInvalidate , $ conditionalTypeHolder ->getExpr (), $ conditionalTypeHolderExprString , false , $ invalidatingClass, $ fromStaticCall )) {
28942894 $ invalidated = true ;
28952895 $ shouldKeep = false ;
28962896 break ;
@@ -2944,7 +2944,7 @@ private function getIntertwinedRefRootVariableName(Expr $expr): ?string
29442944 return null ;
29452945 }
29462946
2947- private function shouldInvalidateExpression (string $ exprStringToInvalidate , Expr $ exprToInvalidate , Expr $ expr , string $ exprString , bool $ requireMoreCharacters = false , ?ClassReflection $ invalidatingClass = null ): bool
2947+ private function shouldInvalidateExpression (string $ exprStringToInvalidate , Expr $ exprToInvalidate , Expr $ expr , string $ exprString , bool $ requireMoreCharacters = false , ?ClassReflection $ invalidatingClass = null , bool $ fromStaticCall = false ): bool
29482948 {
29492949 if (
29502950 $ expr instanceof IntertwinedVariableByReferenceWithExpr
@@ -3011,6 +3011,13 @@ private function shouldInvalidateExpression(string $exprStringToInvalidate, Expr
30113011 return false ;
30123012 }
30133013
3014+ if (
3015+ $ fromStaticCall
3016+ && $ this ->isThisInstancePropertyAccessChain ($ expr )
3017+ ) {
3018+ return false ;
3019+ }
3020+
30143021 return true ;
30153022 }
30163023
@@ -3030,6 +3037,21 @@ private function isPrivatePropertyOfDifferentClass(Expr $expr, ClassReflection $
30303037 return false ;
30313038 }
30323039
3040+ private function isThisInstancePropertyAccessChain (Expr $ expr ): bool
3041+ {
3042+ if ($ expr instanceof Variable && is_string ($ expr ->name ) && $ expr ->name === 'this ' ) {
3043+ return true ;
3044+ }
3045+ if ($ expr instanceof PropertyFetch) {
3046+ return $ this ->isThisInstancePropertyAccessChain ($ expr ->var );
3047+ }
3048+ if ($ expr instanceof Expr \ArrayDimFetch) {
3049+ return $ this ->isThisInstancePropertyAccessChain ($ expr ->var );
3050+ }
3051+
3052+ return false ;
3053+ }
3054+
30333055 private function invalidateMethodsOnExpression (Expr $ expressionToInvalidate ): self
30343056 {
30353057 $ exprStringToInvalidate = null ;
0 commit comments