Skip to content

Commit 3393425

Browse files
ISSUE-142: Updated code to PHP 5.5
1 parent 240de64 commit 3393425

File tree

6 files changed

+87
-87
lines changed

6 files changed

+87
-87
lines changed

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ public function getDefaultOption()
9292
*/
9393
public function getRequiredOptions()
9494
{
95-
return array('constraints');
95+
return ['constraints'];
9696
}
9797
}

tests/BsnValidatorTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testValidate($bsn)
5353
*/
5454
public function testValidateInvalidConstraint()
5555
{
56-
$this->validator->validate(array(), new Assert\NotNull());
56+
$this->validator->validate([], new Assert\NotNull());
5757

5858
$this->assertNoViolation();
5959
}
@@ -107,36 +107,36 @@ public function testValidateViolation($bsn)
107107
*/
108108
public function providerValidBsn()
109109
{
110-
return array(
111-
'valid1' => array('111222333'),
112-
'valid2' => array('123456782'),
113-
'objectToString' => array(new ToStringObject('270590791')),
114-
);
110+
return [
111+
'valid1' => ['111222333'],
112+
'valid2' => ['123456782'],
113+
'objectToString' => [new ToStringObject('270590791')],
114+
];
115115
}
116116

117117
/**
118118
* @return array[]
119119
*/
120120
public function providerNoScalar()
121121
{
122-
return array(
123-
'array' => array(array('foo', 'bar')),
124-
'object' => array(new \stdClass()),
125-
'resource' => array(tmpfile()),
126-
'callable' => array(function () {}),
127-
);
122+
return [
123+
'array' => [['foo', 'bar']],
124+
'object' => [new \stdClass()],
125+
'resource' => [tmpfile()],
126+
'callable' => [function () {}],
127+
];
128128
}
129129

130130
/**
131131
* @return array[]
132132
*/
133133
public function providerInvalidBsn()
134134
{
135-
return array(
136-
'zeros' => array('000000000'),
137-
'invalid1' => array('999999999'),
138-
'invalid2' => array('876543242'),
139-
'toStringObject' => array(new ToStringObject('597944111')),
140-
);
135+
return [
136+
'zeros' => ['000000000'],
137+
'invalid1' => ['999999999'],
138+
'invalid2' => ['876543242'],
139+
'toStringObject' => [new ToStringObject('597944111')],
140+
];
141141
}
142142
}

tests/CollectionTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
2727
{
2828
public function testConstruct()
2929
{
30-
new Collection(array(
31-
'constraints' => array(
30+
new Collection([
31+
'constraints' => [
3232
new Assert\NotBlank(),
33-
),
34-
));
33+
],
34+
]);
3535
}
3636

3737
public function testConstructDefaultOption()
3838
{
39-
new Collection(array(
39+
new Collection([
4040
new Assert\NotBlank(),
41-
));
41+
]);
4242
}
4343

4444
/**
@@ -58,48 +58,48 @@ public function testConstructMissingRequiredConstraintsOption()
5858
*/
5959
public function testConstructConstraintsOptionNoArray($constraints)
6060
{
61-
new Collection(array(
61+
new Collection([
6262
'constraints' => $constraints,
63-
));
63+
]);
6464
}
6565

6666
/**
6767
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
6868
*/
6969
public function testConstructNoConstraint()
7070
{
71-
new Collection(array(
72-
'constraints' => array(
71+
new Collection([
72+
'constraints' => [
7373
'foo',
74-
),
75-
));
74+
],
75+
]);
7676
}
7777

7878
/**
7979
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
8080
*/
8181
public function testConstructValidConstraint()
8282
{
83-
new Collection(array(
84-
'constraints' => array(
83+
new Collection([
84+
'constraints' => [
8585
new Assert\Valid(),
86-
),
87-
));
86+
],
87+
]);
8888
}
8989

9090
/**
9191
* @return array[]
9292
*/
9393
public function providerNoArray()
9494
{
95-
return array(
96-
'bool' => array(true),
97-
'int' => array(1),
98-
'float' => array(1.2),
99-
'string' => array('foo'),
100-
'object' => array(new \stdClass()),
101-
'resource' => array(tmpfile()),
102-
'callable' => array(function () {})
103-
);
95+
return [
96+
'bool' => [true],
97+
'int' => [1],
98+
'float' => [1.2],
99+
'string' => ['foo'],
100+
'object' => [new \stdClass()],
101+
'resource' => [tmpfile()],
102+
'callable' => [function () {}],
103+
];
104104
}
105105
}

