1 | <?php |
||
13 | abstract class InnerNode extends ArrayNode |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * An array of all the children. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $children = []; |
||
22 | |||
23 | /** |
||
24 | * Sets the encoding class to this node and propagates it |
||
25 | * to all its children. |
||
26 | * |
||
27 | * @param Encode $encode |
||
28 | * @return void |
||
29 | */ |
||
30 | public function propagateEncoding(Encode $encode) |
||
41 | |||
42 | /** |
||
43 | * Checks if this node has children. |
||
44 | * |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function hasChildren() |
||
51 | |||
52 | /** |
||
53 | * Returns the child by id. |
||
54 | * |
||
55 | * @param int $id |
||
56 | * @return AbstractNode |
||
57 | * @throws ChildNotFoundException |
||
58 | */ |
||
59 | public function getChild($id) |
||
67 | |||
68 | /** |
||
69 | * Returns a new array of child nodes |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | public function getChildren() |
||
88 | |||
89 | /** |
||
90 | * Counts children |
||
91 | * |
||
92 | * @return int |
||
93 | */ |
||
94 | public function countChildren() |
||
98 | |||
99 | /** |
||
100 | * Adds a child node to this node and returns the id of the child for this |
||
101 | * parent. |
||
102 | * |
||
103 | * @param AbstractNode $child |
||
104 | * @return bool |
||
105 | * @throws CircularException |
||
106 | */ |
||
107 | public function addChild(AbstractNode $child) |
||
146 | |||
147 | /** |
||
148 | * Removes the child by id. |
||
149 | * |
||
150 | * @param int $id |
||
151 | * @return $this |
||
152 | */ |
||
153 | public function removeChild($id) |
||
177 | |||
178 | /** |
||
179 | * Attempts to get the next child. |
||
180 | * |
||
181 | * @param int $id |
||
182 | * @return AbstractNode |
||
183 | * @uses $this->getChild() |
||
184 | * @throws ChildNotFoundException |
||
185 | */ |
||
186 | public function nextChild($id) |
||
187 | { |
||
188 | $child = $this->getChild($id); |
||
189 | $next = $this->children[$child->id()]['next']; |
||
190 | |||
191 | return $this->getChild($next); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * Attempts to get the previous child. |
||
196 | * |
||
197 | * @param int $id |
||
198 | * @return AbstractNode |
||
199 | * @uses $this->getChild() |
||
200 | * @throws ChildNotFoundException |
||
201 | */ |
||
202 | public function previousChild($id) |
||
203 | { |
||
204 | $child = $this->getchild($id); |
||
205 | $next = $this->children[$child->id()]['prev']; |
||
206 | |||
207 | return $this->getChild($next); |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * Checks if the given node id is a child of the |
||
212 | * current node. |
||
213 | * |
||
214 | * @param int $id |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function isChild($id) |
||
227 | |||
228 | /** |
||
229 | * Removes the child with id $childId and replace it with the new child |
||
230 | * $newChild. |
||
231 | * |
||
232 | * @param int $childId |
||
233 | * @param AbstractNode $newChild |
||
234 | * @throws ChildNotFoundException |
||
235 | */ |
||
236 | public function replaceChild($childId, AbstractNode $newChild) |
||
254 | |||
255 | /** |
||
256 | * Shortcut to return the first child. |
||
257 | * |
||
258 | * @return AbstractNode |
||
259 | * @uses $this->getChild() |
||
260 | */ |
||
261 | public function firstChild() |
||
268 | |||
269 | /** |
||
270 | * Attempts to get the last child. |
||
271 | * |
||
272 | * @return AbstractNode |
||
273 | */ |
||
274 | public function lastChild() |
||
281 | |||
282 | /** |
||
283 | * Checks if the given node id is a descendant of the |
||
284 | * current node. |
||
285 | * |
||
286 | * @param int $id |
||
287 | * @return bool |
||
288 | */ |
||
289 | public function isDescendant($id) |
||
308 | |||
309 | /** |
||
310 | * Sets the parent node. |
||
311 | * |
||
312 | * @param InnerNode $parent |
||
313 | * @return $this |
||
314 | * @throws CircularException |
||
315 | */ |
||
316 | public function setParent(InnerNode $parent) |
||
325 | } |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.