Skip to content

Commit

Permalink
Remove unnecessary Node return value from traverseNode()
Browse files Browse the repository at this point in the history
The node always stays the same: We may only change subnodes.
  • Loading branch information
nikic committed May 28, 2023
1 parent 5b65f9f commit 53f6717
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/PhpParser/NodeTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ public function traverse(array $nodes): array {
* Recursively traverse a node.
*
* @param Node $node Node to traverse.
*
* @return Node Result of traversal (may be original node or new one)
*/
protected function traverseNode(Node $node): Node {
protected function traverseNode(Node $node): void {
foreach ($node->getSubNodeNames() as $name) {
$subNode =& $node->$name;

Expand Down Expand Up @@ -128,7 +126,7 @@ protected function traverseNode(Node $node): Node {
}

if ($traverseChildren) {
$subNode = $this->traverseNode($subNode);
$this->traverseNode($subNode);
if ($this->stopTraversal) {
break;
}
Expand Down Expand Up @@ -162,8 +160,6 @@ protected function traverseNode(Node $node): Node {
}
}
}

return $node;
}

/**
Expand Down Expand Up @@ -213,7 +209,7 @@ protected function traverseArray(array $nodes): array {
}

if ($traverseChildren) {
$node = $this->traverseNode($node);
$this->traverseNode($node);
if ($this->stopTraversal) {
break;
}
Expand Down

0 comments on commit 53f6717

Please sign in to comment.