tests/CollectionValidatorTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ protected function createValidator()
4343
*/
4444
public function testValidate($value)
4545
{
46-
$constraints = array(
46+
$constraints = [
4747
new Assert\Email(),
4848
new Assert\NotBlank(),
49-
);
49+
];
5050

5151
$i = 0;
5252

@@ -66,16 +66,16 @@ public function testValidate($value)
6666
*/
6767
public function testValidateInvalidConstraint()
6868
{
69-
$this->validator->validate(array(), new Assert\NotNull());
69+
$this->validator->validate([], new Assert\NotNull());
7070

7171
$this->assertNoViolation();
7272
}
7373

7474
public function testValidateNull()
7575
{
76-
$this->validator->validate(null, new Collection(array(
76+
$this->validator->validate(null, new Collection([
7777
new Assert\NotBlank(),
78-
)));
78+
]));
7979

8080
$this->assertNoViolation();
8181
}
@@ -89,9 +89,9 @@ public function testValidateNull()
8989
*/
9090
public function testValidateNoArray($value)
9191
{
92-
$this->validator->validate($value, new Collection(array(
92+
$this->validator->validate($value, new Collection([
9393
new Assert\NotBlank(),
94-
)));
94+
]));
9595

9696
$this->assertNoViolation();
9797
}
@@ -101,26 +101,26 @@ public function testValidateNoArray($value)
101101
*/
102102
public function providerValidCollection()
103103
{
104-
return array(
105-
'empty' => array(array()),
106-
'array' => array(array('my.email@address.com')),
107-
'traversableObject' => array(new TraversableObject(array('my.email@address.com'))),
108-
);
104+
return [
105+
'empty' => [[]],
106+
'array' => [['my.email@address.com']],
107+
'traversableObject' => [new TraversableObject(['my.email@address.com'])],
108+
];
109109
}
110110

111111
/**
112112
* @return array[]
113113
*/
114114
public function providerNoArray()
115115
{
116-
return array(
117-
'bool' => array(true),
118-
'int' => array(1),
119-
'float' => array(1.2),
120-
'string' => array('foo'),
121-
'object' => array(new \stdClass()),
122-
'resource' => array(tmpfile()),
123-
'callable' => array(function () {})
124-
);
116+
return [
117+
'bool' => [true],
118+
'int' => [1],
119+
'float' => [1.2],
120+
'string' => ['foo'],
121+
'object' => [new \stdClass()],
122+
'resource' => [tmpfile()],
123+
'callable' => [function () {}],
124+
];
125125
}
126126
}

tests/JsonValidatorTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testValidate($json)
5353
*/
5454
public function testValidateInvalidConstraint()
5555
{
56-
$this->validator->validate(array(), new Assert\NotNull());
56+
$this->validator->validate([], new Assert\NotNull());
5757

5858
$this->assertNoViolation();
5959
}
@@ -107,39 +107,39 @@ public function testValidateViolation($json)
107107
*/
108108
public function providerValidJson()
109109
{
110-
return array(
111-
'bool' => array(true),
112-
'int' => array(123),
113-
'float' => array(10.99),
114-
'stringInt' => array('123'),
115-
'stringArray' => array('[1, 2, 3]'),
116-
'stringObject' => array('{"a": 1, "b": 2}'),
117-
'objectToString' => array(new ToStringObject('123')),
118-
);
110+
return [
111+
'bool' => [true],
112+
'int' => [123],
113+
'float' => [10.99],
114+
'stringInt' => ['123'],
115+
'stringArray' => ['[1, 2, 3]'],
116+
'stringObject' => ['{"a": 1, "b": 2}'],
117+
'objectToString' => [new ToStringObject('123')],
118+
];
119119
}
120120

121121
/**
122122
* @return array[]
123123
*/
124124
public function providerNoScalar()
125125
{
126-
return array(
127-
'array' => array(array('foo', 'bar')),
128-
'object' => array(new \stdClass()),
129-
'resource' => array(tmpfile()),
130-
'callable' => array(function () {}),
131-
);
126+
return [
127+
'array' => [['foo', 'bar']],
128+
'object' => [new \stdClass()],
129+
'resource' => [tmpfile()],
130+
'callable' => [function () {}],
131+
];
132132
}
133133

134134
/**
135135
* @return array[]
136136
*/
137137
public function providerInvalidJson()
138138
{
139-
return array(
140-
'string' => array('json'),
141-
'stringArray' => array('[1, 2, 3'),
142-
'stringObject' => array('{"a": 1, "b": 2'),
143-
);
139+
return [
140+
'string' => ['json'],
141+
'stringArray' => ['[1, 2, 3'],
142+
'stringObject' => ['{"a": 1, "b": 2'],
143+
];
144144
}
145145
}

tests/Models/TraversableObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TraversableObject implements \IteratorAggregate
2828
/**
2929
* @param array $data
3030
*/
31-
public function __construct($data = array())
31+
public function __construct($data = [])
3232
{
3333
$this->container = $data;
3434
}

0 commit comments

Comments
 (0)