Skip to content

Commit

Permalink
Faster Scope->shouldInvalidateExpression()
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Dec 21, 2022
1 parent 7c68a12 commit dd3b4b4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Analyser/MutatingScope.php
Expand Up @@ -3500,6 +3500,11 @@ private function shouldInvalidateExpression(string $exprStringToInvalidate, Expr
return false;
}

// Variables will not contain traversable expression. skip the NodeFinder overhead
if ($expr instanceof Variable) {
return $exprStringToInvalidate === $this->getNodeKey($expr);
}

$nodeFinder = new NodeFinder();
$expressionToInvalidateClass = get_class($exprToInvalidate);
$found = $nodeFinder->findFirst([$expr], function (Node $node) use ($expressionToInvalidateClass, $exprStringToInvalidate): bool {
Expand Down

0 comments on commit dd3b4b4

Please sign in to comment.