Skip to content

Commit 8a9aeff

Browse files
committed
Use ::class keyword when possible
1 parent f3c7530 commit 8a9aeff

File tree

63 files changed

+162
-162
lines changed

Some content is hidden

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

63 files changed

+162
-162
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, $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(

Constraints/ExpressionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function validate($value, Constraint $constraint)
6868
private function getExpressionLanguage(): ExpressionLanguage
6969
{
7070
if (null === $this->expressionLanguage) {
71-
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
71+
if (!class_exists(ExpressionLanguage::class)) {
7272
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
7373
}
7474
$this->expressionLanguage = new ExpressionLanguage();

Test/ConstraintValidatorTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function createContext()
107107
{
108108
$translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
109109
$translator->expects($this->any())->method('trans')->willReturnArgument(0);
110-
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
110+
$validator = $this->getMockBuilder(\Symfony\Component\Validator\Validator\ValidatorInterface::class)->getMock();
111111

112112
$context = new ExecutionContext($validator, $this->root, $translator);
113113
$context->setGroup($this->group);

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

0 commit comments

Comments
 (0)