Skip to content

Commit 4ca2eb0

Browse files
committed
Fixing node traverser
1 parent 97698eb commit 4ca2eb0

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ php:
44
- 5.6
55
- 7.0
66
- 7.1
7+
- 7.2
78

89
env:
910
matrix:

src/SQLParser/Query/Union.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,28 @@ public function walk(VisitorInterface $visitor)
9696
$node = $result;
9797
}
9898
if ($result !== NodeTraverser::DONT_TRAVERSE_CHILDREN) {
99-
$this->walkChildren($this->columns, $visitor);
100-
$this->walkChildren($this->from, $visitor);
101-
$this->walkChildren($this->where, $visitor);
102-
$this->walkChildren($this->group, $visitor);
103-
$this->walkChildren($this->having, $visitor);
104-
$this->walkChildren($this->order, $visitor);
99+
$this->walkChildren($this->selects, $visitor);
105100
}
106101

107102
return $visitor->leaveNode($node);
108103
}
109104

110-
private function walkChildren(&$children, VisitorInterface $visitor)
105+
/**
106+
* @param Select[] $children
107+
* @param VisitorInterface $visitor
108+
*/
109+
private function walkChildren(array &$children, VisitorInterface $visitor)
111110
{
112111
if ($children) {
113-
if (is_array($children)) {
114-
foreach ($children as $key => $operand) {
115-
if ($operand) {
116-
$result2 = $operand->walk($visitor);
117-
if ($result2 === NodeTraverser::REMOVE_NODE) {
118-
unset($children[$key]);
119-
} elseif ($result2 instanceof NodeInterface) {
120-
$children[$key] = $result2;
121-
}
112+
foreach ($children as $key => $operand) {
113+
if ($operand) {
114+
$result2 = $operand->walk($visitor);
115+
if ($result2 === NodeTraverser::REMOVE_NODE) {
116+
unset($children[$key]);
117+
} elseif ($result2 instanceof NodeInterface) {
118+
$children[$key] = $result2;
122119
}
123120
}
124-
} else {
125-
$result2 = $children->walk($visitor);
126-
if ($result2 === NodeTraverser::REMOVE_NODE) {
127-
$children = null;
128-
} elseif ($result2 instanceof NodeInterface) {
129-
$children = $result2;
130-
}
131121
}
132122
}
133123
}

0 commit comments

Comments
 (0)