1 | <?php |
||
17 | abstract class Node |
||
18 | { |
||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $depth = 0; |
||
23 | |||
24 | /** |
||
25 | * @var Node|null |
||
26 | */ |
||
27 | protected $parent; |
||
28 | |||
29 | /** |
||
30 | * @var Node|null |
||
31 | */ |
||
32 | protected $previous; |
||
33 | |||
34 | /** |
||
35 | * @var Node|null |
||
36 | */ |
||
37 | protected $next; |
||
38 | |||
39 | /** |
||
40 | * @var Node|null |
||
41 | */ |
||
42 | protected $firstChild; |
||
43 | |||
44 | /** |
||
45 | * @var Node|null |
||
46 | */ |
||
47 | protected $lastChild; |
||
48 | |||
49 | /** |
||
50 | * @return Node|null |
||
51 | */ |
||
52 | 534 | public function previous(): ?Node |
|
56 | |||
57 | /** |
||
58 | * @return Node|null |
||
59 | */ |
||
60 | 2487 | public function next(): ?Node |
|
64 | |||
65 | /** |
||
66 | * @return Node|null |
||
67 | */ |
||
68 | 2517 | public function parent(): ?Node |
|
72 | |||
73 | /** |
||
74 | * @param Node|null $node |
||
75 | */ |
||
76 | 2571 | protected function setParent(Node $node = null) |
|
81 | |||
82 | /** |
||
83 | * Inserts the $sibling node after $this |
||
84 | * |
||
85 | * @param Node $sibling |
||
86 | */ |
||
87 | 2049 | public function insertAfter(Node $sibling) |
|
104 | |||
105 | /** |
||
106 | * Inserts the $sibling node before $this |
||
107 | * |
||
108 | * @param Node $sibling |
||
109 | */ |
||
110 | 186 | public function insertBefore(Node $sibling) |
|
127 | |||
128 | 483 | public function replaceWith(Node $replacement) |
|
134 | |||
135 | 2568 | public function detach() |
|
154 | |||
155 | /** |
||
156 | * @return bool |
||
157 | */ |
||
158 | abstract public function isContainer(): bool; |
||
159 | |||
160 | /** |
||
161 | * @return Node|null |
||
162 | */ |
||
163 | 2484 | public function firstChild(): ?Node |
|
167 | |||
168 | /** |
||
169 | * @return Node|null |
||
170 | */ |
||
171 | 2469 | public function lastChild(): ?Node |
|
175 | |||
176 | /** |
||
177 | * @return Node[] |
||
178 | */ |
||
179 | 2574 | public function children(): iterable |
|
188 | |||
189 | /** |
||
190 | * @param Node $child |
||
191 | */ |
||
192 | 2550 | public function appendChild(Node $child) |
|
202 | |||
203 | /** |
||
204 | * Adds $child as the very first child of $this |
||
205 | * |
||
206 | * @param Node $child |
||
207 | */ |
||
208 | 18 | public function prependChild(Node $child) |
|
218 | |||
219 | /** |
||
220 | * Detaches all child nodes of given node |
||
221 | */ |
||
222 | 6 | public function detachChildren() |
|
229 | |||
230 | /** |
||
231 | * Replace all children of given node with collection of another |
||
232 | * |
||
233 | * @param iterable $children |
||
234 | * |
||
235 | * @return $this |
||
236 | */ |
||
237 | 3 | public function replaceChildren(iterable $children) |
|
246 | |||
247 | /** |
||
248 | * @return int |
||
249 | */ |
||
250 | 432 | public function getDepth(): int |
|
254 | |||
255 | /** |
||
256 | * @return NodeWalker |
||
257 | */ |
||
258 | 2469 | public function walker(): NodeWalker |
|
262 | } |
||
263 |