Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d64f7cd

Browse filesBrowse files
minor #42012 [Form] fix some type annotations (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Form] fix some type annotations | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Backported from #41998 The change in `FormValidator` is likely a bug fix, but it could be an incomplete one. `testFieldsValidateInSequenceWithNestedGroupsArray` triggers a call to `getConstraintsInGroups` with an array. I'd appreciate if `@HeahDude`, `@xabbuh`, or anyone with a better knowledge of Form could have a look please. Commits ------- e49441d [Form] fix some type annotations
2 parents 20d3d84 + e49441d commit d64f7cd
Copy full SHA for d64f7cd

File tree

Expand file treeCollapse file tree

7 files changed

+38
-106
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+38
-106
lines changed

‎src/Symfony/Component/Form/Button.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Button.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ public function handleRequest($request = null)
371371
/**
372372
* Submits data to the button.
373373
*
374-
* @param string|null $submittedData Not used
375-
* @param bool $clearMissing Not used
374+
* @param array|string|null $submittedData Not used
375+
* @param bool $clearMissing Not used
376376
*
377377
* @return $this
378378
*

‎src/Symfony/Component/Form/ButtonBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ButtonBuilder.php
-78Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ public function create($name, $type = null, array $options = [])
101101
/**
102102
* Unsupported method.
103103
*
104-
* This method should not be invoked.
105-
*
106-
* @param string $name
107-
*
108104
* @throws BadMethodCallException
109105
*/
110106
public function get($name)
@@ -115,10 +111,6 @@ public function get($name)
115111
/**
116112
* Unsupported method.
117113
*
118-
* This method should not be invoked.
119-
*
120-
* @param string $name
121-
*
122114
* @throws BadMethodCallException
123115
*/
124116
public function remove($name)
@@ -129,8 +121,6 @@ public function remove($name)
129121
/**
130122
* Unsupported method.
131123
*
132-
* @param string $name
133-
*
134124
* @return bool Always returns false
135125
*/
136126
public function has($name)
@@ -161,12 +151,6 @@ public function getForm()
161151
/**
162152
* Unsupported method.
163153
*
164-
* This method should not be invoked.
165-
*
166-
* @param string $eventName
167-
* @param callable $listener
168-
* @param int $priority
169-
*
170154
* @throws BadMethodCallException
171155
*/
172156
public function addEventListener($eventName, $listener, $priority = 0)
@@ -177,8 +161,6 @@ public function addEventListener($eventName, $listener, $priority = 0)
177161
/**
178162
* Unsupported method.
179163
*
180-
* This method should not be invoked.
181-
*
182164
* @throws BadMethodCallException
183165
*/
184166
public function addEventSubscriber(EventSubscriberInterface $subscriber)
@@ -189,10 +171,6 @@ public function addEventSubscriber(EventSubscriberInterface $subscriber)
189171
/**
190172
* Unsupported method.
191173
*
192-
* This method should not be invoked.
193-
*
194-
* @param bool $forcePrepend
195-
*
196174
* @throws BadMethodCallException
197175
*/
198176
public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false)
@@ -203,8 +181,6 @@ public function addViewTransformer(DataTransformerInterface $viewTransformer, $f
203181
/**
204182
* Unsupported method.
205183
*
206-
* This method should not be invoked.
207-
*
208184
* @throws BadMethodCallException
209185
*/
210186
public function resetViewTransformers()
@@ -215,10 +191,6 @@ public function resetViewTransformers()
215191
/**
216192
* Unsupported method.
217193
*
218-
* This method should not be invoked.
219-
*
220-
* @param bool $forceAppend
221-
*
222194
* @throws BadMethodCallException
223195
*/
224196
public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false)
@@ -229,8 +201,6 @@ public function addModelTransformer(DataTransformerInterface $modelTransformer,
229201
/**
230202
* Unsupported method.
231203
*
232-
* This method should not be invoked.
233-
*
234204
* @throws BadMethodCallException
235205
*/
236206
public function resetModelTransformers()
@@ -261,8 +231,6 @@ public function setAttributes(array $attributes)
261231
/**
262232
* Unsupported method.
263233
*
264-
* This method should not be invoked.
265-
*
266234
* @throws BadMethodCallException
267235
*/
268236
public function setDataMapper(DataMapperInterface $dataMapper = null)
@@ -287,10 +255,6 @@ public function setDisabled($disabled)
287255
/**
288256
* Unsupported method.
289257
*
290-
* This method should not be invoked.
291-
*
292-
* @param mixed $emptyData
293-
*
294258
* @throws BadMethodCallException
295259
*/
296260
public function setEmptyData($emptyData)
@@ -301,10 +265,6 @@ public function setEmptyData($emptyData)
301265
/**
302266
* Unsupported method.
303267
*
304-
* This method should not be invoked.
305-
*
306-
* @param bool $errorBubbling
307-
*
308268
* @throws BadMethodCallException
309269
*/
310270
public function setErrorBubbling($errorBubbling)
@@ -315,10 +275,6 @@ public function setErrorBubbling($errorBubbling)
315275
/**
316276
* Unsupported method.
317277
*
318-
* This method should not be invoked.
319-
*
320-
* @param bool $required
321-
*
322278
* @throws BadMethodCallException
323279
*/
324280
public function setRequired($required)
@@ -329,10 +285,6 @@ public function setRequired($required)
329285
/**
330286
* Unsupported method.
331287
*
332-
* This method should not be invoked.
333-
*
334-
* @param null $propertyPath
335-
*
336288
* @throws BadMethodCallException
337289
*/
338290
public function setPropertyPath($propertyPath)
@@ -343,10 +295,6 @@ public function setPropertyPath($propertyPath)
343295
/**
344296
* Unsupported method.
345297
*
346-
* This method should not be invoked.
347-
*
348-
* @param bool $mapped
349-
*
350298
* @throws BadMethodCallException
351299
*/
352300
public function setMapped($mapped)
@@ -357,10 +305,6 @@ public function setMapped($mapped)
357305
/**
358306
* Unsupported method.
359307
*
360-
* This method should not be invoked.
361-
*
362-
* @param bool $byReference
363-
*
364308
* @throws BadMethodCallException
365309
*/
366310
public function setByReference($byReference)
@@ -371,10 +315,6 @@ public function setByReference($byReference)
371315
/**
372316
* Unsupported method.
373317
*
374-
* This method should not be invoked.
375-
*
376-
* @param bool $compound
377-
*
378318
* @throws BadMethodCallException
379319
*/
380320
public function setCompound($compound)
@@ -397,10 +337,6 @@ public function setType(ResolvedFormTypeInterface $type)
397337
/**
398338
* Unsupported method.
399339
*
400-
* This method should not be invoked.
401-
*
402-
* @param mixed $data
403-
*
404340
* @throws BadMethodCallException
405341
*/
406342
public function setData($data)
@@ -411,10 +347,6 @@ public function setData($data)
411347
/**
412348
* Unsupported method.
413349
*
414-
* This method should not be invoked.
415-
*
416-
* @param bool $locked
417-
*
418350
* @throws BadMethodCallException
419351
*/
420352
public function setDataLocked($locked)
@@ -425,8 +357,6 @@ public function setDataLocked($locked)
425357
/**
426358
* Unsupported method.
427359
*
428-
* This method should not be invoked.
429-
*
430360
* @throws BadMethodCallException
431361
*/
432362
public function setFormFactory(FormFactoryInterface $formFactory)
@@ -437,8 +367,6 @@ public function setFormFactory(FormFactoryInterface $formFactory)
437367
/**
438368
* Unsupported method.
439369
*
440-
* @param string $action
441-
*
442370
* @throws BadMethodCallException
443371
*/
444372
public function setAction($action)
@@ -449,8 +377,6 @@ public function setAction($action)
449377
/**
450378
* Unsupported method.
451379
*
452-
* @param string $method
453-
*
454380
* @throws BadMethodCallException
455381
*/
456382
public function setMethod($method)
@@ -471,8 +397,6 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler)
471397
/**
472398
* Unsupported method.
473399
*
474-
* @param bool $initialize
475-
*
476400
* @return $this
477401
*
478402
* @throws BadMethodCallException
@@ -489,8 +413,6 @@ public function setAutoInitialize($initialize)
489413
/**
490414
* Unsupported method.
491415
*
492-
* @param bool $inheritData
493-
*
494416
* @throws BadMethodCallException
495417
*/
496418
public function setInheritData($inheritData)

