@@ -4601,6 +4601,67 @@ private function invalidateMethodsOnExpression(Expr $expressionToInvalidate): se
46014601 );
46024602 }
46034603
4604+ public function invalidateStaticMembers (string $ className ): self
4605+ {
4606+ if (!$ this ->reflectionProvider ->hasClass ($ className )) {
4607+ return $ this ;
4608+ }
4609+
4610+ $ classReflection = $ this ->reflectionProvider ->getClass ($ className );
4611+ $ classNamesToInvalidate = [strtolower ($ className )];
4612+ foreach ($ classReflection ->getParents () as $ parentClass ) {
4613+ $ classNamesToInvalidate [] = strtolower ($ parentClass ->getName ());
4614+ }
4615+
4616+ $ expressionTypes = $ this ->expressionTypes ;
4617+ $ nativeExpressionTypes = $ this ->nativeExpressionTypes ;
4618+ $ invalidated = false ;
4619+ $ nodeFinder = new NodeFinder ();
4620+ foreach ($ expressionTypes as $ exprString => $ exprTypeHolder ) {
4621+ $ expr = $ exprTypeHolder ->getExpr ();
4622+ $ found = $ nodeFinder ->findFirst ([$ expr ], static function (Node $ node ) use ($ classNamesToInvalidate ): bool {
4623+ if (!$ node instanceof Expr \StaticCall && !$ node instanceof Expr \StaticPropertyFetch) {
4624+ return false ;
4625+ }
4626+ if (!$ node ->class instanceof Name || !$ node ->class ->isFullyQualified ()) {
4627+ return false ;
4628+ }
4629+
4630+ return in_array ($ node ->class ->toLowerString (), $ classNamesToInvalidate , true );
4631+ });
4632+ if ($ found === null ) {
4633+ continue ;
4634+ }
4635+
4636+ unset($ expressionTypes [$ exprString ]);
4637+ unset($ nativeExpressionTypes [$ exprString ]);
4638+ $ invalidated = true ;
4639+ }
4640+
4641+ if (!$ invalidated ) {
4642+ return $ this ;
4643+ }
4644+
4645+ return $ this ->scopeFactory ->create (
4646+ $ this ->context ,
4647+ $ this ->isDeclareStrictTypes (),
4648+ $ this ->getFunction (),
4649+ $ this ->getNamespace (),
4650+ $ expressionTypes ,
4651+ $ nativeExpressionTypes ,
4652+ $ this ->conditionalExpressions ,
4653+ $ this ->inClosureBindScopeClasses ,
4654+ $ this ->anonymousFunctionReflection ,
4655+ $ this ->inFirstLevelStatement ,
4656+ $ this ->currentlyAssignedExpressions ,
4657+ $ this ->currentlyAllowedUndefinedExpressions ,
4658+ [],
4659+ $ this ->afterExtractCall ,
4660+ $ this ->parentScope ,
4661+ $ this ->nativeTypesPromoted ,
4662+ );
4663+ }
4664+
46044665 private function setExpressionCertainty (Expr $ expr , TrinaryLogic $ certainty ): self
46054666 {
46064667 if ($ this ->hasExpressionType ($ expr )->no ()) {
0 commit comments