diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 8bdf7894e6..3a9ef63cc1 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -917,8 +917,12 @@ public function getScopeNativeType(Expr $expr): Type private function getNodeKey(Expr $node): string { - $key = $this->exprPrinter->printExpr($node); + // perf optimize for the most common path + if ($node instanceof Variable && !$node->name instanceof Expr) { + return '$' . $node->name; + } + $key = $this->exprPrinter->printExpr($node); $attributes = $node->getAttributes(); if ( $node instanceof Node\FunctionLike