1 | <?php |
||
13 | class SimpleTreeNode implements TreeNodeInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var multitype |
||
17 | */ |
||
18 | protected $value; |
||
19 | |||
20 | /** |
||
21 | * @var SimpleTreeNode |
||
22 | */ |
||
23 | protected $parent; |
||
24 | |||
25 | /** |
||
26 | * @var ListInterface |
||
27 | */ |
||
28 | protected $children; |
||
29 | |||
30 | /** |
||
31 | * Constructs a new SimpleTreeNode |
||
32 | * @param multitype $value |
||
33 | * @param SimpleTreeNode $parent |
||
34 | * @param ListInterface $children |
||
35 | */ |
||
36 | public function __construct($value, SimpleTreeNode $parent = null, ListInterface $children = null) |
||
49 | |||
50 | /** |
||
51 | * Returns the children of the receiver as an Enumeration. |
||
52 | * @return ListInterface |
||
53 | */ |
||
54 | public function children() |
||
58 | |||
59 | /** |
||
60 | * Returns true if the receiver allows children. |
||
61 | * @return boolean |
||
62 | */ |
||
63 | public function getAllowsChildren() |
||
67 | |||
68 | /** |
||
69 | * Returns the child TreeNode at index childIndex. |
||
70 | * @param int $index |
||
71 | * @return TreeNodeInterface |
||
72 | */ |
||
73 | public function getChildAt($index) |
||
77 | |||
78 | /** |
||
79 | * Returns the number of children TreeNodes the receiver contains. |
||
80 | * @return int |
||
81 | */ |
||
82 | public function getChildCount() |
||
86 | |||
87 | /** |
||
88 | * Returns the index of node in the receivers children. |
||
89 | * @return int |
||
90 | */ |
||
91 | public function getIndex(TreeNodeInterface $node) |
||
95 | |||
96 | /** |
||
97 | * Returns the parent TreeNode of the receiver. |
||
98 | * @return TreeNodeInterface |
||
99 | */ |
||
100 | public function getParent() |
||
104 | |||
105 | /** |
||
106 | * Retrieves the value of this TreeNode |
||
107 | * @return multitype |
||
108 | */ |
||
109 | public function value() |
||
113 | |||
114 | /** |
||
115 | * Injects a node into the current tree structure, |
||
116 | * such that the node at the specified index becomes |
||
117 | * a child of the injected node, and the injected node |
||
118 | * moves to the specified index in the receiver |
||
119 | * @param int $index |
||
120 | * @param TreeNodeInterface $node |
||
121 | */ |
||
122 | public function injectAt($index, TreeNodeInterface $node) |
||
127 | |||
128 | /** |
||
129 | * Adds child to the receiver at index. |
||
130 | * @param TreeNodeInterface $nodex |
||
131 | * @return void |
||
132 | */ |
||
133 | public function insert(TreeNodeInterface $node) |
||
138 | |||
139 | /** |
||
140 | * Adds child to the receiver at index. |
||
141 | * @param int $index |
||
142 | * @param TreeNodeInterface $node |
||
143 | * @return void |
||
144 | */ |
||
145 | public function insertAt($index, TreeNodeInterface $node) |
||
150 | |||
151 | /** |
||
152 | * Returns true if the receiver is a leaf. |
||
153 | * @return boolean |
||
154 | */ |
||
155 | public function isLeaf() |
||
159 | |||
160 | /** |
||
161 | * Removes node from the receiver. |
||
162 | * @param TreeNodeInterface $node |
||
163 | */ |
||
164 | public function remove(TreeNodeInterface $node) |
||
168 | |||
169 | /** |
||
170 | * Removes the child at index from the receiver. |
||
171 | * @param int $index |
||
172 | */ |
||
173 | public function removeAt($index) |
||
177 | |||
178 | /** |
||
179 | * Removes the receiver from its parent. |
||
180 | * @return void |
||
181 | */ |
||
182 | public function removeFromParent() |
||
189 | |||
190 | /** |
||
191 | * Replace the node at the specified index in the |
||
192 | * receiver with the node argument |
||
193 | * @param int $index |
||
194 | * @param TreeNodeInterface $node |
||
195 | */ |
||
196 | public function replaceAt($index, TreeNodeInterface $node) |
||
202 | |||
203 | /** |
||
204 | * Sets the parent of the receiver to newParent. |
||
205 | * @param TreeNodeInterface $node |
||
206 | */ |
||
207 | public function setParent(TreeNodeInterface $node) |
||
211 | |||
212 | /** |
||
213 | * Sets the receiver's value |
||
214 | * @param multitype $value |
||
215 | */ |
||
216 | public function setValue($value) |
||
220 | |||
221 | /** |
||
222 | * Outputs to stdout a simplistic representation of this node and |
||
223 | * it's children |
||
224 | * @param number $level |
||
225 | */ |
||
226 | public function toString($level = 0) |
||
247 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: