2014-02-06 14:44:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpParser;
|
|
|
|
|
|
|
|
interface NodeTraverserInterface
|
|
|
|
{
|
2015-01-11 22:13:58 +01:00
|
|
|
/**
|
|
|
|
* If NodeVisitor::enterNode() returns DONT_TRAVERSE_CHILDREN, child nodes
|
|
|
|
* of the current node will not be traversed for any visitors.
|
|
|
|
*
|
|
|
|
* For subsequent visitors enterNode() will still be called on the current
|
|
|
|
* node and leaveNode() will also be invoked for the current node.
|
|
|
|
*/
|
|
|
|
const DONT_TRAVERSE_CHILDREN = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If NodeVisitor::leaveNode() returns REMOVE_NODE for a node that occurs
|
|
|
|
* in an array, it will be removed from the array.
|
|
|
|
*
|
|
|
|
* For subsequent visitors leaveNode() will still be invoked for the
|
|
|
|
* removed node.
|
|
|
|
*/
|
|
|
|
const REMOVE_NODE = false;
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
/**
|
|
|
|
* Adds a visitor.
|
|
|
|
*
|
|
|
|
* @param NodeVisitor $visitor Visitor to add
|
|
|
|
*/
|
|
|
|
function addVisitor(NodeVisitor $visitor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an added visitor.
|
|
|
|
*
|
|
|
|
* @param NodeVisitor $visitor
|
|
|
|
*/
|
|
|
|
function removeVisitor(NodeVisitor $visitor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Traverses an array of nodes using the registered visitors.
|
|
|
|
*
|
|
|
|
* @param Node[] $nodes Array of nodes
|
|
|
|
*
|
|
|
|
* @return Node[] Traversed array of nodes
|
|
|
|
*/
|
|
|
|
function traverse(array $nodes);
|
|
|
|
}
|
|
|
|
|