function Traverser::execFunctions
Executes all functions on the given node and, if required, starts traversing its children. The returned value is an array where the first value is the node or null if it has been removed and the second value is a boolean indicating if the traverser must continue the traversing or not
Parameters
Syntax\Node\Node $node Node:
Syntax\Node\Node|null $parent Parent node:
Return value
array
2 calls to Traverser::execFunctions()
- Traverser::traverse in vendor/
mck89/ peast/ lib/ Peast/ Traverser.php - Starts the traversing
- Traverser::traverseChildren in vendor/
mck89/ peast/ lib/ Peast/ Traverser.php - Traverses node children. It returns a boolean indicating if the traversing must continue or not
File
-
vendor/
mck89/ peast/ lib/ Peast/ Traverser.php, line 129
Class
- Traverser
- Nodes traverser class
Namespace
PeastCode
protected function execFunctions($node, $parent = null) {
$traverseChildren = true;
$continueTraversing = true;
foreach ($this->functions as $fn) {
$ret = $this->passParentNode ? $fn($node, $parent) : $fn($node);
if ($ret) {
if (is_array($ret) && $ret[0] instanceof Syntax\Node\Node) {
$node = $ret[0];
if (isset($ret[1]) && is_numeric($ret[1])) {
if ($ret[1] & self::DONT_TRAVERSE_CHILD_NODES) {
$traverseChildren = false;
}
if ($ret[1] & self::STOP_TRAVERSING) {
$continueTraversing = false;
}
}
}
elseif ($ret instanceof Syntax\Node\Node) {
$node = $ret;
}
elseif (is_numeric($ret)) {
if ($ret & self::DONT_TRAVERSE_CHILD_NODES) {
$traverseChildren = false;
}
if ($ret & self::STOP_TRAVERSING) {
$continueTraversing = false;
}
if ($ret & self::REMOVE_NODE) {
$node = null;
$traverseChildren = false;
break;
}
}
}
}
if ($traverseChildren && $continueTraversing) {
$continueTraversing = $this->traverseChildren($node);
}
return array(
$node,
$continueTraversing,
);
}