function Traverser::addFunction
Adds a function that will be called for each node in the tree. The function will receive the current node as argument. The action that will be executed on the node by the traverser depends on the returned value of the function:
- a node: it will replace the node with the returned one
- a numeric value that is a combination of the constants defined in this class: it will execute the function related to each constant
- an array where the first element is a node and the second element is a numeric value that is a combination of the constants defined in this class: it will replace the node with the returned one and it will execute the function related to each constant (REMOVE_NODE will be ignored since it does not make any sense in this case)
- other: nothing
Parameters
callable $fn Function to add:
Return value
$this
File
-
vendor/
mck89/ peast/ lib/ Peast/ Traverser.php, line 95
Class
- Traverser
- Nodes traverser class
Namespace
PeastCode
public function addFunction(callable $fn) {
$this->functions[] = $fn;
return $this;
}