1 | <?php |
||
5 | abstract class Node |
||
6 | { |
||
7 | /** |
||
8 | * @var int |
||
9 | */ |
||
10 | protected $depth = 0; |
||
11 | |||
12 | /** |
||
13 | * @var Node|null |
||
14 | */ |
||
15 | protected $parent; |
||
16 | |||
17 | /** |
||
18 | * @var Node|null |
||
19 | */ |
||
20 | protected $previous; |
||
21 | |||
22 | /** |
||
23 | * @var Node|null |
||
24 | */ |
||
25 | protected $next; |
||
26 | |||
27 | /** |
||
28 | * @var Node|null |
||
29 | */ |
||
30 | protected $firstChild; |
||
31 | |||
32 | /** |
||
33 | * @var Node|null |
||
34 | */ |
||
35 | protected $lastChild; |
||
36 | |||
37 | /** |
||
38 | * @return Node|null |
||
39 | */ |
||
40 | 15 | public function previous(): ?Node |
|
44 | |||
45 | /** |
||
46 | * @return Node|null |
||
47 | */ |
||
48 | 1947 | public function next(): ?Node |
|
52 | |||
53 | /** |
||
54 | * @return Node|null |
||
55 | */ |
||
56 | 1962 | public function parent(): ?Node |
|
60 | |||
61 | /** |
||
62 | * @param Node|null $node |
||
63 | */ |
||
64 | 1980 | protected function setParent(Node $node = null) |
|
69 | |||
70 | /** |
||
71 | * Inserts the $sibling node after $this |
||
72 | * |
||
73 | * @param Node $sibling |
||
74 | */ |
||
75 | 1503 | public function insertAfter(Node $sibling) |
|
92 | |||
93 | /** |
||
94 | * Inserts the $sibling node before $this |
||
95 | * |
||
96 | * @param Node $sibling |
||
97 | */ |
||
98 | 9 | public function insertBefore(Node $sibling) |
|
115 | |||
116 | 384 | public function replaceWith(Node $replacement) |
|
122 | |||
123 | 1980 | public function detach() |
|
142 | |||
143 | /** |
||
144 | * @return bool |
||
145 | */ |
||
146 | abstract public function isContainer(): bool; |
||
147 | |||
148 | /** |
||
149 | * @return Node|null |
||
150 | */ |
||
151 | 1953 | public function firstChild(): ?Node |
|
155 | |||
156 | /** |
||
157 | * @return Node|null |
||
158 | */ |
||
159 | 1944 | public function lastChild(): ?Node |
|
163 | |||
164 | /** |
||
165 | * @return Node[] |
||
166 | */ |
||
167 | 2043 | public function children(): iterable |
|
176 | |||
177 | /** |
||
178 | * @param Node $child |
||
179 | */ |
||
180 | 1974 | public function appendChild(Node $child) |
|
190 | |||
191 | /** |
||
192 | * Adds $child as the very first child of $this |
||
193 | * |
||
194 | * @param Node $child |
||
195 | */ |
||
196 | 6 | public function prependChild(Node $child) |
|
206 | |||
207 | /** |
||
208 | * Detaches all child nodes of given node |
||
209 | */ |
||
210 | 6 | public function detachChildren() |
|
217 | |||
218 | /** |
||
219 | * Replace all children of given node with collection of another |
||
220 | * |
||
221 | * @param iterable $children |
||
222 | * |
||
223 | * @return $this |
||
224 | */ |
||
225 | 3 | public function replaceChildren(iterable $children) |
|
234 | |||
235 | /** |
||
236 | * @return int |
||
237 | */ |
||
238 | 396 | public function getDepth(): int |
|
242 | |||
243 | /** |
||
244 | * @return NodeWalker |
||
245 | */ |
||
246 | 1941 | public function walker(): NodeWalker |
|
250 | } |
||
251 |