Skip to content

Commit beb7704

Browse files
Merge branch '4.4' into 5.2
* 4.4: [Form] Fix 'invalid_message' use in multiple ChoiceType [Form] fix some type annotations
2 parents 9c9a97f + b7ac47d commit beb7704

File tree

6 files changed

+38
-77
lines changed

6 files changed

+38
-77
lines changed

Button.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ public function handleRequest($request = null)
365365
/**
366366
* Submits data to the button.
367367
*
368-
* @param string|null $submittedData Not used
369-
* @param bool $clearMissing Not used
368+
* @param array|string|null $submittedData Not used
369+
* @param bool $clearMissing Not used
370370
*
371371
* @return $this
372372
*

ButtonBuilder.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public function __construct(?string $name, array $options = [])
6767
/**
6868
* Unsupported method.
6969
*
70-
* This method should not be invoked.
71-
*
7270
* @throws BadMethodCallException
7371
*/
7472
public function add($child, string $type = null, array $options = [])
@@ -79,8 +77,6 @@ public function add($child, string $type = null, array $options = [])
7977
/**
8078
* Unsupported method.
8179
*
82-
* This method should not be invoked.
83-
*
8480
* @throws BadMethodCallException
8581
*/
8682
public function create(string $name, string $type = null, array $options = [])
@@ -91,8 +87,6 @@ public function create(string $name, string $type = null, array $options = [])
9187
/**
9288
* Unsupported method.
9389
*
94-
* This method should not be invoked.
95-
*
9690
* @throws BadMethodCallException
9791
*/
9892
public function get(string $name)
@@ -103,8 +97,6 @@ public function get(string $name)
10397
/**
10498
* Unsupported method.
10599
*
106-
* This method should not be invoked.
107-
*
108100
* @throws BadMethodCallException
109101
*/
110102
public function remove(string $name)
@@ -145,8 +137,6 @@ public function getForm()
145137
/**
146138
* Unsupported method.
147139
*
148-
* This method should not be invoked.
149-
*
150140
* @throws BadMethodCallException
151141
*/
152142
public function addEventListener(string $eventName, callable $listener, int $priority = 0)
@@ -157,8 +147,6 @@ public function addEventListener(string $eventName, callable $listener, int $pri
157147
/**
158148
* Unsupported method.
159149
*
160-
* This method should not be invoked.
161-
*
162150
* @throws BadMethodCallException
163151
*/
164152
public function addEventSubscriber(EventSubscriberInterface $subscriber)
@@ -169,8 +157,6 @@ public function addEventSubscriber(EventSubscriberInterface $subscriber)
169157
/**
170158
* Unsupported method.
171159
*
172-
* This method should not be invoked.
173-
*
174160
* @throws BadMethodCallException
175161
*/
176162
public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false)
@@ -181,8 +167,6 @@ public function addViewTransformer(DataTransformerInterface $viewTransformer, bo
181167
/**
182168
* Unsupported method.
183169
*
184-
* This method should not be invoked.
185-
*
186170
* @throws BadMethodCallException
187171
*/
188172
public function resetViewTransformers()
@@ -193,8 +177,6 @@ public function resetViewTransformers()
193177
/**
194178
* Unsupported method.
195179
*
196-
* This method should not be invoked.
197-
*
198180
* @throws BadMethodCallException
199181
*/
200182
public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false)
@@ -205,8 +187,6 @@ public function addModelTransformer(DataTransformerInterface $modelTransformer,
205187
/**
206188
* Unsupported method.
207189
*
208-
* This method should not be invoked.
209-
*
210190
* @throws BadMethodCallException
211191
*/
212192
public function resetModelTransformers()
@@ -237,8 +217,6 @@ public function setAttributes(array $attributes)
237217
/**
238218
* Unsupported method.
239219
*
240-
* This method should not be invoked.
241-
*
242220
* @throws BadMethodCallException
243221
*/
244222
public function setDataMapper(DataMapperInterface $dataMapper = null)
@@ -261,10 +239,6 @@ public function setDisabled(bool $disabled)
261239
/**
262240
* Unsupported method.
263241
*
264-
* This method should not be invoked.
265-
*
266-
* @param mixed $emptyData
267-
*
268242
* @throws BadMethodCallException
269243
*/
270244
public function setEmptyData($emptyData)
@@ -275,8 +249,6 @@ public function setEmptyData($emptyData)
275249
/**
276250
* Unsupported method.
277251
*
278-
* This method should not be invoked.
279-
*
280252
* @throws BadMethodCallException
281253
*/
282254
public function setErrorBubbling(bool $errorBubbling)
@@ -287,8 +259,6 @@ public function setErrorBubbling(bool $errorBubbling)
287259
/**
288260
* Unsupported method.
289261
*
290-
* This method should not be invoked.
291-
*
292262
* @throws BadMethodCallException
293263
*/
294264
public function setRequired(bool $required)
@@ -299,10 +269,6 @@ public function setRequired(bool $required)
299269
/**
300270
* Unsupported method.
301271
*
302-
* This method should not be invoked.
303-
*
304-
* @param null $propertyPath
305-
*
306272
* @throws BadMethodCallException
307273
*/
308274
public function setPropertyPath($propertyPath)
@@ -313,8 +279,6 @@ public function setPropertyPath($propertyPath)
313279
/**
314280
* Unsupported method.
315281
*
316-
* This method should not be invoked.
317-
*
318282
* @throws BadMethodCallException
319283
*/
320284
public function setMapped(bool $mapped)
@@ -325,8 +289,6 @@ public function setMapped(bool $mapped)
325289
/**
326290
* Unsupported method.
327291
*
328-
* This method should not be invoked.
329-
*
330292
* @throws BadMethodCallException
331293
*/
332294
public function setByReference(bool $byReference)
@@ -337,8 +299,6 @@ public function setByReference(bool $byReference)
337299
/**
338300
* Unsupported method.
339301
*
340-
* This method should not be invoked.
341-
*
342302
* @throws BadMethodCallException
343303
*/
344304
public function setCompound(bool $compound)
@@ -361,10 +321,6 @@ public function setType(ResolvedFormTypeInterface $type)
361321
/**
362322
* Unsupported method.
363323
*
364-
* This method should not be invoked.
365-
*
366-
* @param mixed $data
367-
*
368324
* @throws BadMethodCallException
369325
*/
370326
public function setData($data)
@@ -375,8 +331,6 @@ public function setData($data)
375331
/**
376332
* Unsupported method.
377333
*
378-
* This method should not be invoked.
379-
*
380334
* @throws BadMethodCallException
381335
*/
382336
public function setDataLocked(bool $locked)
@@ -387,8 +341,6 @@ public function setDataLocked(bool $locked)
387341
/**
388342
* Unsupported method.
389343
*
390-
* This method should not be invoked.
391-
*
392344
* @throws BadMethodCallException
393345
*/
394346
public function setFormFactory(FormFactoryInterface $formFactory)

ChoiceList/Factory/PropertyAccessDecorator.php

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\PropertyAccess\PropertyAccess;
1919
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
2020
use Symfony\Component\PropertyAccess\PropertyPath;
21+
use Symfony\Component\PropertyAccess\PropertyPathInterface;
2122

2223
/**
2324
* Adds property path support to a choice list factory.
@@ -59,12 +60,10 @@ public function getDecoratedFactory()
5960
/**
6061
* {@inheritdoc}
6162
*
62-
* @param callable|string|PropertyPath|null $value The callable or path for
63-
* generating the choice values
64-
* @param callable|string|PropertyPath|null $filter The callable or path for
65-
* filtering the choices
63+
* @param mixed $value
64+
* @param mixed $filter
6665
*
67-
* @return ChoiceListInterface The choice list
66+
* @return ChoiceListInterface
6867
*/
6968
public function createListFromChoices(iterable $choices, $value = null/*, $filter = null*/)
7069
{
@@ -74,7 +73,7 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
7473
$value = new PropertyPath($value);
7574
}
7675

77-
if ($value instanceof PropertyPath) {
76+
if ($value instanceof PropertyPathInterface) {
7877
$accessor = $this->propertyAccessor;
7978
$value = function ($choice) use ($accessor, $value) {
8079
// The callable may be invoked with a non-object/array value
@@ -102,12 +101,10 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
102101
/**
103102
* {@inheritdoc}
104103
*
105-
* @param callable|string|PropertyPath|null $value The callable or path for
106-
* generating the choice values
107-
* @param callable|string|PropertyPath|null $filter The callable or path for
108-
* filtering the choices
104+
* @param mixed $value
105+
* @param mixed $filter
109106
*
110-
* @return ChoiceListInterface The choice list
107+
* @return ChoiceListInterface
111108
*/
112109
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null/*, $filter = null*/)
113110
{
@@ -117,7 +114,7 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
117114
$value = new PropertyPath($value);
118115
}
119116

120-
if ($value instanceof PropertyPath) {
117+
if ($value instanceof PropertyPathInterface) {
121118
$accessor = $this->propertyAccessor;
122119
$value = function ($choice) use ($accessor, $value) {
123120
// The callable may be invoked with a non-object/array value
@@ -145,13 +142,13 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
145142
/**
146143
* {@inheritdoc}
147144
*
148-
* @param array|callable|string|PropertyPath|null $preferredChoices The preferred choices
149-
* @param callable|string|PropertyPath|null $label The callable or path generating the choice labels
150-
* @param callable|string|PropertyPath|null $index The callable or path generating the view indices
151-
* @param callable|string|PropertyPath|null $groupBy The callable or path generating the group names
152-
* @param array|callable|string|PropertyPath|null $attr The callable or path generating the HTML attributes
145+
* @param mixed $preferredChoices
146+
* @param mixed $label
147+
* @param mixed $index
148+
* @param mixed $groupBy
149+
* @param mixed $attr
153150
*
154-
* @return ChoiceListView The choice list view
151+
* @return ChoiceListView
155152
*/
156153
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
157154
{
@@ -161,7 +158,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
161158
$label = new PropertyPath($label);
162159
}
163160

164-
if ($label instanceof PropertyPath) {
161+
if ($label instanceof PropertyPathInterface) {
165162
$label = function ($choice) use ($accessor, $label) {
166163
return $accessor->getValue($choice, $label);
167164
};
@@ -171,7 +168,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
171168
$preferredChoices = new PropertyPath($preferredChoices);
172169
}
173170

174-
if ($preferredChoices instanceof PropertyPath) {
171+
if ($preferredChoices instanceof PropertyPathInterface) {
175172
$preferredChoices = function ($choice) use ($accessor, $preferredChoices) {
176173
try {
177174
return $accessor->getValue($choice, $preferredChoices);
@@ -186,7 +183,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
186183
$index = new PropertyPath($index);
187184
}
188185

189-
if ($index instanceof PropertyPath) {
186+
if ($index instanceof PropertyPathInterface) {
190187
$index = function ($choice) use ($accessor, $index) {
191188
return $accessor->getValue($choice, $index);
192189
};
@@ -196,7 +193,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
196193
$groupBy = new PropertyPath($groupBy);
197194
}
198195

199-
if ($groupBy instanceof PropertyPath) {
196+
if ($groupBy instanceof PropertyPathInterface) {
200197
$groupBy = function ($choice) use ($accessor, $groupBy) {
201198
try {
202199
return $accessor->getValue($choice, $groupBy);
@@ -211,7 +208,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
211208
$attr = new PropertyPath($attr);
212209
}
213210

214-
if ($attr instanceof PropertyPath) {
211+
if ($attr instanceof PropertyPathInterface) {
215212
$attr = function ($choice) use ($accessor, $attr) {
216213
return $accessor->getValue($choice, $attr);
217214
};

Extension/Validator/Constraints/FormValidator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,16 @@ private static function resolveValidationGroups($groups, FormInterface $form)
261261

262262
private static function getConstraintsInGroups($constraints, $group)
263263
{
264-
return array_filter($constraints, static function (Constraint $constraint) use ($group) {
265-
return \in_array($group, $constraint->groups, true);
264+
$groups = (array) $group;
265+
266+
return array_filter($constraints, static function (Constraint $constraint) use ($groups) {
267+
foreach ($groups as $group) {
268+
if (\in_array($group, $constraint->groups, true)) {
269+
return true;
270+
}
271+
}
272+
273+
return false;
266274
});
267275
}
268276
}

SubmitButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function isClicked()
3131
/**
3232
* Submits data to the button.
3333
*
34-
* @param string|null $submittedData The data
35-
* @param bool $clearMissing Not used
34+
* @param array|string|null $submittedData The data
35+
* @param bool $clearMissing Not used
3636
*
3737
* @return $this
3838
*

Util/OptionsResolverWrapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public function addAllowedValues(string $option, $allowedValues): self
6767
}
6868

6969
/**
70+
* @param string|array $allowedTypes
71+
*
7072
* @return $this
7173
*/
7274
public function setAllowedTypes(string $option, $allowedTypes): self
@@ -81,6 +83,8 @@ public function setAllowedTypes(string $option, $allowedTypes): self
8183
}
8284

8385
/**
86+
* @param string|array $allowedTypes
87+
*
8488
* @return $this
8589
*/
8690
public function addAllowedTypes(string $option, $allowedTypes): self

0 commit comments

Comments
 (0)