Skip to content

Commit 70dcffa

Browse files
authored
Leverage get_debug_type() (#9297)
1 parent c94a9b1 commit 70dcffa

30 files changed

+73
-98
lines changed

lib/Doctrine/ORM/Cache/Exception/MetadataCacheUsesNonPersistentCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
use Doctrine\Common\Cache\Cache;
88

9-
use function get_class;
9+
use function get_debug_type;
1010

1111
final class MetadataCacheUsesNonPersistentCache extends CacheException
1212
{
1313
public static function fromDriver(Cache $cache): self
1414
{
1515
return new self(
16-
'Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'
16+
'Metadata Cache uses a non-persistent cache driver, ' . get_debug_type($cache) . '.'
1717
);
1818
}
1919
}

lib/Doctrine/ORM/Cache/Exception/QueryCacheUsesNonPersistentCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
use Doctrine\Common\Cache\Cache;
88

9-
use function get_class;
9+
use function get_debug_type;
1010

1111
final class QueryCacheUsesNonPersistentCache extends CacheException
1212
{
1313
public static function fromDriver(Cache $cache): self
1414
{
1515
return new self(
16-
'Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.'
16+
'Query Cache uses a non-persistent cache driver, ' . get_debug_type($cache) . '.'
1717
);
1818
}
1919
}

lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Doctrine\ORM\Query\ResultSetMapping;
99
use Doctrine\Persistence\ObjectManagerDecorator;
1010

11-
use function get_class;
11+
use function get_debug_type;
1212
use function method_exists;
1313
use function sprintf;
1414
use function trigger_error;
@@ -67,7 +67,7 @@ public function wrapInTransaction(callable $func)
6767
{
6868
if (! method_exists($this->wrapped, 'wrapInTransaction')) {
6969
trigger_error(
70-
sprintf('Calling `transactional()` instead of `wrapInTransaction()` which is not implemented on %s', get_class($this->wrapped)),
70+
sprintf('Calling `transactional()` instead of `wrapInTransaction()` which is not implemented on %s', get_debug_type($this->wrapped)),
7171
E_USER_NOTICE
7272
);
7373

lib/Doctrine/ORM/EntityManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
use function array_keys;
3434
use function call_user_func;
35-
use function get_class;
35+
use function get_debug_type;
3636
use function gettype;
3737
use function is_array;
3838
use function is_callable;
@@ -948,7 +948,7 @@ protected static function createConnection($connection, Configuration $config, ?
948948
throw new InvalidArgumentException(
949949
sprintf(
950950
'Invalid $connection argument of type %s given%s.',
951-
is_object($connection) ? get_class($connection) : gettype($connection),
951+
get_debug_type($connection),
952952
is_object($connection) ? '' : ': "' . $connection . '"'
953953
)
954954
);

lib/Doctrine/ORM/EntityNotFoundException.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public static function fromClassNameAndIdentifier($className, array $id)
3737

3838
/**
3939
* Instance for which no identifier can be found
40-
*
41-
* @psalm-param class-string $className
4240
*/
4341
public static function noIdentifierFound(string $className): self
4442
{

lib/Doctrine/ORM/Event/PreUpdateEventArgs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Doctrine\ORM\PersistentCollection;
99
use InvalidArgumentException;
1010

11-
use function get_class;
11+
use function get_debug_type;
1212
use function sprintf;
1313

1414
/**
@@ -108,7 +108,7 @@ private function assertValidField(string $field): void
108108
throw new InvalidArgumentException(sprintf(
109109
'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
110110
$field,
111-
get_class($this->getEntity())
111+
get_debug_type($this->getEntity())
112112
));
113113
}
114114
}

lib/Doctrine/ORM/Exception/EntityMissingAssignedId.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Doctrine\ORM\Exception;
66

7-
use function get_class;
7+
use function get_debug_type;
88

99
final class EntityMissingAssignedId extends ORMException
1010
{
@@ -13,7 +13,7 @@ final class EntityMissingAssignedId extends ORMException
1313
*/
1414
public static function forField($entity, string $field): self
1515
{
16-
return new self('Entity of type ' . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " .
16+
return new self('Entity of type ' . get_debug_type($entity) . " is missing an assigned ID for field '" . $field . "'. " .
1717
'The identifier generation strategy for this entity requires the ID field to be populated before ' .
1818
'EntityManager#persist() is called. If you want automatically generated identifiers instead ' .
1919
'you need to adjust the metadata mapping accordingly.');

lib/Doctrine/ORM/Mapping/Exception/CannotGenerateIds.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
use Doctrine\ORM\Exception\ORMException;
99

10-
use function get_class;
10+
use function get_debug_type;
1111
use function sprintf;
1212

1313
final class CannotGenerateIds extends ORMException
@@ -16,7 +16,7 @@ public static function withPlatform(AbstractPlatform $platform): self
1616
{
1717
return new self(sprintf(
1818
'Platform %s does not support generating identifiers',
19-
get_class($platform)
19+
get_debug_type($platform)
2020
));
2121
}
2222
}

lib/Doctrine/ORM/ORMException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Doctrine\Persistence\ObjectRepository;
99
use Exception;
1010

11-
use function get_class;
11+
use function get_debug_type;
1212
use function implode;
1313
use function sprintf;
1414

@@ -218,7 +218,7 @@ public static function metadataCacheNotConfigured()
218218
*/
219219
public static function queryCacheUsesNonPersistentCache(CacheDriver $cache)
220220
{
221-
return new self('Query Cache uses a non-persistent cache driver, ' . get_class($cache) . '.');
221+
return new self('Query Cache uses a non-persistent cache driver, ' . get_debug_type($cache) . '.');
222222
}
223223

224224
/**
@@ -228,7 +228,7 @@ public static function queryCacheUsesNonPersistentCache(CacheDriver $cache)
228228
*/
229229
public static function metadataCacheUsesNonPersistentCache(CacheDriver $cache)
230230
{
231-
return new self('Metadata Cache uses a non-persistent cache driver, ' . get_class($cache) . '.');
231+
return new self('Metadata Cache uses a non-persistent cache driver, ' . get_debug_type($cache) . '.');
232232
}
233233

234234
/**

lib/Doctrine/ORM/ORMInvalidArgumentException.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
use function array_map;
1111
use function count;
12-
use function get_class;
12+
use function get_debug_type;
1313
use function gettype;
1414
use function implode;
15-
use function is_object;
1615
use function method_exists;
1716
use function reset;
1817
use function spl_object_id;
@@ -218,7 +217,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a
218217
$expectedType,
219218
$assoc['sourceEntity'],
220219
$assoc['fieldName'],
221-
is_object($actualValue) ? get_class($actualValue) : gettype($actualValue)
220+
get_debug_type($actualValue)
222221
));
223222
}
224223

@@ -231,7 +230,7 @@ public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $a
231230
*/
232231
public static function invalidEntityName($entityName)
233232
{
234-
return new self(sprintf('Entity name must be a string, %s given', gettype($entityName)));
233+
return new self(sprintf('Entity name must be a string, %s given', get_debug_type($entityName)));
235234
}
236235

237236
/**
@@ -241,7 +240,7 @@ public static function invalidEntityName($entityName)
241240
*/
242241
private static function objToStr($obj): string
243242
{
244-
return method_exists($obj, '__toString') ? (string) $obj : get_class($obj) . '@' . spl_object_id($obj);
243+
return method_exists($obj, '__toString') ? (string) $obj : get_debug_type($obj) . '@' . spl_object_id($obj);
245244
}
246245

247246
/**

0 commit comments

Comments
 (0)