1717
1818function choice_callback ()
1919{
20- return array ( 'foo ' , 'bar ' ) ;
20+ return [ 'foo ' , 'bar ' ] ;
2121}
2222
2323class ChoiceValidatorTest extends ConstraintValidatorTestCase
@@ -29,23 +29,23 @@ protected function createValidator()
2929
3030 public static function staticCallback ()
3131 {
32- return array ( 'foo ' , 'bar ' ) ;
32+ return [ 'foo ' , 'bar ' ] ;
3333 }
3434
3535 public function objectMethodCallback ()
3636 {
37- return array ( 'foo ' , 'bar ' ) ;
37+ return [ 'foo ' , 'bar ' ] ;
3838 }
3939
4040 /**
4141 * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
4242 */
4343 public function testExpectArrayIfMultipleIsTrue ()
4444 {
45- $ constraint = new Choice (array (
46- 'choices ' => array ( 'foo ' , 'bar ' ) ,
45+ $ constraint = new Choice ([
46+ 'choices ' => [ 'foo ' , 'bar ' ] ,
4747 'multiple ' => true ,
48- ) );
48+ ] );
4949
5050 $ this ->validator ->validate ('asdf ' , $ constraint );
5151 }
@@ -55,9 +55,9 @@ public function testNullIsValid()
5555 $ this ->validator ->validate (
5656 null ,
5757 new Choice (
58- array (
59- 'choices ' => array ( 'foo ' , 'bar ' ) ,
60- )
58+ [
59+ 'choices ' => [ 'foo ' , 'bar ' ] ,
60+ ]
6161 )
6262 );
6363
@@ -77,12 +77,12 @@ public function testChoicesOrCallbackExpected()
7777 */
7878 public function testValidCallbackExpected ()
7979 {
80- $ this ->validator ->validate ('foobar ' , new Choice (array ( 'callback ' => 'abcd ' ) ));
80+ $ this ->validator ->validate ('foobar ' , new Choice ([ 'callback ' => 'abcd ' ] ));
8181 }
8282
8383 public function testValidChoiceArray ()
8484 {
85- $ constraint = new Choice (array ( 'choices ' => array ( 'foo ' , 'bar ' )) );
85+ $ constraint = new Choice ([ 'choices ' => [ 'foo ' , 'bar ' ]] );
8686
8787 $ this ->validator ->validate ('bar ' , $ constraint );
8888
@@ -91,7 +91,7 @@ public function testValidChoiceArray()
9191
9292 public function testValidChoiceCallbackFunction ()
9393 {
94- $ constraint = new Choice (array ( 'callback ' => __NAMESPACE__ .'\choice_callback ' ) );
94+ $ constraint = new Choice ([ 'callback ' => __NAMESPACE__ .'\choice_callback ' ] );
9595
9696 $ this ->validator ->validate ('bar ' , $ constraint );
9797
@@ -101,11 +101,11 @@ public function testValidChoiceCallbackFunction()
101101 public function testValidChoiceCallbackClosure ()
102102 {
103103 $ constraint = new Choice (
104- array (
104+ [
105105 'callback ' => function () {
106- return array ( 'foo ' , 'bar ' ) ;
106+ return [ 'foo ' , 'bar ' ] ;
107107 },
108- )
108+ ]
109109 );
110110
111111 $ this ->validator ->validate ('bar ' , $ constraint );
@@ -115,7 +115,7 @@ public function testValidChoiceCallbackClosure()
115115
116116 public function testValidChoiceCallbackStaticMethod ()
117117 {
118- $ constraint = new Choice (array ( 'callback ' => array ( __CLASS__ , 'staticCallback ' )) );
118+ $ constraint = new Choice ([ 'callback ' => [ __CLASS__ , 'staticCallback ' ]] );
119119
120120 $ this ->validator ->validate ('bar ' , $ constraint );
121121
@@ -127,7 +127,7 @@ public function testValidChoiceCallbackContextMethod()
127127 // search $this for "staticCallback"
128128 $ this ->setObject ($ this );
129129
130- $ constraint = new Choice (array ( 'callback ' => 'staticCallback ' ) );
130+ $ constraint = new Choice ([ 'callback ' => 'staticCallback ' ] );
131131
132132 $ this ->validator ->validate ('bar ' , $ constraint );
133133
@@ -139,7 +139,7 @@ public function testValidChoiceCallbackContextObjectMethod()
139139 // search $this for "objectMethodCallback"
140140 $ this ->setObject ($ this );
141141
142- $ constraint = new Choice (array ( 'callback ' => 'objectMethodCallback ' ) );
142+ $ constraint = new Choice ([ 'callback ' => 'objectMethodCallback ' ] );
143143
144144 $ this ->validator ->validate ('bar ' , $ constraint );
145145
@@ -148,22 +148,22 @@ public function testValidChoiceCallbackContextObjectMethod()
148148
149149 public function testMultipleChoices ()
150150 {
151- $ constraint = new Choice (array (
152- 'choices ' => array ( 'foo ' , 'bar ' , 'baz ' ) ,
151+ $ constraint = new Choice ([
152+ 'choices ' => [ 'foo ' , 'bar ' , 'baz ' ] ,
153153 'multiple ' => true ,
154- ) );
154+ ] );
155155
156- $ this ->validator ->validate (array ( 'baz ' , 'bar ' ) , $ constraint );
156+ $ this ->validator ->validate ([ 'baz ' , 'bar ' ] , $ constraint );
157157
158158 $ this ->assertNoViolation ();
159159 }
160160
161161 public function testInvalidChoice ()
162162 {
163- $ constraint = new Choice (array (
164- 'choices ' => array ( 'foo ' , 'bar ' ) ,
163+ $ constraint = new Choice ([
164+ 'choices ' => [ 'foo ' , 'bar ' ] ,
165165 'message ' => 'myMessage ' ,
166- ) );
166+ ] );
167167
168168 $ this ->validator ->validate ('baz ' , $ constraint );
169169
@@ -175,12 +175,12 @@ public function testInvalidChoice()
175175
176176 public function testInvalidChoiceEmptyChoices ()
177177 {
178- $ constraint = new Choice (array (
178+ $ constraint = new Choice ([
179179 // May happen when the choices are provided dynamically, e.g. from
180180 // the DB or the model
181- 'choices ' => array () ,
181+ 'choices ' => [] ,
182182 'message ' => 'myMessage ' ,
183- ) );
183+ ] );
184184
185185 $ this ->validator ->validate ('baz ' , $ constraint );
186186
@@ -192,13 +192,13 @@ public function testInvalidChoiceEmptyChoices()
192192
193193 public function testInvalidChoiceMultiple ()
194194 {
195- $ constraint = new Choice (array (
196- 'choices ' => array ( 'foo ' , 'bar ' ) ,
195+ $ constraint = new Choice ([
196+ 'choices ' => [ 'foo ' , 'bar ' ] ,
197197 'multipleMessage ' => 'myMessage ' ,
198198 'multiple ' => true ,
199- ) );
199+ ] );
200200
201- $ this ->validator ->validate (array ( 'foo ' , 'baz ' ) , $ constraint );
201+ $ this ->validator ->validate ([ 'foo ' , 'baz ' ] , $ constraint );
202202
203203 $ this ->buildViolation ('myMessage ' )
204204 ->setParameter ('{{ value }} ' , '"baz" ' )
@@ -209,14 +209,14 @@ public function testInvalidChoiceMultiple()
209209
210210 public function testTooFewChoices ()
211211 {
212- $ constraint = new Choice (array (
213- 'choices ' => array ( 'foo ' , 'bar ' , 'moo ' , 'maa ' ) ,
212+ $ constraint = new Choice ([
213+ 'choices ' => [ 'foo ' , 'bar ' , 'moo ' , 'maa ' ] ,
214214 'multiple ' => true ,
215215 'min ' => 2 ,
216216 'minMessage ' => 'myMessage ' ,
217- ) );
217+ ] );
218218
219- $ value = array ( 'foo ' ) ;
219+ $ value = [ 'foo ' ] ;
220220
221221 $ this ->setValue ($ value );
222222
@@ -232,14 +232,14 @@ public function testTooFewChoices()
232232
233233 public function testTooManyChoices ()
234234 {
235- $ constraint = new Choice (array (
236- 'choices ' => array ( 'foo ' , 'bar ' , 'moo ' , 'maa ' ) ,
235+ $ constraint = new Choice ([
236+ 'choices ' => [ 'foo ' , 'bar ' , 'moo ' , 'maa ' ] ,
237237 'multiple ' => true ,
238238 'max ' => 2 ,
239239 'maxMessage ' => 'myMessage ' ,
240- ) );
240+ ] );
241241
242- $ value = array ( 'foo ' , 'bar ' , 'moo ' ) ;
242+ $ value = [ 'foo ' , 'bar ' , 'moo ' ] ;
243243
244244 $ this ->setValue ($ value );
245245
@@ -255,9 +255,9 @@ public function testTooManyChoices()
255255
256256 public function testStrictAllowsExactValue ()
257257 {
258- $ constraint = new Choice (array (
259- 'choices ' => array ( 1 , 2 ) ,
260- ) );
258+ $ constraint = new Choice ([
259+ 'choices ' => [ 1 , 2 ] ,
260+ ] );
261261
262262 $ this ->validator ->validate (2 , $ constraint );
263263
@@ -266,10 +266,10 @@ public function testStrictAllowsExactValue()
266266
267267 public function testStrictDisallowsDifferentType ()
268268 {
269- $ constraint = new Choice (array (
270- 'choices ' => array ( 1 , 2 ) ,
269+ $ constraint = new Choice ([
270+ 'choices ' => [ 1 , 2 ] ,
271271 'message ' => 'myMessage ' ,
272- ) );
272+ ] );
273273
274274 $ this ->validator ->validate ('2 ' , $ constraint );
275275
@@ -281,13 +281,13 @@ public function testStrictDisallowsDifferentType()
281281
282282 public function testStrictWithMultipleChoices ()
283283 {
284- $ constraint = new Choice (array (
285- 'choices ' => array ( 1 , 2 , 3 ) ,
284+ $ constraint = new Choice ([
285+ 'choices ' => [ 1 , 2 , 3 ] ,
286286 'multiple ' => true ,
287287 'multipleMessage ' => 'myMessage ' ,
288- ) );
288+ ] );
289289
290- $ this ->validator ->validate (array ( 2 , '3 ' ) , $ constraint );
290+ $ this ->validator ->validate ([ 2 , '3 ' ] , $ constraint );
291291
292292 $ this ->buildViolation ('myMessage ' )
293293 ->setParameter ('{{ value }} ' , '"3" ' )
0 commit comments