1 | <?php |
||
26 | class TreeHydrator implements HydratorInterface |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Hydratable data. |
||
31 | * |
||
32 | * @internal |
||
33 | * Used as interim storage. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $hydrateData = []; |
||
38 | |||
39 | /** |
||
40 | * Extract tree items. |
||
41 | * |
||
42 | * Flattens the tree structure to an one dimensional array and returns it in an array |
||
43 | * under the key'items'. |
||
44 | * |
||
45 | * The returned array can be directly bound to \Core\Form\Tree\ManagementFieldset. |
||
46 | * |
||
47 | * @param object $object The root of the tree. |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | public function extract($object) |
||
59 | |||
60 | /** |
||
61 | * Recursively flattens a tree structure. |
||
62 | * |
||
63 | * @param NodeInterface $tree |
||
64 | * @param array $data |
||
65 | * @param string $curId |
||
66 | */ |
||
67 | private function flattenTree($tree, &$data, $curId = '1') |
||
86 | |||
87 | /** |
||
88 | * Hydrate a tree structure from form values. |
||
89 | * |
||
90 | * Takes the post values for a \Core\Tree\ManegementFieldset and rebuilds the |
||
91 | * tree structure. |
||
92 | * |
||
93 | * @param array $data Form values |
||
94 | * @param Collection $object |
||
95 | * |
||
96 | * @return object |
||
97 | */ |
||
98 | public function hydrate(array $data, $object) |
||
104 | |||
105 | /** |
||
106 | * Prepares the form values for hydrating. |
||
107 | * |
||
108 | * @internal |
||
109 | * Populates the {@link hydrateData} array |
||
110 | * |
||
111 | * @param array $data |
||
112 | */ |
||
113 | private function prepareHydrateData(array $data) |
||
128 | |||
129 | /** |
||
130 | * Recursively hydrate the tree structure. |
||
131 | * |
||
132 | * Items not present in the {@link hydrateData} are removed, |
||
133 | * new items are created accordingly. |
||
134 | * |
||
135 | * @param NodeInterface $object |
||
136 | * @param \ArrayObject $currentData |
||
137 | * |
||
138 | * @return NodeInterface |
||
139 | */ |
||
140 | private function hydrateTree(NodeInterface $object, \ArrayObject $currentData = null) |
||
169 | |||
170 | /** |
||
171 | * Finds an item in a tree structure or create a new item. |
||
172 | * |
||
173 | * @param NodeInterface $tree |
||
174 | * @param $id |
||
175 | * |
||
176 | * @return NodeInterface |
||
177 | */ |
||
178 | private function findOrCreateChild($tree, $id) |
||
191 | } |
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: