src/Zicht/Tool/Container/Traverser.php
public function addVisitor($callable, $condition, $when = self::BEFORE)
    {
        $this->visitors[] = array($when, $condition, $callable);

        return $this;
    }
public function addVisitor($callable, $condition, $when = self::BEFORE)
    {
        $this->visitors[] = array($when, $condition, $callable);

        return $this;
    }
public function addVisitor ( $ callable , $ condition , $ when = self :: BEFORE ) { $ this -> visitors [ ] = array ( $ when , $ condition , $ callable ) ; return $ this ; }
Add a visitor to the traverser. The node being visited is passed to the second callback to determine whether
the first callback should be called with the node. The arguments passed to both callbacks are the current node
and the path to the node. The result of the first callback is used to replace the node in the tree.

Example:
<code>
$traverser->addVisitor(
function($path, $node) {
$node['i was visited'] = true;
return $node;
},
function($path, $node) {
return count($path) == 3 && $path[0] == 'foo' && $path[2] == 'bar';
}
);

$traverser->traverse(
array(
'foo' => array(
array(
'bar' => array('i should be visited' => true),
'baz' => array('i should not be visited' => true)
)
)
)
);
</code>

@param callable $callable
@param callable $condition
@param int $when
@return self
Add a visitor to the traverser . The node being visited is passed to the second callback to determine whether the first callback should be called with the node . The arguments passed to both callbacks are the current node and the path to the node . The result of the first callback is used to replace the node in the tree .