Skip to content

Commit cfd515d

Browse files
Leverage PHP8's get_debug_type()
1 parent ece5b76 commit cfd515d

7 files changed

+10
-9
lines changed

Lock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function acquire(bool $blocking = false): bool
7070
try {
7171
if ($blocking) {
7272
if (!$this->store instanceof BlockingStoreInterface) {
73-
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
73+
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', get_debug_type($this->store)));
7474
}
7575
$this->store->waitAndSave($this->key);
7676
} else {

Store/CombinedStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(array $stores, StrategyInterface $strategy)
4444
{
4545
foreach ($stores as $store) {
4646
if (!$store instanceof PersistingStoreInterface) {
47-
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, \get_class($store)));
47+
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, get_debug_type($store)));
4848
}
4949
}
5050

Store/MongoDbStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function __construct($mongo, array $options = [], float $initialTtl = 300
133133

134134
$this->uri = $mongo;
135135
} else {
136-
throw new InvalidArgumentException(sprintf('"%s()" requires "%s" or "%s" or URI as first argument, "%s" given.', __METHOD__, Collection::class, Client::class, \is_object($mongo) ? \get_class($mongo) : \gettype($mongo)));
136+
throw new InvalidArgumentException(sprintf('"%s()" requires "%s" or "%s" or URI as first argument, "%s" given.', __METHOD__, Collection::class, Client::class, get_debug_type($mongo)));
137137
}
138138

139139
if ($this->options['gcProbablity'] < 0.0 || $this->options['gcProbablity'] > 1.0) {

Store/PdoStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __construct($connOrDsn, array $options = [], float $gcProbabilit
9595
} elseif (\is_string($connOrDsn)) {
9696
$this->dsn = $connOrDsn;
9797
} else {
98-
throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, \is_object($connOrDsn) ? \get_class($connOrDsn) : \gettype($connOrDsn)));
98+
throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, get_debug_type($connOrDsn)));
9999
}
100100

101101
$this->table = $options['db_table'] ?? $this->table;

Store/RedisStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class RedisStore implements PersistingStoreInterface
3838
public function __construct($redisClient, float $initialTtl = 300.0)
3939
{
4040
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) {
41-
throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient)));
41+
throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($redisClient)));
4242
}
4343

4444
if ($initialTtl <= 0) {
@@ -141,7 +141,7 @@ private function evaluate(string $script, string $resource, array $args)
141141
return $this->redis->eval(...array_merge([$script, 1, $resource], $args));
142142
}
143143

144-
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
144+
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, get_debug_type($this->redis)));
145145
}
146146

147147
private function getUniqueToken(Key $key): string

Store/StoreFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class StoreFactory
3333
public static function createStore($connection)
3434
{
3535
if (!\is_string($connection) && !\is_object($connection)) {
36-
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, \gettype($connection)));
36+
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, get_debug_type($connection)));
3737
}
3838

3939
switch (true) {
@@ -59,7 +59,7 @@ public static function createStore($connection)
5959
return new ZookeeperStore($connection);
6060

6161
case !\is_string($connection):
62-
throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection)));
62+
throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', get_debug_type($connection)));
6363
case 'flock' === $connection:
6464
return new FlockStore();
6565

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": "^7.2.5",
20-
"psr/log": "~1.0"
20+
"psr/log": "~1.0",
21+
"symfony/polyfill-php80": "^1.15"
2122
},
2223
"require-dev": {
2324
"doctrine/dbal": "~2.5",

0 commit comments

Comments
 (0)