8000 minor #33666 [Lock] use Predis\ClientInterface instead of Predis\Clie… · symfony/symfony@35b6701 · GitHub
[go: up one dir, main page]

Skip to content

Commit 35b6701

Browse files
committed
minor #33666 [Lock] use Predis\ClientInterface instead of Predis\Client (seferov)
This PR was squashed before being merged into the 3.4 branch (closes #33666). Discussion ---------- [Lock] use Predis\ClientInterface instead of Predis\Client | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT `\Predis\ClientInterface` can be used instead of `\Predis\Client` for RedisStore. Commits ------- 5c01f0a [Lock] use Predis\ClientInterface instead of Predis\Client
2 parents d958312 + 5c01f0a commit 35b6701

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/Symfony/Component/Lock/Store/RedisStore.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class RedisStore implements StoreInterface
3131
private $initialTtl;
3232

3333
/**
34-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
35-
* @param float $initialTtl the expiration delay of locks in seconds
34+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
35+
* @param float $initialTtl the expiration delay of locks in seconds
3636
*/
3737
public function __construct($redisClient, $initialTtl = 300.0)
3838
{
39-
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy) {
40-
throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient)));
39+
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) {
40+
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)));
4141
}
4242

4343
if ($initialTtl <= 0) {
@@ -139,11 +139,11 @@ private function evaluate($script, $resource, array $args)
139139
return $this->redis->_instance($this->redis->_target($resource))->eval($script, array_merge([$resource], $args), 1);
140140
}
141141

142-
if ($this->redis instanceof \Predis\Client) {
142+
if ($this->redis instanceof \Predis\ClientInterface) {
143143
return \call_user_func_array([$this->redis, 'eval'], array_merge([$script, 1, $resource], $args));
144144
}
145145

146-
throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis)));
146+
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)));
147147
}
148148

149149
/**

src/Symfony/Component/Lock/Store/StoreFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
class StoreFactory
2323
{
2424
/**
25-
* @param \Redis|\RedisArray|\RedisCluster|\Pred 8000 is\Client|\Memcached $connection
25+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Memcached $connection
2626
*
2727
* @return RedisStore|MemcachedStore
2828
*/
2929
public static function createStore($connection)
3030
{
31-
if ($connection instanceof \Redis || $connection instanceof \RedisArray || $connection instanceof \RedisCluster || $connection instanceof \Predis\Client || $connection instanceof RedisProxy) {
31+
if ($connection instanceof \Redis || $connection instanceof \RedisArray || $connection instanceof \RedisCluster || $connection instanceof \Predis\ClientInterface || $connection instanceof RedisProxy) {
3232
return new RedisStore($connection);
3333
}
3434
if ($connection instanceof \Memcached) {

src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function getClockDelay()
3131
/**
3232
* Return a RedisConnection.
3333
*
34-
* @return \Redis|\RedisArray|\RedisCluster|\Predis\Client
34+
* @return \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface
3535
*/
3636
abstract protected function getRedisConnection();
3737

0 commit comments

Comments
 (0)
0