Skip to content

Commit

Permalink
Faster MutatingScope->getNodeKey()
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 17, 2024
1 parent b66058f commit 9c81a80
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,15 +710,16 @@ private function getNodeKey(Expr $node): string
{
$key = $this->exprPrinter->printExpr($node);

$attributes = $node->getAttributes();
if (
$node instanceof Node\FunctionLike
&& $node->hasAttribute(ArrayMapArgVisitor::ATTRIBUTE_NAME)
&& $node->hasAttribute('startFilePos')
&& (($attributes[ArrayMapArgVisitor::ATTRIBUTE_NAME] ?? null) !== null)
&& (($attributes['startFilePos'] ?? null) !== null)
) {
$key .= '/*' . $node->getAttribute('startFilePos') . '*/';
$key .= '/*' . $attributes['startFilePos'] . '*/';
}

if ($node->getAttribute(self::KEEP_VOID_ATTRIBUTE_NAME) === true) {
if (($attributes[self::KEEP_VOID_ATTRIBUTE_NAME] ?? null) === true) {
$key .= '/*' . self::KEEP_VOID_ATTRIBUTE_NAME . '*/';
}

Expand Down

0 comments on commit 9c81a80

Please sign in to comment.