1 | <?php namespace Rocket\UI\Taxonomy; |
||
6 | class ParentChildTree |
||
7 | { |
||
8 | /** |
||
9 | * @var array The tree itself |
||
10 | */ |
||
11 | public $tree; |
||
12 | |||
13 | /** |
||
14 | * @var array The flat tree to find elements |
||
15 | */ |
||
16 | public $finder; |
||
17 | |||
18 | /** |
||
19 | * @var array Configuration values |
||
20 | */ |
||
21 | public $config = [ |
||
22 | 'id' => 'id', |
||
23 | 'childs' => 'childs', |
||
24 | 'parent' => 'parent_id', |
||
25 | 'default_parent' => [null, ''], |
||
26 | 'create_root' => false, |
||
27 | 'default_root' => [], |
||
28 | 'default_root_id' => 0, |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * Generate the tree |
||
33 | * |
||
34 | * @param array $tree_data The raw data to create a tree from |
||
35 | * @param array $config The configuration on how to create this tree |
||
36 | * |
||
37 | * @throws \Exception |
||
38 | */ |
||
39 | public function __construct($tree_data, $config = []) |
||
54 | |||
55 | /** |
||
56 | * Build the tree from the received data |
||
57 | * |
||
58 | * @param array $tree_data The raw data to create a tree from |
||
59 | * @throws \Exception |
||
60 | */ |
||
61 | protected function buildTree($tree_data) |
||
80 | |||
81 | /** |
||
82 | * Exit the tree creation if the tree can't be built completely |
||
83 | * |
||
84 | * @param int $beginning_with The number of nodes left to place on the tree |
||
85 | * @param array $tree_data The rest of the tree data to place |
||
86 | * @throws \Exception |
||
87 | */ |
||
88 | protected function ungracefulExit($beginning_with, $tree_data) |
||
94 | |||
95 | /** |
||
96 | * Add a leaf on the tree. |
||
97 | * |
||
98 | * @param string $parent_id |
||
99 | * @param string $node_id |
||
100 | * @param array $node |
||
101 | * @return bool |
||
102 | */ |
||
103 | public function add($parent_id, $node_id, $node) |
||
129 | |||
130 | /** |
||
131 | * Get the prepared tree. |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | public function getTree() |
||
139 | |||
140 | /** |
||
141 | * Get all node's children. |
||
142 | * |
||
143 | * @param string $id The entry's ID |
||
144 | * @return array |
||
145 | */ |
||
146 | public function getChilds($id) |
||
155 | |||
156 | /** |
||
157 | * Internal recursive function to get children. |
||
158 | * |
||
159 | * @param array $childs |
||
160 | * @param array $result |
||
161 | * @return array |
||
162 | */ |
||
163 | private function recursiveGetChilds($childs, $result) |
||
172 | |||
173 | /** |
||
174 | * Sort the tree |
||
175 | * @param mixed $key |
||
176 | */ |
||
177 | public function sort($key) |
||
182 | |||
183 | /** |
||
184 | * Internal recursive function |
||
185 | * @param array $tree |
||
186 | * @return bool |
||
187 | */ |
||
188 | private function recursiveSort(&$tree) |
||
210 | } |
||
211 |
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: