File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
src/Symfony/Component/Validator Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -94,20 +94,20 @@ private static function isFieldsOption($options): bool
94
94
return false ;
95
95
}
96
96
97
- if ([] === $ options ) {
98
- return true ;
99
- }
100
-
101
97
foreach ($ options as $ optionOrField ) {
102
98
if ($ optionOrField instanceof Constraint) {
103
99
return true ;
104
100
}
105
101
102
+ if (null === $ optionOrField ) {
103
+ continue ;
104
+ }
105
+
106
106
if (!\is_array ($ optionOrField )) {
107
107
return false ;
108
108
}
109
109
110
- if ([] !== $ optionOrField && !($ optionOrField [0 ] ?? null ) instanceof Constraint) {
110
+ if ($ optionOrField && !($ optionOrField [0 ] ?? null ) instanceof Constraint) {
111
111
return false ;
112
112
}
113
113
}
Original file line number Diff line number Diff line change @@ -175,10 +175,15 @@ public function testEmptyFieldsInOptions()
175
175
$ this ->assertSame ('foo bar baz ' , $ constraint ->extraFieldsMessage );
176
176
}
177
177
178
- public function testEmptyConstraintListFor ()
178
+ /**
179
+ * @testWith [[]]
180
+ * [null]
181
+ */
182
+ public function testEmptyConstraintListForField (?array $ fieldConstraint )
179
183
{
180
- $ constraint = new Collection ([
181
- 'foo ' => [],
184
+ $ constraint = new Collection (
185
+ [
186
+ 'foo ' => $ fieldConstraint ,
182
187
],
183
188
null ,
184
189
null ,
@@ -193,11 +198,15 @@ public function testEmptyConstraintListFor()
193
198
$ this ->assertSame ('foo bar baz ' , $ constraint ->extraFieldsMessage );
194
199
}
195
200
196
- public function testEmptyConstraintListForFieldInOptions ()
201
+ /**
202
+ * @testWith [[]]
203
+ * [null]
204
+ */
205
+ public function testEmptyConstraintListForFieldInOptions (?array $ fieldConstraint )
197
206
{
198
207
$ constraint = new Collection ([
199
208
'fields ' => [
200
- 'foo ' => [] ,
209
+ 'foo ' => $ fieldConstraint ,
201
210
],
202
211
'allowExtraFields ' => true ,
203
212
'extraFieldsMessage ' => 'foo bar baz ' ,
You can’t perform that action at this time.
0 commit comments