‎src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php
+18-20Lines changed: 18 additions & 20 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,19 +60,17 @@ public function getDecoratedFactory()
5960
/**
6061
* {@inheritdoc}
6162
*
62-
* @param iterable $choices The choices
63-
* @param callable|string|PropertyPath|null $value The callable or path for
64-
* generating the choice values
63+
* @param mixed $value
6564
*
66-
* @return ChoiceListInterface The choice list
65+
* @return ChoiceListInterface
6766
*/
6867
public function createListFromChoices($choices, $value = null)
6968
{
7069
if (\is_string($value)) {
7170
$value = new PropertyPath($value);
7271
}
7372

74-
if ($value instanceof PropertyPath) {
73+
if ($value instanceof PropertyPathInterface) {
7574
$accessor = $this->propertyAccessor;
7675
$value = function ($choice) use ($accessor, $value) {
7776
// The callable may be invoked with a non-object/array value
@@ -88,18 +87,17 @@ public function createListFromChoices($choices, $value = null)
8887
/**
8988
* {@inheritdoc}
9089
*
91-
* @param callable|string|PropertyPath|null $value The callable or path for
92-
* generating the choice values
90+
* @param mixed $value
9391
*
94-
* @return ChoiceListInterface The choice list
92+
* @return ChoiceListInterface
9593
*/
9694
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null)
9795
{
9896
if (\is_string($value)) {
9997
$value = new PropertyPath($value);
10098
}
10199

102-
if ($value instanceof PropertyPath) {
100+
if ($value instanceof PropertyPathInterface) {
103101
$accessor = $this->propertyAccessor;
104102
$value = function ($choice) use ($accessor, $value) {
105103
// The callable may be invoked with a non-object/array value
@@ -116,13 +114,13 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
116114
/**
117115
* {@inheritdoc}
118116
*
119-
* @param array|callable|string|PropertyPath|null $preferredChoices The preferred choices
120-
* @param callable|string|PropertyPath|null $label The callable or path generating the choice labels
121-
* @param callable|string|PropertyPath|null $index The callable or path generating the view indices
122-
* @param callable|string|PropertyPath|null $groupBy The callable or path generating the group names
123-
* @param array|callable|string|PropertyPath|null $attr The callable or path generating the HTML attributes
117+
* @param mixed $preferredChoices
118+
* @param mixed $label
119+
* @param mixed $index
120+
* @param mixed $groupBy
121+
* @param mixed $attr
124122
*
125-
* @return ChoiceListView The choice list view
123+
* @return ChoiceListView
126124
*/
127125
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null)
128126
{
@@ -132,7 +130,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
132130
$label = new PropertyPath($label);
133131
}
134132

135-
if ($label instanceof PropertyPath) {
133+
if ($label instanceof PropertyPathInterface) {
136134
$label = function ($choice) use ($accessor, $label) {
137135
return $accessor->getValue($choice, $label);
138136
};
@@ -142,7 +140,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
142140
$preferredChoices = new PropertyPath($preferredChoices);
143141
}
144142

145-
if ($preferredChoices instanceof PropertyPath) {
143+
if ($preferredChoices instanceof PropertyPathInterface) {
146144
$preferredChoices = function ($choice) use ($accessor, $preferredChoices) {
147145
try {
148146
return $accessor->getValue($choice, $preferredChoices);
@@ -157,7 +155,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
157155
$index = new PropertyPath($index);
158156
}
159157

160-
if ($index instanceof PropertyPath) {
158+
if ($index instanceof PropertyPathInterface) {
161159
$index = function ($choice) use ($accessor, $index) {
162160
return $accessor->getValue($choice, $index);
163161
};
@@ -167,7 +165,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
167165
$groupBy = new PropertyPath($groupBy);
168166
}
169167

170-
if ($groupBy instanceof PropertyPath) {
168+
if ($groupBy instanceof PropertyPathInterface) {
171169
$groupBy = function ($choice) use ($accessor, $groupBy) {
172170
try {
173171
return $accessor->getValue($choice, $groupBy);
@@ -182,7 +180,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
182180
$attr = new PropertyPath($attr);
183181
}
184182

185-
if ($attr instanceof PropertyPath) {
183+
if ($attr instanceof PropertyPathInterface) {
186184
$attr = function ($choice) use ($accessor, $attr) {
187185
return $accessor->getValue($choice, $attr);
188186
};

‎src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,16 @@ private static function resolveValidationGroups($groups, FormInterface $form)
260260

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.