Chris@13
|
1 <?php declare(strict_types=1);
|
Chris@0
|
2
|
Chris@0
|
3 namespace PhpParser;
|
Chris@0
|
4
|
Chris@0
|
5 interface NodeVisitor
|
Chris@0
|
6 {
|
Chris@0
|
7 /**
|
Chris@0
|
8 * Called once before traversal.
|
Chris@0
|
9 *
|
Chris@0
|
10 * Return value semantics:
|
Chris@0
|
11 * * null: $nodes stays as-is
|
Chris@0
|
12 * * otherwise: $nodes is set to the return value
|
Chris@0
|
13 *
|
Chris@0
|
14 * @param Node[] $nodes Array of nodes
|
Chris@0
|
15 *
|
Chris@0
|
16 * @return null|Node[] Array of nodes
|
Chris@0
|
17 */
|
Chris@0
|
18 public function beforeTraverse(array $nodes);
|
Chris@0
|
19
|
Chris@0
|
20 /**
|
Chris@0
|
21 * Called when entering a node.
|
Chris@0
|
22 *
|
Chris@0
|
23 * Return value semantics:
|
Chris@0
|
24 * * null
|
Chris@0
|
25 * => $node stays as-is
|
Chris@0
|
26 * * NodeTraverser::DONT_TRAVERSE_CHILDREN
|
Chris@0
|
27 * => Children of $node are not traversed. $node stays as-is
|
Chris@0
|
28 * * NodeTraverser::STOP_TRAVERSAL
|
Chris@0
|
29 * => Traversal is aborted. $node stays as-is
|
Chris@0
|
30 * * otherwise
|
Chris@0
|
31 * => $node is set to the return value
|
Chris@0
|
32 *
|
Chris@0
|
33 * @param Node $node Node
|
Chris@0
|
34 *
|
Chris@13
|
35 * @return null|int|Node Replacement node (or special return value)
|
Chris@0
|
36 */
|
Chris@0
|
37 public function enterNode(Node $node);
|
Chris@0
|
38
|
Chris@0
|
39 /**
|
Chris@0
|
40 * Called when leaving a node.
|
Chris@0
|
41 *
|
Chris@0
|
42 * Return value semantics:
|
Chris@0
|
43 * * null
|
Chris@0
|
44 * => $node stays as-is
|
Chris@0
|
45 * * NodeTraverser::REMOVE_NODE
|
Chris@0
|
46 * => $node is removed from the parent array
|
Chris@0
|
47 * * NodeTraverser::STOP_TRAVERSAL
|
Chris@0
|
48 * => Traversal is aborted. $node stays as-is
|
Chris@0
|
49 * * array (of Nodes)
|
Chris@0
|
50 * => The return value is merged into the parent array (at the position of the $node)
|
Chris@0
|
51 * * otherwise
|
Chris@0
|
52 * => $node is set to the return value
|
Chris@0
|
53 *
|
Chris@0
|
54 * @param Node $node Node
|
Chris@0
|
55 *
|
Chris@13
|
56 * @return null|int|Node|Node[] Replacement node (or special return value)
|
Chris@0
|
57 */
|
Chris@0
|
58 public function leaveNode(Node $node);
|
Chris@0
|
59
|
Chris@0
|
60 /**
|
Chris@0
|
61 * Called once after traversal.
|
Chris@0
|
62 *
|
Chris@0
|
63 * Return value semantics:
|
Chris@0
|
64 * * null: $nodes stays as-is
|
Chris@0
|
65 * * otherwise: $nodes is set to the return value
|
Chris@0
|
66 *
|
Chris@0
|
67 * @param Node[] $nodes Array of nodes
|
Chris@0
|
68 *
|
Chris@0
|
69 * @return null|Node[] Array of nodes
|
Chris@0
|
70 */
|
Chris@0
|
71 public function afterTraverse(array $nodes);
|
Chris@13
|
72 }
|