Skip to content

Commit

Permalink
Reduce use of PreviousConnectingVisitor::ATTRIBUTE_PREVIOUS to assist…
Browse files Browse the repository at this point in the history
… garbage collector
  • Loading branch information
staabm committed Aug 3, 2024
1 parent 4962951 commit 34a5343
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Ast/PreviousConnectingVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public function enterNode(Node $node)
$node->setAttribute(self::ATTRIBUTE_PARENT, $this->stack[\count($this->stack) - 1]);
}

if (null !== $this->previous && $this->previous->getAttribute(self::ATTRIBUTE_PARENT) === $node->getAttribute(self::ATTRIBUTE_PARENT)) {
$node->setAttribute(self::ATTRIBUTE_PREVIOUS, $this->previous);
if (!$node instanceof Node\FunctionLike && !$node instanceof Node\Stmt\ClassLike) {
if (null !== $this->previous && $this->previous->getAttribute(self::ATTRIBUTE_PARENT) === $node->getAttribute(self::ATTRIBUTE_PARENT)) {
$node->setAttribute(self::ATTRIBUTE_PREVIOUS, $this->previous);
}
}

$this->stack[] = $node;
Expand Down

0 comments on commit 34a5343

Please sign in to comment.