Skip to content

Commit fbdf3c0

Browse files
committed
Use ::class keyword when possible
1 parent 4e56817 commit fbdf3c0

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Constraints/EmailValidator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Constraints;
1313

14+
use Egulias\EmailValidator\EmailValidator as EguliasEmailValidator;
1415
use Egulias\EmailValidator\Validation\EmailValidation;
1516
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
1617
use Symfony\Component\Validator\Constraint;
@@ -107,11 +108,11 @@ public function validate($value, Constraint $constraint)
107108
}
108109

109110
if (Email::VALIDATION_MODE_STRICT === $constraint->mode) {
110-
if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
111+
if (!class_exists(EguliasEmailValidator::class)) {
111112
throw new LogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0.');
112113
}
113114

114-
$strictValidator = new \Egulias\EmailValidator\EmailValidator();
115+
$strictValidator = new EguliasEmailValidator();
115116

116117
if (interface_exists(EmailValidation::class) && !$strictValidator->isValid($value, new NoRFCWarningsValidation())) {
117118
$this->context->buildViolation($constraint->message)

Tests/Mapping/Loader/XmlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testThrowExceptionIfDocTypeIsSet()
114114
$loader = new XmlFileLoader(__DIR__.'/withdoctype.xml');
115115
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
116116

117-
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
117+
$this->expectException(MappingException::class);
118118
$loader->loadClassMetadata($metadata);
119119
}
120120

@@ -129,7 +129,7 @@ public function testDoNotModifyStateIfExceptionIsThrown()
129129
try {
130130
$loader->loadClassMetadata($metadata);
131131
} catch (MappingException $e) {
132-
$this->expectException('\Symfony\Component\Validator\Exception\MappingException');
132+
$this->expectException(MappingException::class);
133133
$loader->loadClassMetadata($metadata);
134134
}
135135
}

Tests/Mapping/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testDoNotModifyStateIfExceptionIsThrown()
6969
$loader->loadClassMetadata($metadata);
7070
} catch (\InvalidArgumentException $e) {
7171
// Call again. Again an exception should be thrown
72-
$this->expectException('\InvalidArgumentException');
72+
$this->expectException(\InvalidArgumentException::class);
7373
$loader->loadClassMetadata($metadata);
7474
}
7575
}
@@ -85,7 +85,7 @@ public function testLoadClassMetadataReturnsTrueIfSuccessful()
8585
public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
8686
{
8787
$loader = new YamlFileLoader(__DIR__.'/constraint-mapping.yml');
88-
$metadata = new ClassMetadata('\stdClass');
88+
$metadata = new ClassMetadata(\stdClass::class);
8989

9090
$this->assertFalse($loader->loadClassMetadata($metadata));
9191
}

0 commit comments

Comments
 (0)