Skip to content

Commit 73d9ff6

Browse files
Leverage PHP8's get_debug_type()
1 parent 657ea07 commit 73d9ff6

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

Form/ChoiceList/IdReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getIdValue(object $object = null)
9393
}
9494

9595
if (!$this->om->contains($object)) {
96-
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', \get_class($object)));
96+
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_debug_type($object)));
9797
}
9898

9999
$this->om->initializeObject($object);

Form/Type/EntityType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function configureOptions(OptionsResolver $resolver)
5353
public function getLoader(ObjectManager $manager, $queryBuilder, string $class)
5454
{
5555
if (!$queryBuilder instanceof QueryBuilder) {
56-
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder)));
56+
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder)));
5757
}
5858

5959
return new ORMQueryBuilderLoader($queryBuilder);
@@ -79,7 +79,7 @@ public function getBlockPrefix()
7979
public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array
8080
{
8181
if (!$queryBuilder instanceof QueryBuilder) {
82-
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder)));
82+
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder)));
8383
}
8484

8585
return [

Security/User/EntityUserProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function loadUserByUsername(string $username)
5555
$user = $repository->findOneBy([$this->property => $username]);
5656
} else {
5757
if (!$repository instanceof UserLoaderInterface) {
58-
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository)));
58+
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_debug_type($repository)));
5959
}
6060

6161
$user = $repository->loadUserByUsername($username);
@@ -75,7 +75,7 @@ public function refreshUser(UserInterface $user)
7575
{
7676
$class = $this->getClass();
7777
if (!$user instanceof $class) {
78-
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
78+
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
7979
}
8080

8181
$repository = $this->getRepository();
@@ -114,7 +114,7 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)
114114
{
115115
$class = $this->getClass();
116116
if (!$user instanceof $class) {
117-
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
117+
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
118118
}
119119

120120
$repository = $this->getRepository();

Tests/PropertyInfo/Fixtures/DoctrineFooType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
5050
return null;
5151
}
5252
if (!$value instanceof Foo) {
53-
throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value)));
53+
throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', get_debug_type($value)));
5454
}
5555

5656
return $foo->bar;

Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function validate($entity, Constraint $constraint)
7171
$em = $this->registry->getManagerForClass(\get_class($entity));
7272

7373
if (!$em) {
74-
throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', \get_class($entity)));
74+
throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_debug_type($entity)));
7575
}
7676
}
7777

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"doctrine/persistence": "^1.3",
2222
"symfony/polyfill-ctype": "~1.8",
2323
"symfony/polyfill-mbstring": "~1.0",
24+
"symfony/polyfill-php80": "^1.15",
2425
"symfony/service-contracts": "^1.1|^2"
2526
},
2627
"require-dev": {

0 commit comments

Comments
 (0)