Skip to content

Commit 580f6e2

Browse files
Merge branch '3.4' into 4.3
* 3.4: Use `::class` constants instead of `__NAMESPACE__` when possible
2 parents 2e242af + c2571b0 commit 580f6e2

38 files changed

+44
-44
lines changed

Constraints/AbstractComparisonValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(PropertyAccessorInterface $propertyAccessor = null)
4040
public function validate($value, Constraint $constraint)
4141
{
4242
if (!$constraint instanceof AbstractComparison) {
43-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\AbstractComparison');
43+
throw new UnexpectedTypeException($constraint, AbstractComparison::class);
4444
}
4545

4646
if (null === $value) {

Constraints/AllValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AllValidator extends ConstraintValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof All) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\All');
30+
throw new UnexpectedTypeException($constraint, All::class);
3131
}
3232

3333
if (null === $value) {

Constraints/BicValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(PropertyAccessor $propertyAccessor = null)
6161
public function validate($value, Constraint $constraint)
6262
{
6363
if (!$constraint instanceof Bic) {
64-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Bic');
64+
throw new UnexpectedTypeException($constraint, Bic::class);
6565
}
6666

6767
if (null === $value || '' === $value) {

Constraints/BlankValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BlankValidator extends ConstraintValidator
2626
public function validate($value, Constraint $constraint)
2727
{
2828
if (!$constraint instanceof Blank) {
29-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Blank');
29+
throw new UnexpectedTypeException($constraint, Blank::class);
3030
}
3131

3232
if ('' !== $value && null !== $value) {

Constraints/CallbackValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CallbackValidator extends ConstraintValidator
2929
public function validate($object, Constraint $constraint)
3030
{
3131
if (!$constraint instanceof Callback) {
32-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Callback');
32+
throw new UnexpectedTypeException($constraint, Callback::class);
3333
}
3434

3535
$method = $constraint->callback;

Constraints/CardSchemeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CardSchemeValidator extends ConstraintValidator
9999
public function validate($value, Constraint $constraint)
100100
{
101101
if (!$constraint instanceof CardScheme) {
102-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\CardScheme');
102+
throw new UnexpectedTypeException($constraint, CardScheme::class);
103103
}
104104

105105
if (null === $value || '' === $value) {

Constraints/ChoiceValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ChoiceValidator extends ConstraintValidator
3232
public function validate($value, Constraint $constraint)
3333
{
3434
if (!$constraint instanceof Choice) {
35-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Choice');
35+
throw new UnexpectedTypeException($constraint, Choice::class);
3636
}
3737

3838
if (!\is_array($constraint->choices) && !$constraint->callback) {

Constraints/CollectionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CollectionValidator extends ConstraintValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof Collection) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Collection');
30+
throw new UnexpectedTypeException($constraint, Collection::class);
3131
}
3232

3333
if (null === $value) {

Constraints/CountValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CountValidator extends ConstraintValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof Count) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Count');
30+
throw new UnexpectedTypeException($constraint, Count::class);
3131
}
3232

3333
if (null === $value) {

Constraints/CountryValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CountryValidator extends ConstraintValidator
3131
public function validate($value, Constraint $constraint)
3232
{
3333
if (!$constraint instanceof Country) {
34-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Country');
34+
throw new UnexpectedTypeException($constraint, Country::class);
3535
}
3636

3737
if (null === $value || '' === $value) {

Constraints/CurrencyValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CurrencyValidator extends ConstraintValidator
3232
public function validate($value, Constraint $constraint)
3333
{
3434
if (!$constraint instanceof Currency) {
35-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Currency');
35+
throw new UnexpectedTypeException($constraint, Currency::class);
3636
}
3737

3838
if (null === $value || '' === $value) {

Constraints/DateTimeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DateTimeValidator extends DateValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof DateTime) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\DateTime');
30+
throw new UnexpectedTypeException($constraint, DateTime::class);
3131
}
3232

3333
if (null === $value || '' === $value) {

Constraints/DateValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function checkDate($year, $month, $day)
4545
public function validate($value, Constraint $constraint)
4646
{
4747
if (!$constraint instanceof Date) {
48-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Date');
48+
throw new UnexpectedTypeException($constraint, Date::class);
4949
}
5050

5151
if (null === $value || '' === $value) {

Constraints/EmailValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct($defaultMode = Email::VALIDATION_MODE_LOOSE)
6868
public function validate($value, Constraint $constraint)
6969
{
7070
if (!$constraint instanceof Email) {
71-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Email');
71+
throw new UnexpectedTypeException($constraint, Email::class);
7272
}
7373

7474
if (null === $value || '' === $value) {

Constraints/ExpressionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct($propertyAccessor = null, ExpressionLanguage $expres
3636
public function validate($value, Constraint $constraint)
3737
{
3838
if (!$constraint instanceof Expression) {
39-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Expression');
39+
throw new UnexpectedTypeException($constraint, Expression::class);
4040
}
4141

4242
$variables = $constraint->values;

Constraints/FileValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class FileValidator extends ConstraintValidator
4242
public function validate($value, Constraint $constraint)
4343
{
4444
if (!$constraint instanceof File) {
45-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\File');
45+
throw new UnexpectedTypeException($constraint, File::class);
4646
}
4747

4848
if (null === $value || '' === $value) {

Constraints/IbanValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class IbanValidator extends ConstraintValidator
143143
public function validate($value, Constraint $constraint)
144144
{
145145
if (!$constraint instanceof Iban) {
146-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Iban');
146+
throw new UnexpectedTypeException($constraint, Iban::class);
147147
}
148148

149149
if (null === $value || '' === $value) {

Constraints/ImageValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ImageValidator extends FileValidator
3131
public function validate($value, Constraint $constraint)
3232
{
3333
if (!$constraint instanceof Image) {
34-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Image');
34+
throw new UnexpectedTypeException($constraint, Image::class);
3535
}
3636

3737
$violations = \count($this->context->getViolations());

Constraints/IpValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class IpValidator extends ConstraintValidator
3030
public function validate($value, Constraint $constraint)
3131
{
3232
if (!$constraint instanceof Ip) {
33-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Ip');
33+
throw new UnexpectedTypeException($constraint, Ip::class);
3434
}
3535

3636
if (null === $value || '' === $value) {

Constraints/IsFalseValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IsFalseValidator extends ConstraintValidator
2626
public function validate($value, Constraint $constraint)
2727
{
2828
if (!$constraint instanceof IsFalse) {
29-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\IsFalse');
29+
throw new UnexpectedTypeException($constraint, IsFalse::class);
3030
}
3131

3232
if (null === $value || false === $value || 0 === $value || '0' === $value) {

Constraints/IsNullValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IsNullValidator extends ConstraintValidator
2626
public function validate($value, Constraint $constraint)
2727
{
2828
if (!$constraint instanceof IsNull) {
29-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\IsNull');
29+
throw new UnexpectedTypeException($constraint, IsNull::class);
3030
}
3131

3232
if (null !== $value) {

Constraints/IsTrueValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IsTrueValidator extends ConstraintValidator
2626
public function validate($value, Constraint $constraint)
2727
{
2828
if (!$constraint instanceof IsTrue) {
29-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\IsTrue');
29+
throw new UnexpectedTypeException($constraint, IsTrue::class);
3030
}
3131

3232
if (null === $value) {

Constraints/IsbnValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class IsbnValidator extends ConstraintValidator
3333
public function validate($value, Constraint $constraint)
3434
{
3535
if (!$constraint instanceof Isbn) {
36-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Isbn');
36+
throw new UnexpectedTypeException($constraint, Isbn::class);
3737
}
3838

3939
if (null === $value || '' === $value) {

Constraints/IssnValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class IssnValidator extends ConstraintValidator
3232
public function validate($value, Constraint $constraint)
3333
{
3434
if (!$constraint instanceof Issn) {
35-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Issn');
35+
throw new UnexpectedTypeException($constraint, Issn::class);
3636
}
3737

3838
if (null === $value || '' === $value) {

Constraints/LanguageValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class LanguageValidator extends ConstraintValidator
3131
public function validate($value, Constraint $constraint)
3232
{
3333
if (!$constraint instanceof Language) {
34-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Language');
34+
throw new UnexpectedTypeException($constraint, Language::class);
3535
}
3636

3737
if (null === $value || '' === $value) {

Constraints/LengthValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LengthValidator extends ConstraintValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof Length) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Length');
30+
throw new UnexpectedTypeException($constraint, Length::class);
3131
}
3232

3333
if (null === $value || '' === $value) {

Constraints/LocaleValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class LocaleValidator extends ConstraintValidator
3131
public function validate($value, Constraint $constraint)
3232
{
3333
if (!$constraint instanceof Locale) {
34-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Locale');
34+
throw new UnexpectedTypeException($constraint, Locale::class);
3535
}
3636

3737
if (null === $value || '' === $value) {

Constraints/LuhnValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class LuhnValidator extends ConstraintValidator
4040
public function validate($value, Constraint $constraint)
4141
{
4242
if (!$constraint instanceof Luhn) {
43-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Luhn');
43+
throw new UnexpectedTypeException($constraint, Luhn::class);
4444
}
4545

4646
if (null === $value || '' === $value) {

Constraints/NotBlankValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class NotBlankValidator extends ConstraintValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof NotBlank) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\NotBlank');
30+
throw new UnexpectedTypeException($constraint, NotBlank::class);
3131
}
3232

3333
if ($constraint->allowNull && null === $value) {

Constraints/NotNullValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class NotNullValidator extends ConstraintValidator
2626
public function validate($value, Constraint $constraint)
2727
{
2828
if (!$constraint instanceof NotNull) {
29-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\NotNull');
29+
throw new UnexpectedTypeException($constraint, NotNull::class);
3030
}
3131

3232
if (null === $value) {

Constraints/RangeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RangeValidator extends ConstraintValidator
2727
public function validate($value, Constraint $constraint)
2828
{
2929
if (!$constraint instanceof Range) {
30-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Range');
30+
throw new UnexpectedTypeException($constraint, Range::class);
3131
}
3232

3333
if (null === $value) {

Constraints/RegexValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RegexValidator extends ConstraintValidator
3030
public function validate($value, Constraint $constraint)
3131
{
3232
if (!$constraint instanceof Regex) {
33-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Regex');
33+
throw new UnexpectedTypeException($constraint, Regex::class);
3434
}
3535

3636
if (null === $value || '' === $value) {

Constraints/TimeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function checkTime($hour, $minute, $second)
4545
public function validate($value, Constraint $constraint)
4646
{
4747
if (!$constraint instanceof Time) {
48-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Time');
48+
throw new UnexpectedTypeException($constraint, Time::class);
4949
}
5050

5151
if (null === $value || '' === $value) {

Constraints/TypeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TypeValidator extends ConstraintValidator
2626
public function validate($value, Constraint $constraint)
2727
{
2828
if (!$constraint instanceof Type) {
29-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Type');
29+
throw new UnexpectedTypeException($constraint, Type::class);
3030
}
3131

3232
if (null === $value) {

Constraints/UrlValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class UrlValidator extends ConstraintValidator
4646
public function validate($value, Constraint $constraint)
4747
{
4848
if (!$constraint instanceof Url) {
49-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Url');
49+
throw new UnexpectedTypeException($constraint, Url::class);
5050
}
5151

5252
if (null === $value || '' === $value) {

Constraints/UuidValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class UuidValidator extends ConstraintValidator
6868
public function validate($value, Constraint $constraint)
6969
{
7070
if (!$constraint instanceof Uuid) {
71-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Uuid');
71+
throw new UnexpectedTypeException($constraint, Uuid::class);
7272
}
7373

7474
if (null === $value || '' === $value) {

Constraints/ValidValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ValidValidator extends ConstraintValidator
2323
public function validate($value, Constraint $constraint)
2424
{
2525
if (!$constraint instanceof Valid) {
26-
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Valid');
26+
throw new UnexpectedTypeException($constraint, Valid::class);
2727
}
2828

2929
if (null === $value) {

Tests/Mapping/Loader/StaticMethodLoaderTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function tearDown(): void
3333
public function testLoadClassMetadataReturnsTrueIfSuccessful()
3434
{
3535
$loader = new StaticMethodLoader('loadMetadata');
36-
$metadata = new ClassMetadata(__NAMESPACE__.'\StaticLoaderEntity');
36+
$metadata = new ClassMetadata(StaticLoaderEntity::class);
3737

3838
$this->assertTrue($loader->loadClassMetadata($metadata));
3939
}
@@ -49,7 +49,7 @@ public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
4949
public function testLoadClassMetadata()
5050
{
5151
$loader = new StaticMethodLoader('loadMetadata');
52-
$metadata = new ClassMetadata(__NAMESPACE__.'\StaticLoaderEntity');
52+
$metadata = new ClassMetadata(StaticLoaderEntity::class);
5353

5454
$loader->loadClassMetadata($metadata);
5555

@@ -59,20 +59,20 @@ public function testLoadClassMetadata()
5959
public function testLoadClassMetadataDoesNotRepeatLoadWithParentClasses()
6060
{
6161
$loader = new StaticMethodLoader('loadMetadata');
62-
$metadata = new ClassMetadata(__NAMESPACE__.'\StaticLoaderDocument');
62+
$metadata = new ClassMetadata(StaticLoaderDocument::class);
6363
$loader->loadClassMetadata($metadata);
6464
$this->assertCount(0, $metadata->getConstraints());
6565

6666
$loader = new StaticMethodLoader('loadMetadata');
67-
$metadata = new ClassMetadata(__NAMESPACE__.'\BaseStaticLoaderDocument');
67+
$metadata = new ClassMetadata(BaseStaticLoaderDocument::class);
6868
$loader->loadClassMetadata($metadata);
6969
$this->assertCount(1, $metadata->getConstraints());
7070
}
7171

7272
public function testLoadClassMetadataIgnoresInterfaces()
7373
{
7474
$loader = new StaticMethodLoader('loadMetadata');
75-
$metadata = new ClassMetadata(__NAMESPACE__.'\StaticLoaderInterface');
75+
$metadata = new ClassMetadata(StaticLoaderInterface::class);
7676

7777
$loader->loadClassMetadata($metadata);
7878

@@ -82,7 +82,7 @@ public function testLoadClassMetadataIgnoresInterfaces()
8282
public function testLoadClassMetadataInAbstractClasses()
8383
{
8484
$loader = new StaticMethodLoader('loadMetadata');
85-
$metadata = new ClassMetadata(__NAMESPACE__.'\AbstractStaticLoader');
85+
$metadata = new ClassMetadata(AbstractStaticLoader::class);
8686

8787
$loader->loadClassMetadata($metadata);
8888

@@ -95,7 +95,7 @@ public function testLoadClassMetadataIgnoresAbstractMethods()
9595
// strict standards error
9696
error_reporting(0);
9797

98-
$metadata = new ClassMetadata(__NAMESPACE__.'\AbstractStaticMethodLoader');
98+
$metadata = new ClassMetadata(AbstractStaticMethodLoader::class);
9999

100100
$loader = new StaticMethodLoader('loadMetadata');
101101
$loader->loadClassMetadata($metadata);

0 commit comments

Comments
 (0)