Merge branch '3.4' into 4.3
* 3.4: Various tweaks 3.4 [PhpUnit] Fix usleep mock return value [Lock] use Predis\ClientInterface instead of Predis\Client
This commit is contained in:
commit
7031e83a8f
@ -53,12 +53,10 @@ class ClockMock
|
||||
public static function usleep($us)
|
||||
{
|
||||
if (null === self::$now) {
|
||||
return \usleep($us);
|
||||
}
|
||||
|
||||
\usleep($us);
|
||||
} else {
|
||||
self::$now += $us / 1000000;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function microtime($asFloat = false)
|
||||
@ -127,7 +125,7 @@ function sleep(\$s)
|
||||
|
||||
function usleep(\$us)
|
||||
{
|
||||
return \\$self::usleep(\$us);
|
||||
\\$self::usleep(\$us);
|
||||
}
|
||||
|
||||
function date(\$format, \$timestamp = null)
|
||||
|
@ -19,7 +19,7 @@ class RedisAdapter extends AbstractAdapter
|
||||
use RedisTrait;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client
|
||||
* @param string $namespace The default namespace
|
||||
* @param int $defaultLifetime The default lifetime
|
||||
*/
|
||||
|
@ -70,7 +70,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
|
||||
private $redisServerSupportSPOP = null;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client
|
||||
* @param string $namespace The default namespace
|
||||
* @param int $defaultLifetime The default lifetime
|
||||
*
|
||||
@ -81,7 +81,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
|
||||
$this->init($redisClient, $namespace, $defaultLifetime, $marshaller);
|
||||
|
||||
// Make sure php-redis is 3.1.3 or higher configured for Redis classes
|
||||
if (!$this->redis instanceof Predis\Client && version_compare(phpversion('redis'), '3.1.3', '<')) {
|
||||
if (!$this->redis instanceof \Predis\ClientInterface && version_compare(phpversion('redis'), '3.1.3', '<')) {
|
||||
throw new LogicException('RedisTagAwareAdapter requires php-redis 3.1.3 or higher, alternatively use predis/predis');
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
|
||||
return true;
|
||||
}
|
||||
|
||||
$predisCluster = $this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface;
|
||||
$predisCluster = $this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface;
|
||||
$this->pipeline(static function () use ($ids, $tagData, $predisCluster) {
|
||||
if ($predisCluster) {
|
||||
foreach ($ids as $id) {
|
||||
|
@ -26,7 +26,7 @@ class RedisCache extends AbstractCache
|
||||
use RedisTrait;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
|
||||
*/
|
||||
public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ trait RedisTrait
|
||||
private $marshaller;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
|
||||
*/
|
||||
private function init($redisClient, $namespace, $defaultLifetime, ?MarshallerInterface $marshaller)
|
||||
{
|
||||
@ -54,8 +54,8 @@ trait RedisTrait
|
||||
if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
|
||||
throw new InvalidArgumentException(sprintf('RedisAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
|
||||
}
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) {
|
||||
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)));
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) {
|
||||
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)));
|
||||
}
|
||||
$this->redis = $redisClient;
|
||||
$this->marshaller = $marshaller ?? new DefaultMarshaller();
|
||||
@ -76,7 +76,7 @@ trait RedisTrait
|
||||
*
|
||||
* @throws InvalidArgumentException when the DSN is invalid
|
||||
*
|
||||
* @return \Redis|\RedisCluster|\Predis\Client According to the "class" option
|
||||
* @return \Redis|\RedisCluster|\Predis\ClientInterface According to the "class" option
|
||||
*/
|
||||
public static function createConnection($dsn, array $options = [])
|
||||
{
|
||||
@ -243,7 +243,7 @@ trait RedisTrait
|
||||
};
|
||||
|
||||
$redis = $params['lazy'] ? new RedisClusterProxy($initializer) : $initializer();
|
||||
} elseif (is_a($class, \Predis\Client::class, true)) {
|
||||
} elseif (is_a($class, \Predis\ClientInterface::class, true)) {
|
||||
if ($params['redis_cluster']) {
|
||||
$params['cluster'] = 'redis';
|
||||
}
|
||||
@ -269,7 +269,7 @@ trait RedisTrait
|
||||
|
||||
$redis = new $class($hosts, array_diff_key($params, self::$defaultConnectionOptions));
|
||||
} elseif (class_exists($class, false)) {
|
||||
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis", "RedisArray", "RedisCluster" nor "Predis\Client".', $class));
|
||||
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis", "RedisArray", "RedisCluster" nor "Predis\ClientInterface".', $class));
|
||||
} else {
|
||||
throw new InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||
}
|
||||
@ -288,7 +288,7 @@ trait RedisTrait
|
||||
|
||||
$result = [];
|
||||
|
||||
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
|
||||
if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) {
|
||||
$values = $this->pipeline(function () use ($ids) {
|
||||
foreach ($ids as $id) {
|
||||
yield 'get' => [$id];
|
||||
@ -321,7 +321,7 @@ trait RedisTrait
|
||||
protected function doClear($namespace)
|
||||
{
|
||||
$cleared = true;
|
||||
if ($this->redis instanceof \Predis\Client) {
|
||||
if ($this->redis instanceof \Predis\ClientInterface) {
|
||||
$evalArgs = [0, $namespace];
|
||||
} else {
|
||||
$evalArgs = [[$namespace], 0];
|
||||
@ -346,7 +346,7 @@ trait RedisTrait
|
||||
|
||||
$cursor = null;
|
||||
do {
|
||||
$keys = $host instanceof \Predis\Client ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
|
||||
$keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
|
||||
if (isset($keys[1]) && \is_array($keys[1])) {
|
||||
$cursor = $keys[0];
|
||||
$keys = $keys[1];
|
||||
@ -369,7 +369,7 @@ trait RedisTrait
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
|
||||
if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) {
|
||||
$this->pipeline(function () use ($ids) {
|
||||
foreach ($ids as $id) {
|
||||
yield 'del' => [$id];
|
||||
@ -413,7 +413,7 @@ trait RedisTrait
|
||||
{
|
||||
$ids = [];
|
||||
|
||||
if ($this->redis instanceof RedisClusterProxy || $this->redis instanceof \RedisCluster || ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof RedisCluster)) {
|
||||
if ($this->redis instanceof RedisClusterProxy || $this->redis instanceof \RedisCluster || ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof RedisCluster)) {
|
||||
// phpredis & predis don't support pipelining with RedisCluster
|
||||
// see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining
|
||||
// see https://github.com/nrk/predis/issues/267#issuecomment-123781423
|
||||
@ -422,7 +422,7 @@ trait RedisTrait
|
||||
$results[] = $this->redis->{$command}(...$args);
|
||||
$ids[] = $args[0];
|
||||
}
|
||||
} elseif ($this->redis instanceof \Predis\Client) {
|
||||
} elseif ($this->redis instanceof \Predis\ClientInterface) {
|
||||
$results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) {
|
||||
foreach ($generator() as $command => $args) {
|
||||
$redis->{$command}(...$args);
|
||||
@ -463,7 +463,7 @@ trait RedisTrait
|
||||
private function getHosts(): array
|
||||
{
|
||||
$hosts = [$this->redis];
|
||||
if ($this->redis instanceof \Predis\Client) {
|
||||
if ($this->redis instanceof \Predis\ClientInterface) {
|
||||
$connection = $this->redis->getConnection();
|
||||
if ($connection instanceof ClusterInterface && $connection instanceof \Traversable) {
|
||||
$hosts = [];
|
||||
|
@ -652,7 +652,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
$dialog = new QuestionHelper();
|
||||
|
||||
$question = new Question('What\'s your name?');
|
||||
$question->setValidator(function () {
|
||||
$question->setValidator(function ($value) {
|
||||
if (!$value) {
|
||||
throw new \Exception('A value is required.');
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class InputDefinitionTest extends TestCase
|
||||
{
|
||||
protected static $fixtures;
|
||||
|
||||
protected $multi;
|
||||
protected $foo;
|
||||
protected $bar;
|
||||
protected $foo1;
|
||||
|
@ -196,7 +196,7 @@ class CommandTesterTest extends TestCase
|
||||
];
|
||||
|
||||
$command = new Command('foo');
|
||||
$command->setCode(function ($input, $output) use ($questions, $command) {
|
||||
$command->setCode(function ($input, $output) use ($questions) {
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->ask($questions[0]);
|
||||
$io->ask($questions[1]);
|
||||
|
@ -34,7 +34,7 @@ class RedisSessionHandler extends AbstractSessionHandler
|
||||
* List of available options:
|
||||
* * prefix: The prefix to use for the keys in order to avoid collision on the Redis server.
|
||||
*
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|RedisProxy $redis
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy $redis
|
||||
* @param array $options An associative array of options
|
||||
*
|
||||
* @throws \InvalidArgumentException When unsupported client or options are passed
|
||||
@ -45,11 +45,11 @@ class RedisSessionHandler extends AbstractSessionHandler
|
||||
!$redis instanceof \Redis &&
|
||||
!$redis instanceof \RedisArray &&
|
||||
!$redis instanceof \RedisCluster &&
|
||||
!$redis instanceof \Predis\Client &&
|
||||
!$redis instanceof \Predis\ClientInterface &&
|
||||
!$redis instanceof RedisProxy &&
|
||||
!$redis instanceof RedisClusterProxy
|
||||
) {
|
||||
throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
|
||||
throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
|
||||
}
|
||||
|
||||
if ($diff = array_diff(array_keys($options), ['prefix'])) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Ldap\Tests;
|
||||
namespace Symfony\Component\Ldap\Tests\Adapter\ExtLdap;
|
||||
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
|
||||
@ -18,6 +18,7 @@ use Symfony\Component\Ldap\Entry;
|
||||
use Symfony\Component\Ldap\Exception\LdapException;
|
||||
use Symfony\Component\Ldap\Exception\NotBoundException;
|
||||
use Symfony\Component\Ldap\LdapInterface;
|
||||
use Symfony\Component\Ldap\Tests\LdapTestCase;
|
||||
|
||||
/**
|
||||
* @requires extension ldap
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Ldap\Tests;
|
||||
namespace Symfony\Component\Ldap\Tests\Adapter\ExtLdap;
|
||||
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
|
||||
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
|
||||
@ -18,6 +18,7 @@ use Symfony\Component\Ldap\Entry;
|
||||
use Symfony\Component\Ldap\Exception\LdapException;
|
||||
use Symfony\Component\Ldap\Exception\NotBoundException;
|
||||
use Symfony\Component\Ldap\Exception\UpdateOperationException;
|
||||
use Symfony\Component\Ldap\Tests\LdapTestCase;
|
||||
|
||||
/**
|
||||
* @requires extension ldap
|
||||
|
@ -32,13 +32,13 @@ class RedisStore implements StoreInterface
|
||||
private $initialTtl;
|
||||
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
|
||||
* @param float $initialTtl the expiration delay of locks in seconds
|
||||
*/
|
||||
public function __construct($redisClient, float $initialTtl = 300.0)
|
||||
{
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy) {
|
||||
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)));
|
||||
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) {
|
||||
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)));
|
||||
}
|
||||
|
||||
if ($initialTtl <= 0) {
|
||||
@ -145,11 +145,11 @@ class RedisStore implements StoreInterface
|
||||
return $this->redis->_instance($this->redis->_target($resource))->eval($script, array_merge([$resource], $args), 1);
|
||||
}
|
||||
|
||||
if ($this->redis instanceof \Predis\Client) {
|
||||
if ($this->redis instanceof \Predis\ClientInterface) {
|
||||
return $this->redis->eval(...array_merge([$script, 1, $resource], $args));
|
||||
}
|
||||
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
|
||||
private function getUniqueToken(Key $key): string
|
||||
|
@ -25,7 +25,7 @@ use Symfony\Component\Lock\StoreInterface;
|
||||
class StoreFactory
|
||||
{
|
||||
/**
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|\Memcached|\Zookeeper|string $connection Connection or DSN or Store short name
|
||||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Memcached|\Zookeeper|string $connection Connection or DSN or Store short name
|
||||
*
|
||||
* @return StoreInterface
|
||||
*/
|
||||
@ -35,7 +35,7 @@ class StoreFactory
|
||||
$connection instanceof \Redis ||
|
||||
$connection instanceof \RedisArray ||
|
||||
$connection instanceof \RedisCluster ||
|
||||
$connection instanceof \Predis\Client ||
|
||||
$connection instanceof \Predis\ClientInterface ||
|
||||
$connection instanceof RedisProxy ||
|
||||
$connection instanceof RedisClusterProxy
|
||||
) {
|
||||
|
@ -31,7 +31,7 @@ abstract class AbstractRedisStoreTest extends AbstractStoreTest
|
||||
/**
|
||||
* Return a RedisConnection.
|
||||
*
|
||||
* @return \Redis|\RedisArray|\RedisCluster|\Predis\Client
|
||||
* @return \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface
|
||||
*/
|
||||
abstract protected function getRedisConnection();
|
||||
|
||||
|
@ -40,7 +40,7 @@ class PhpFileLoader extends FileLoader
|
||||
|
||||
// the closure forbids access to the private scope in the included file
|
||||
$loader = $this;
|
||||
$load = \Closure::bind(static function ($file) use ($loader) {
|
||||
$load = \Closure::bind(static function ($file) {
|
||||
return include $file;
|
||||
}, null, ProtectedPhpFileLoader::class);
|
||||
|
||||
|
@ -165,7 +165,7 @@ class CsrfTokenManagerTest extends TestCase
|
||||
$requestStack = new RequestStack();
|
||||
$requestStack->push(new Request([], [], [], [], [], ['HTTPS' => 'on']));
|
||||
|
||||
$manager = new CsrfTokenManager($generator, $storage, null, $requestStack);
|
||||
$manager = new CsrfTokenManager($generator, $storage);
|
||||
|
||||
$token = $manager->getToken('foo');
|
||||
$this->assertSame('foo', $token->getId());
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
||||
namespace Symfony\Component\Security\Http\Tests\Firewall;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Tests\Http\Firewall;
|
||||
namespace Symfony\Component\Security\Http\Tests\Firewall;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -37,11 +37,6 @@ class ProjectTemplateLoader4 extends Loader
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
public function getDebugger()
|
||||
{
|
||||
return $this->debugger;
|
||||
}
|
||||
|
||||
public function isFresh(TemplateReferenceInterface $template, $time)
|
||||
{
|
||||
return false;
|
||||
|
@ -93,7 +93,7 @@ class PhpEngineTest extends TestCase
|
||||
|
||||
public function testExtendRender()
|
||||
{
|
||||
$engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader, [], [new SlotsHelper()]);
|
||||
$engine = new ProjectTemplateEngine(new TemplateNameParser(), $this->loader, []);
|
||||
try {
|
||||
$engine->render('name');
|
||||
$this->fail('->render() throws an InvalidArgumentException if the template does not exist');
|
||||
|
Reference in New Issue
Block a user