mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 07:08:14 +01:00
Avoid by-reference iteration in NodeTraverser
No need to create reference wrappers around every element in the array.
This commit is contained in:
parent
b4183c2b09
commit
de84f76766
@ -175,7 +175,7 @@ class NodeTraverser implements NodeTraverserInterface {
|
||||
protected function traverseArray(array $nodes): array {
|
||||
$doNodes = [];
|
||||
|
||||
foreach ($nodes as $i => &$node) {
|
||||
foreach ($nodes as $i => $node) {
|
||||
if ($node instanceof Node) {
|
||||
$traverseChildren = true;
|
||||
$visitorIndex = -1;
|
||||
@ -185,7 +185,7 @@ class NodeTraverser implements NodeTraverserInterface {
|
||||
if (null !== $return) {
|
||||
if ($return instanceof Node) {
|
||||
$this->ensureReplacementReasonable($node, $return);
|
||||
$node = $return;
|
||||
$nodes[$i] = $node = $return;
|
||||
} elseif (\is_array($return)) {
|
||||
$doNodes[] = [$i, $return];
|
||||
continue 2;
|
||||
@ -225,7 +225,7 @@ class NodeTraverser implements NodeTraverserInterface {
|
||||
if (null !== $return) {
|
||||
if ($return instanceof Node) {
|
||||
$this->ensureReplacementReasonable($node, $return);
|
||||
$node = $return;
|
||||
$nodes[$i] = $node = $return;
|
||||
} elseif (\is_array($return)) {
|
||||
$doNodes[] = [$i, $return];
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user