Skip to content

Commit 6b5f279

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents 526af10 + 8a9aeff commit 6b5f279

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+145
-145
lines changed

ConstraintValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function formatTypeOf($value)
8787
protected function formatValue($value, int $format = 0)
8888
{
8989
if (($format & self::PRETTY_DATE) && $value instanceof \DateTimeInterface) {
90-
if (class_exists('IntlDateFormatter')) {
90+
if (class_exists(\IntlDateFormatter::class)) {
9191
$formatter = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, 'UTC');
9292

9393
return $formatter->format(new \DateTime(

Tests/ConstraintTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSetProperties()
3838

3939
public function testSetNotExistingPropertyThrowsException()
4040
{
41-
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
41+
$this->expectException(InvalidOptionsException::class);
4242

4343
new ConstraintA([
4444
'foo' => 'bar',
@@ -49,14 +49,14 @@ public function testMagicPropertiesAreNotAllowed()
4949
{
5050
$constraint = new ConstraintA();
5151

52-
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
52+
$this->expectException(InvalidOptionsException::class);
5353

5454
$constraint->foo = 'bar';
5555
}
5656

5757
public function testInvalidAndRequiredOptionsPassed()
5858
{
59-
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
59+
$this->expectException(InvalidOptionsException::class);
6060

6161
new ConstraintC([
6262
'option1' => 'default',
@@ -104,14 +104,14 @@ public function testDontSetDefaultPropertyIfValuePropertyExists()
104104

105105
public function testSetUndefinedDefaultProperty()
106106
{
107-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
107+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
108108

109109
new ConstraintB('foo');
110110
}
111111

112112
public function testRequiredOptionsMustBeDefined()
113113
{
114-
$this->expectException('Symfony\Component\Validator\Exception\MissingOptionsException');
114+
$this->expectException(\Symfony\Component\Validator\Exception\MissingOptionsException::class);
115115

116116
new ConstraintC();
117117
}
@@ -209,7 +209,7 @@ public function testSerializeKeepsCustomGroups()
209209

210210
public function testGetErrorNameForUnknownCode()
211211
{
212-
$this->expectException('Symfony\Component\Validator\Exception\InvalidArgumentException');
212+
$this->expectException(\Symfony\Component\Validator\Exception\InvalidArgumentException::class);
213213
Constraint::getErrorName(1);
214214
}
215215

@@ -226,7 +226,7 @@ public function testOptionsAsDefaultOption()
226226

227227
public function testInvalidOptions()
228228
{
229-
$this->expectException('Symfony\Component\Validator\Exception\InvalidOptionsException');
229+
$this->expectException(InvalidOptionsException::class);
230230
$this->expectExceptionMessage('The options "0", "5" do not exist in constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintA".');
231231
new ConstraintA(['property2' => 'foo', 'bar', 5 => 'baz']);
232232
}
@@ -244,7 +244,7 @@ public function testOptionsWithInvalidInternalPointer()
244244

245245
public function testAnnotationSetUndefinedDefaultOption()
246246
{
247-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
247+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
248248
$this->expectExceptionMessage('No default option is configured for constraint "Symfony\Component\Validator\Tests\Fixtures\ConstraintB".');
249249
new ConstraintB(['value' => 1]);
250250
}

Tests/Constraints/AbstractComparisonValidatorTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ public function provideInvalidConstraintOptions()
8282
*/
8383
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
8484
{
85-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
85+
$this->expectException(ConstraintDefinitionException::class);
8686
$this->expectExceptionMessage('requires either the "value" or "propertyPath" option to be set.');
8787
$this->createConstraint($options);
8888
}
8989

9090
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
9191
{
92-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
92+
$this->expectException(ConstraintDefinitionException::class);
9393
$this->expectExceptionMessage('requires only one of the "value" or "propertyPath" options to be set, not both.');
9494
$this->createConstraint(([
9595
'value' => 'value',

Tests/Constraints/AllTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class AllTest extends TestCase
2222
{
2323
public function testRejectNonConstraints()
2424
{
25-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
25+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
2626
new All([
2727
'foo',
2828
]);
2929
}
3030

3131
public function testRejectValidConstraint()
3232
{
33-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
33+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
3434
new All([
3535
new Valid(),
3636
]);

Tests/Constraints/AllValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testNullIsValid()
3333

3434
public function testThrowsExceptionIfNotTraversable()
3535
{
36-
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
36+
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
3737
$this->validator->validate('foo.barbar', new All(new Range(['min' => 4])));
3838
}
3939

Tests/Constraints/BicValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testNoViolationOnNullObjectWithPropertyPath()
105105

106106
public function testThrowsConstraintExceptionIfBothValueAndPropertyPath()
107107
{
108-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
108+
$this->expectException(ConstraintDefinitionException::class);
109109
$this->expectExceptionMessage('The "iban" and "ibanPropertyPath" options of the Iban constraint cannot be used at the same time');
110110
new Bic([
111111
'iban' => 'value',
@@ -129,7 +129,7 @@ public function testInvalidValuePath()
129129

130130
public function testExpectsStringCompatibleType()
131131
{
132-
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
132+
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
133133
$this->validator->validate(new \stdClass(), new Bic());
134134
}
135135

Tests/Constraints/CallbackValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ public function testArrayCallableExplicitName()
182182

183183
public function testExpectValidMethods()
184184
{
185-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
185+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
186186
$object = new CallbackValidatorTest_Object();
187187

188188
$this->validator->validate($object, new Callback(['callback' => ['foobar']]));
189189
}
190190

191191
public function testExpectValidCallbacks()
192192
{
193-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
193+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
194194
$object = new CallbackValidatorTest_Object();
195195

196196
$this->validator->validate($object, new Callback(['callback' => ['foo', 'bar']]));

Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function objectMethodCallback()
3939

4040
public function testExpectArrayIfMultipleIsTrue()
4141
{
42-
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
42+
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
4343
$constraint = new Choice([
4444
'choices' => ['foo', 'bar'],
4545
'multiple' => true,
@@ -62,13 +62,13 @@ public function testNullIsValid()
6262

6363
public function testChoicesOrCallbackExpected()
6464
{
65-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
65+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
6666
$this->validator->validate('foobar', new Choice());
6767
}
6868

6969
public function testValidCallbackExpected()
7070
{
71-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
71+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
7272
$this->validator->validate('foobar', new Choice(['callback' => 'abcd']));
7373
}
7474

Tests/Constraints/CollectionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ class CollectionTest extends TestCase
2525
{
2626
public function testRejectInvalidFieldsOption()
2727
{
28-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
28+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
2929
new Collection([
3030
'fields' => 'foo',
3131
]);
3232
}
3333

3434
public function testRejectNonConstraints()
3535
{
36-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
36+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
3737
new Collection([
3838
'foo' => 'bar',
3939
]);
4040
}
4141

4242
public function testRejectValidConstraint()
4343
{
44-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
44+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
4545
new Collection([
4646
'foo' => new Valid(),
4747
]);
4848
}
4949

5050
public function testRejectValidConstraintWithinOptional()
5151
{
52-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
52+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
5353
new Collection([
5454
'foo' => new Optional(new Valid()),
5555
]);
5656
}
5757

5858
public function testRejectValidConstraintWithinRequired()
5959
{
60-
$this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
60+
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class);
6161
new Collection([
6262
'foo' => new Required(new Valid()),
6363
]);

Tests/Constraints/CollectionValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testFieldsAsDefaultOption()
5454

5555
public function testThrowsExceptionIfNotTraversable()
5656
{
57-
$this->expectException('Symfony\Component\Validator\Exception\UnexpectedValueException');
57+
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class);
5858
$this->validator->validate('foobar', new Collection(['fields' => [
5959
'foo' => new Range(['min' => 4]),
6060
]]));

0 commit comments

Comments
 (0)