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
9494 return false ;
9595 }
9696
97- if ([] === $ options ) {
98- return true ;
99- }
100-
10197 foreach ($ options as $ optionOrField ) {
10298 if ($ optionOrField instanceof Constraint) {
10399 return true ;
104100 }
105101
102+ if (null === $ optionOrField ) {
103+ continue ;
104+ }
105+
106106 if (!\is_array ($ optionOrField )) {
107107 return false ;
108108 }
109109
110- if ([] !== $ optionOrField && !($ optionOrField [0 ] ?? null ) instanceof Constraint) {
110+ if ($ optionOrField && !($ optionOrField [0 ] ?? null ) instanceof Constraint) {
111111 return false ;
112112 }
113113 }
Original file line number Diff line number Diff line change @@ -175,10 +175,15 @@ public function testEmptyFieldsInOptions()
175175 $ this ->assertSame ('foo bar baz ' , $ constraint ->extraFieldsMessage );
176176 }
177177
178- public function testEmptyConstraintListFor ()
178+ /**
179+ * @testWith [[]]
180+ * [null]
181+ */
182+ public function testEmptyConstraintListForField (?array $ fieldConstraint )
179183 {
180- $ constraint = new Collection ([
181- 'foo ' => [],
184+ $ constraint = new Collection (
185+ [
186+ 'foo ' => $ fieldConstraint ,
182187 ],
183188 null ,
184189 null ,
@@ -193,11 +198,15 @@ public function testEmptyConstraintListFor()
193198 $ this ->assertSame ('foo bar baz ' , $ constraint ->extraFieldsMessage );
194199 }
195200
196- public function testEmptyConstraintListForFieldInOptions ()
201+ /**
202+ * @testWith [[]]
203+ * [null]
204+ */
205+ public function testEmptyConstraintListForFieldInOptions (?array $ fieldConstraint )
197206 {
198207 $ constraint = new Collection ([
199208 'fields ' => [
200- 'foo ' => [] ,
209+ 'foo ' => $ fieldConstraint ,
201210 ],
202211 'allowExtraFields ' => true ,
203212 'extraFieldsMessage ' => 'foo bar baz ' ,
You can’t perform that action at this time.
0 commit comments