From 5c01f0a7e599b136ca68c0ba64e053f50ce7e4da Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Mon, 23 Sep 2019 11:24:06 +0300 Subject: [PATCH 1/3] [Lock] use Predis\ClientInterface instead of Predis\Client --- src/Symfony/Component/Lock/Store/RedisStore.php | 12 ++++++------ src/Symfony/Component/Lock/Store/StoreFactory.php | 4 ++-- .../Lock/Tests/Store/AbstractRedisStoreTest.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 6e532f83cf..4e32834026 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -31,13 +31,13 @@ class RedisStore implements StoreInterface private $initialTtl; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient - * @param float $initialTtl the expiration delay of locks in seconds + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient + * @param float $initialTtl the expiration delay of locks in seconds */ public function __construct($redisClient, $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) { @@ -139,11 +139,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 \call_user_func_array([$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))); } /** diff --git a/src/Symfony/Component/Lock/Store/StoreFactory.php b/src/Symfony/Component/Lock/Store/StoreFactory.php index cbbcb685c3..2edcc1d327 100644 --- a/src/Symfony/Component/Lock/Store/StoreFactory.php +++ b/src/Symfony/Component/Lock/Store/StoreFactory.php @@ -22,13 +22,13 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException; class StoreFactory { /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|\Memcached $connection + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Memcached $connection * * @return RedisStore|MemcachedStore */ public static function createStore($connection) { - if ($connection instanceof \Redis || $connection instanceof \RedisArray || $connection instanceof \RedisCluster || $connection instanceof \Predis\Client || $connection instanceof RedisProxy) { + if ($connection instanceof \Redis || $connection instanceof \RedisArray || $connection instanceof \RedisCluster || $connection instanceof \Predis\ClientInterface || $connection instanceof RedisProxy) { return new RedisStore($connection); } if ($connection instanceof \Memcached) { diff --git a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php index 4b9c81bd8e..4d9ca48bf5 100644 --- a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php @@ -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(); From 8198d93c5beca4f7de71932017b1073eda15bb85 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Sep 2019 21:21:37 +0200 Subject: [PATCH 2/3] [PhpUnit] Fix usleep mock return value --- src/Symfony/Bridge/PhpUnit/ClockMock.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 07ce9c3a60..bfc7566abd 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -52,12 +52,10 @@ class ClockMock public static function usleep($us) { if (null === self::$now) { - return \usleep($us); + \usleep($us); + } else { + self::$now += $us / 1000000; } - - self::$now += $us / 1000000; - - return null; } public static function microtime($asFloat = false) @@ -108,7 +106,7 @@ function sleep(\$s) function usleep(\$us) { - return \\$self::usleep(\$us); + \\$self::usleep(\$us); } EOPHP From 47cb83a6ec353bbe90cfb97049aba6891ab09d56 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Sep 2019 21:33:12 +0200 Subject: [PATCH 3/3] Various tweaks 3.4 --- .../Component/Console/Tests/Helper/QuestionHelperTest.php | 2 +- .../Component/Console/Tests/Input/InputDefinitionTest.php | 1 + .../Component/Console/Tests/Tester/CommandTesterTest.php | 2 +- .../Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php | 3 ++- .../Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php | 3 ++- src/Symfony/Component/Routing/Loader/PhpFileLoader.php | 2 +- .../Component/Security/Csrf/Tests/CsrfTokenManagerTest.php | 2 +- .../UsernamePasswordFormAuthenticationListenerTest.php | 2 +- .../UsernamePasswordJsonAuthenticationListenerTest.php | 2 +- src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php | 5 ----- src/Symfony/Component/Templating/Tests/PhpEngineTest.php | 2 +- 11 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index fc2589097c..02cc6ce7e0 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -960,7 +960,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.'); } diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index 086d28a41f..4a881f5955 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -20,6 +20,7 @@ class InputDefinitionTest extends TestCase { protected static $fixtures; + protected $multi; protected $foo; protected $bar; protected $foo1; diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index e13dc15829..1fa8292365 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -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]); diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php index f5c856f9d5..4a4fcfb0ad 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php @@ -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; @@ -17,6 +17,7 @@ use Symfony\Component\Ldap\Adapter\ExtLdap\Query; use Symfony\Component\Ldap\Entry; use Symfony\Component\Ldap\Exception\NotBoundException; use Symfony\Component\Ldap\LdapInterface; +use Symfony\Component\Ldap\Tests\LdapTestCase; /** * @requires extension ldap diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php index 9605932ee0..48719a46b4 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php @@ -9,13 +9,14 @@ * 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; use Symfony\Component\Ldap\Entry; use Symfony\Component\Ldap\Exception\LdapException; use Symfony\Component\Ldap\Exception\NotBoundException; +use Symfony\Component\Ldap\Tests\LdapTestCase; /** * @requires extension ldap diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index d9ba59d51e..dee8022f55 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -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); diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index 631c36a0db..fbd8207661 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -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()); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index c5a23be27c..60685ae263 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php index 58948ce53b..2a5ffb30e6 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php @@ -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; diff --git a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php index da8c04caa4..b8d6d15cd4 100644 --- a/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Templating/Tests/Loader/LoaderTest.php @@ -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; diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php index 4bce834150..5f43cb5f24 100644 --- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php @@ -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');