Skip to content

Commit 909c9a1

Browse files
deguiffabpot
authored andcommitted
Replace get_class() calls by ::class
1 parent 34a0f90 commit 909c9a1

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

DataCollector/ObjectParameter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(object $object, ?\Throwable $error)
2323
$this->object = $object;
2424
$this->error = $error;
2525
$this->stringable = \is_callable([$object, '__toString']);
26-
$this->class = \get_class($object);
26+
$this->class = $object::class;
2727
}
2828

2929
public function getObject(): object

Tests/Security/User/EntityUserProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function testSupportProxy()
146146
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
147147

148148
$user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', ['id1' => 1, 'id2' => 1]);
149-
$this->assertTrue($provider->supportsClass(\get_class($user2)));
149+
$this->assertTrue($provider->supportsClass($user2::class));
150150
}
151151

152152
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()

Validator/Constraints/UniqueEntityValidator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ public function validate(mixed $entity, Constraint $constraint)
7575
throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em));
7676
}
7777
} else {
78-
$em = $this->registry->getManagerForClass(\get_class($entity));
78+
$em = $this->registry->getManagerForClass($entity::class);
7979

8080
if (!$em) {
8181
throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_debug_type($entity)));
8282
}
8383
}
8484

85-
$class = $em->getClassMetadata(\get_class($entity));
85+
$class = $em->getClassMetadata($entity::class);
8686

8787
$criteria = [];
8888
$hasNullValue = false;
@@ -136,7 +136,7 @@ public function validate(mixed $entity, Constraint $constraint)
136136
throw new ConstraintDefinitionException(sprintf('The "%s" entity repository does not support the "%s" entity. The entity should be an instance of or extend "%s".', $constraint->entityClass, $class->getName(), $supportedClass));
137137
}
138138
} else {
139-
$repository = $em->getRepository(\get_class($entity));
139+
$repository = $em->getRepository($entity::class);
140140
}
141141

142142
$arguments = [$criteria];
@@ -203,7 +203,7 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class,
203203
return (string) $value;
204204
}
205205

206-
if ($class->getName() !== $idClass = \get_class($value)) {
206+
if ($class->getName() !== $idClass = $value::class) {
207207
// non unique value might be a composite PK that consists of other entity objects
208208
if ($em->getMetadataFactory()->hasMetadataFor($idClass)) {
209209
$identifiers = $em->getClassMetadata($idClass)->getIdentifierValues($value);
@@ -224,7 +224,7 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class,
224224
if (!\is_object($id) || $id instanceof \DateTimeInterface) {
225225
$idAsString = $this->formatValue($id, self::PRETTY_DATE);
226226
} else {
227-
$idAsString = sprintf('object("%s")', \get_class($id));
227+
$idAsString = sprintf('object("%s")', $id::class);
228228
}
229229

230230
$id = sprintf('%s => %s', $field, $idAsString);

Validator/DoctrineInitializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public function __construct(ManagerRegistry $registry)
3030

3131
public function initialize(object $object)
3232
{
33-
$this->registry->getManagerForClass(\get_class($object))?->initializeObject($object);
33+
$this->registry->getManagerForClass($object::class)?->initializeObject($object);
3434
}
3535
}

0 commit comments

Comments
 (0)