@@ -4112,6 +4112,10 @@ public function exitExpressionAssign(Expr $expr): self
41124112 /** @api */
41134113 public function isInExpressionAssign (Expr $ expr ): bool
41144114 {
4115+ if (count ($ this ->currentlyAssignedExpressions ) === 0 ) {
4116+ return false ;
4117+ }
4118+
41154119 $ exprString = $ this ->getNodeKey ($ expr );
41164120 return array_key_exists ($ exprString , $ this ->currentlyAssignedExpressions );
41174121 }
@@ -4185,6 +4189,9 @@ public function unsetAllowedUndefinedExpression(Expr $expr): self
41854189 /** @api */
41864190 public function isUndefinedExpressionAllowed (Expr $ expr ): bool
41874191 {
4192+ if (count ($ this ->currentlyAllowedUndefinedExpressions ) === 0 ) {
4193+ return false ;
4194+ }
41884195 $ exprString = $ this ->getNodeKey ($ expr );
41894196 return array_key_exists ($ exprString , $ this ->currentlyAllowedUndefinedExpressions );
41904197 }
@@ -4480,13 +4487,14 @@ public function invalidateExpression(Expr $expressionToInvalidate, bool $require
44804487
44814488 private function shouldInvalidateExpression (string $ exprStringToInvalidate , Expr $ exprToInvalidate , Expr $ expr , bool $ requireMoreCharacters = false ): bool
44824489 {
4483- if ($ requireMoreCharacters && $ exprStringToInvalidate === $ this ->getNodeKey ($ expr )) {
4490+ $ exprString = $ this ->getNodeKey ($ expr );
4491+ if ($ requireMoreCharacters && $ exprStringToInvalidate === $ exprString ) {
44844492 return false ;
44854493 }
44864494
44874495 // Variables will not contain traversable expressions. skip the NodeFinder overhead
44884496 if ($ expr instanceof Variable && is_string ($ expr ->name ) && !$ requireMoreCharacters ) {
4489- return $ exprStringToInvalidate === $ this -> getNodeKey ( $ expr ) ;
4497+ return $ exprStringToInvalidate === $ exprString ;
44904498 }
44914499
44924500 $ nodeFinder = new NodeFinder ();
0 commit comments