1: <?php
2: namespace Pharborist;
3:
4: interface ParentNodeInterface extends NodeInterface {
5: /**
6: * Get the number of children.
7: * @return int
8: */
9: public function childCount();
10:
11: /**
12: * Return the first child.
13: * @return Node
14: */
15: public function firstChild();
16:
17: /**
18: * Return the last child.
19: * @return Node
20: */
21: public function lastChild();
22:
23: /**
24: * Get the immediate children of this node.
25: * @param callable $callback An optional callback to filter by.
26: * @return NodeCollection
27: */
28: public function children(callable $callback = NULL);
29:
30: /**
31: * Remove all child nodes.
32: */
33: public function clear();
34:
35: /**
36: * Prepend nodes to this node.
37: * @param Node|Node[]|NodeCollection $nodes
38: * @return $this
39: * @throws \InvalidArgumentException
40: */
41: public function prepend($nodes);
42:
43: /**
44: * Append nodes to this node.
45: * @param Node|Node[]|NodeCollection $nodes
46: * @return $this
47: * @throws \InvalidArgumentException
48: */
49: public function append($nodes);
50:
51: /**
52: * Get the first (i.e. leftmost leaf) token.
53: * @return TokenNode
54: */
55: public function firstToken();
56:
57: /**
58: * Get the last (i.e. rightmost leaf) token.
59: * @return TokenNode
60: */
61: public function lastToken();
62:
63: /**
64: * Test if the node has a descendant that matches.
65: * @param callable $callback Callback to test for match.
66: * @return NodeCollection
67: */
68: public function has(callable $callback);
69:
70: /**
71: * Test if the node is a descendant of this node.
72: * @param Node $node Node to test
73: * @return boolean
74: */
75: public function isDescendant(Node $node);
76:
77: /**
78: * Find descendants that pass filter callback.
79: * @param callable $callback Callback to filter by.
80: * @return NodeCollection
81: */
82: public function find(callable $callback);
83:
84: /**
85: * Perform callback on this node and all descendant nodes.
86: * @param callable $callback Callback for each node.
87: */
88: public function walk(callable $callback);
89: }
90: