1 | <?php |
||
39 | class AddElements implements WorkerInterface |
||
40 | { |
||
41 | /** |
||
42 | * @var array Available form elements |
||
43 | */ |
||
44 | public static $elements = [ |
||
45 | 'button' => Button::class, |
||
46 | 'fieldset' => FieldSet::class, |
||
47 | 'label' => Label::class, |
||
48 | 'reset' => Reset::class, |
||
49 | 'submit' => Submit::class, |
||
50 | 'checkbox' => Checkbox::class, |
||
51 | 'hidden' => Hidden::class, |
||
52 | 'password' => Password::class, |
||
53 | 'select' => Select::class, |
||
54 | 'text' => Text::class, |
||
55 | 'textarea' => TextArea::class, |
||
56 | 'file' => File::class |
||
57 | ]; |
||
58 | |||
59 | /** |
||
60 | * @var array List of validators that adds required attribute to input |
||
61 | */ |
||
62 | public static $triggerRequired = [ |
||
63 | 'notEmpty', 'email', 'url' |
||
64 | ]; |
||
65 | |||
66 | private static $form; |
||
67 | |||
68 | /** |
||
69 | * Adds or changes a specific aspect of provided from |
||
70 | * |
||
71 | * @param ContainerInterface $form |
||
72 | * @param array $data |
||
73 | * |
||
74 | * @return void |
||
75 | */ |
||
76 | 36 | public static function execute(ContainerInterface $form, array $data) |
|
92 | |||
93 | /** |
||
94 | * Recursively creates the elements to add to the form |
||
95 | * |
||
96 | * @param array $element |
||
97 | * |
||
98 | * @return ElementInterface |
||
99 | */ |
||
100 | 36 | protected static function create(array $element) |
|
109 | |||
110 | /** |
||
111 | * Sets the properties and dependencies for input elements |
||
112 | * |
||
113 | * @param ElementInterface $input |
||
114 | * @param array $data |
||
115 | */ |
||
116 | 36 | protected static function populateInputs( |
|
133 | |||
134 | /** |
||
135 | * Sets the properties and dependencies for HTML elements |
||
136 | * |
||
137 | * @param ElementInterface $elm |
||
138 | * @param array $data |
||
139 | */ |
||
140 | 36 | protected static function populateElement(ElementInterface $elm, array $data) |
|
154 | |||
155 | /** |
||
156 | * Adds the value to the element |
||
157 | * |
||
158 | * @param ElementInterface $elm |
||
159 | * @param array $data |
||
160 | */ |
||
161 | 36 | protected static function setValue(ElementInterface $elm, $data) |
|
167 | |||
168 | /** |
||
169 | * Check the element alias or FQ class name |
||
170 | * |
||
171 | * @param string $type |
||
172 | * |
||
173 | * @return string The Element class name |
||
174 | */ |
||
175 | 36 | protected static function getClassName($type) |
|
176 | { |
||
177 | 36 | if (in_array($type, array_keys(self::$elements))) { |
|
178 | 36 | $type = self::$elements[$type]; |
|
179 | 36 | } |
|
180 | |||
181 | 36 | if (!class_exists($type)) { |
|
182 | 2 | throw new InvalidArgumentException( |
|
183 | 2 | "Input class '{$type}' does not exists." |
|
184 | 2 | ); |
|
185 | } |
||
186 | |||
187 | 36 | if (! is_subclass_of($type, ElementInterface::class)) { |
|
188 | 2 | throw new InvalidArgumentException( |
|
189 | 2 | "The class '{$type}' does not implement the " . |
|
190 | "Slick\\Form\\ElementInterface interface." |
||
191 | 2 | ); |
|
192 | } |
||
193 | |||
194 | 36 | return $type; |
|
195 | } |
||
196 | |||
197 | /** |
||
198 | * Add filter to the input filter chain |
||
199 | * |
||
200 | * @param InputInterface $input |
||
201 | * @param array $data |
||
202 | */ |
||
203 | 36 | protected static function setFilters(InputInterface $input, array $data) |
|
214 | |||
215 | /** |
||
216 | * Add validators to the input validator chain |
||
217 | * |
||
218 | * @param InputInterface $input |
||
219 | * @param array $data |
||
220 | */ |
||
221 | 36 | protected static function addValidators(InputInterface $input, array $data) |
|
237 | |||
238 | /** |
||
239 | * Adds the html Label element to input |
||
240 | * |
||
241 | * @param InputInterface $input |
||
242 | * @param array $data |
||
243 | */ |
||
244 | 36 | protected static function addLabel(InputInterface $input, array $data) |
|
258 | |||
259 | /** |
||
260 | * Check if validator triggers the required attribute |
||
261 | * |
||
262 | * @param string $name Validator name |
||
263 | * @param InputInterface $input |
||
264 | */ |
||
265 | 30 | protected static function checkIfRequired($name, InputInterface $input) |
|
271 | |||
272 | /** |
||
273 | * Set options for ChoiceAwareElementInterface input types like Select |
||
274 | * |
||
275 | * @param InputInterface $input |
||
276 | * @param $data |
||
277 | */ |
||
278 | 36 | protected static function addOptions(InputInterface $input, $data) |
|
289 | |||
290 | 36 | protected static function setSettings(ElementInterface $input, $data) |
|
296 | |||
297 | } |
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: