8000 Merge branch '4.3' into 4.4 · symfony/symfony@51a2cb6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51a2cb6

Browse files
Merge branch '4.3' into 4.4
* 4.3: [Security/Http] fix typo in deprecation message Various tweaks 3.4 Various tweaks 4.3 [PhpUnit] Fix usleep mock return value [Lock] use Predis\ClientInterface instead of Predis\Client Fix version typo in deprecation notice Make legacy "wrong" RFC2047 encoding apply only to one header
2 parents 3c7172d + 1ccc970 commit 51a2cb6

29 files changed

+83
-65
lines changed

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ public static function sleep($s)
5353
public static function usleep($us)
5454
{
5555
if (null === self::$now) {
56-
return \usleep($us);
56+
\usleep($us);
57+
} else {
58+
self::$now += $us / 1000000;
5759
}
58-
59-
self::$now += $us / 1000000;
60-
61-
return null;
6260
}
6361

6462
public static function microtime($asFloat = false)
@@ -127,7 +125,7 @@ function sleep(\$s)
127125
128126
function usleep(\$us)
129127
{
130-
return \\$self::usleep(\$us);
128+
\\$self::usleep(\$us);
131129
}
132130
133131
function date(\$format, \$timestamp = null)

src/Symfony/Component/Cache/Adapter/RedisAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class RedisAdapter extends AbstractAdapter
1919
use RedisTrait;
2020

2121
/**
22-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client
23-
* @param string $namespace The default namespace
24-
* @param int $defaultLifetime The default lifetime
22+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client
23+
* @param string $namespace The default namespace
24+
* @param int $defaultLifetime The default lifetime
2525
*/
2626
public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
2727
{

src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
6868
private $redisServerSupportSPOP = null;
6969

7070
/**
71-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client
72-
* @param string $namespace The default namespace
73-
* @param int $defaultLifetime The default lifetime
71+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client
72+
* @param string $namespace The default namespace
73+
* @param int $defaultLifetime The default lifetime
7474
*
7575
* @throws \Symfony\Component\Cache\Exception\LogicException If phpredis with version lower than 3.1.3.
7676
*/
@@ -79,7 +79,7 @@ public function __construct($redisClient, string $namespace = '', int $defaultLi
7979
$this->init($redisClient, $namespace, $defaultLifetime, $marshaller);
8080

8181
// Make sure php-redis is 3.1.3 or higher configured for Redis classes
82-
if (!$this->redis instanceof Predis\Client && version_compare(phpversion('redis'), '3.1.3', '<')) {
82+
if (!$this->redis instanceof \Predis\ClientInterface && version_compare(phpversion('redis'), '3.1.3', '<')) {
8383
throw new LogicException('RedisTagAwareAdapter requires php-redis 3.1.3 or higher, alternatively use predis/predis');
8484
}
8585
}
@@ -138,7 +138,7 @@ protected function doDelete(array $ids, array $tagData = []): bool
138138
return true;
139139
}
140140

141-
$predisCluster = $this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface;
141+
$predisCluster = $this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface;
142142
$this->pipeline(static function () use ($ids, $tagData, $predisCluster) {
143143
if ($predisCluster) {
144144
foreach ($ids as $id) {

src/Symfony/Component/Cache/Simple/RedisCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RedisCache extends AbstractCache
2626
use RedisTrait;
2727

2828
/**
29-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
29+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
3030
*/
3131
public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
3232
{

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ trait RedisTrait
4646
private $marshaller;
4747

4848
/**
49-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
49+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
5050
*/
5151
private function init($redisClient, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller)
5252
{
@@ -55,8 +55,8 @@ private function init($redisClient, string $namespace, int $defaultLifetime, ?Ma
5555
if (preg_match('#[^-+_.A-Za-z0-9]#', $namespace, $match)) {
5656
throw new InvalidArgumentException(sprintf('RedisAdapter namespace contains "%s" but only characters in [-+_.A-Za-z0-9] are allowed.', $match[0]));
5757
}
58-
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) {
59-
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)));
58+
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) {
59+
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)));
6060
}
6161
$this->redis = $redisClient;
6262
$this->marshaller = $marshaller ?? new DefaultMarshaller();
@@ -77,7 +77,7 @@ private function init($redisClient, string $namespace, int $defaultLifetime, ?Ma
7777
*
7878
* @throws InvalidArgumentException when the DSN is invalid
7979
*
80-
* @return \Redis|\RedisCluster|\Predis\Client According to the "class" option
80+
* @return \Redis|\RedisCluster|\Predis\ClientInterface According to the "class" option
8181
*/
8282
public static function createConnection($dsn, array $options = [])
8383
{
@@ -248,7 +248,7 @@ public static function createConnection($dsn, array $options = [])
248248
};
249249

250250
$redis = $params['lazy'] ? new RedisClusterProxy($initializer) : $initializer();
251-
} elseif (is_a($class, \Predis\Client::class, true)) {
251+
} elseif (is_a($class, \Predis\ClientInterface::class, true)) {
252252
if ($params['redis_cluster']) {
253253
$params['cluster'] = 'redis';
254254
if (isset($params['redis_sentinel'])) {
@@ -283,7 +283,7 @@ public static function createConnection($dsn, array $options = [])
283283
$redis->getConnection()->setSentinelTimeout($params['timeout']);
284284
}
285285
} elseif (class_exists($class, false)) {
286-
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis", "RedisArray", "RedisCluster" nor "Predis\Client".', $class));
286+
throw new InvalidArgumentException(sprintf('"%s" is not a subclass of "Redis", "RedisArray", "RedisCluster" nor "Predis\ClientInterface".', $class));
287287
} else {
288288
throw new InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
289289
}
@@ -302,7 +302,7 @@ protected function doFetch(array $ids)
302302

303303
$result = [];
304304

305-
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
305+
if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) {
306306
$values = $this->pipeline(function () use ($ids) {
307307
foreach ($ids as $id) {
308308
yield 'get' => [$id];
@@ -335,7 +335,7 @@ protected function doHave($id)
335335
protected function doClear($namespace)
336336
{
337337
$cleared = true;
338-
if ($this->redis instanceof \Predis\Client) {
338+
if ($this->redis instanceof \Predis\ClientInterface) {
339339
$evalArgs = [0, $namespace];
340340
} else {
341341
$evalArgs = [[$namespace], 0];
@@ -360,7 +360,7 @@ protected function doClear($namespace)
360360

361361
$cursor = null;
362362
do {
363-
$keys = $host instanceof \Predis\Client ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
363+
$keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
364364
if (isset($keys[1]) && \is_array($keys[1])) {
365365
$cursor = $keys[0];
366366
$keys = $keys[1];
@@ -383,7 +383,7 @@ protected function doDelete(array $ids)
383383
return true;
384384
}
385385

386-
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
386+
if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) {
387387
$this->pipeline(function () use ($ids) {
388388
foreach ($ids as $id) {
389389
yield 'del' => [$id];
@@ -427,7 +427,7 @@ private function pipeline(\Closure $generator): \Generator
427427
{
428428
$ids = [];
429429

430-
if ($this->redis instanceof RedisClusterProxy || $this->redis instanceof \RedisCluster || ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof RedisCluster)) {
430+
if ($this->redis instanceof RedisClusterProxy || $this->redis instanceof \RedisCluster || ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof RedisCluster)) {
431431
// phpredis & predis don't support pipelining with RedisCluster
432432
// see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining
433433
// see https://github.com/nrk/predis/issues/267#issuecomment-123781423
@@ -436,7 +436,7 @@ private function pipeline(\Closure $generator): \Generator
436436
$results[] = $this->redis->{$command}(...$args);
437437
$ids[] = $args[0];
438438
}
439-
} elseif ($this->redis instanceof \Predis\Client) {
439+
} elseif ($this->redis instanceof \Predis\ClientInterface) {
440440
$results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) {
441441
foreach ($generator() as $command => $args) {
442442
$redis->{$command}(...$args);
@@ -477,7 +477,7 @@ private function pipeline(\Closure $generator): \Generator
477477
private function getHosts(): array
478478
{
479479
$hosts = [$this->redis];
480-
if ($this->redis instanceof \Predis\Client) {
480+
if ($this->redis instanceof \Predis\ClientInterface) {
481481
$connection = $this->redis->getConnection();
482482
if ($connection instanceof ClusterInterface && $connection instanceof \Traversable) {
483483
$hosts = [];

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ public function testAskThrowsExceptionOnMissingInputWithValidator()
715715
$dialog = new QuestionHelper();
716716

717717
$question = new Question('What\'s your name?');
718-
$question->setValidator(function () {
718+
$question->setValidator(function ($value) {
719719
if (!$value) {
720720
throw new \Exception('A value is required.');
721721
}

src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class InputDefinitionTest extends TestCase
2020
{
2121
protected static $fixtures;
2222

23+
protected $multi;
2324
protected $foo;
2425
protected $bar;
2526
protected $foo1;

src/Symfony/Component/Console/Tests/Question/QuestionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function providerSetAutocompleterValuesInvalid()
140140
{
141141
return [
142142
['Potato'],
143-
[new \stdclass()],
143+
[new \stdClass()],
144144
[false],
145145
];
146146
}

src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function testSymfonyStyleCommandWithInputs()
196196
];
197197

198198
$command = new Command('foo');
199-
$command->setCode(function ($input, $output) use ($questions, $command) {
199+
$command->setCode(function ($input, $output) use ($questions) {
200200
$io = new SymfonyStyle($input, $output);
201201
$io->ask($questions[0]);
202202
$io->ask($questions[1]);

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RedisSessionHandler extends AbstractSessionHandler
3434
* List of available options:
3535
* * prefix: The prefix to use for the keys in order to avoid collision on the Redis server.
3636
*
37-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|RedisProxy $redis
37+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy $redis
3838
*
3939
* @throws \InvalidArgumentException When unsupported client or options are passed
4040
*/
@@ -44,11 +44,11 @@ public function __construct($redis, array $options = [])
4444
!$redis instanceof \Redis &&
4545
!$redis instanceof \RedisArray &&
4646
!$redis instanceof \RedisCluster &&
47-
!$redis instanceof \Predis\Client &&
47+
!$redis instanceof \Predis\ClientInterface &&
4848
!$redis instanceof RedisProxy &&
4949
!$redis instanceof RedisClusterProxy
5050
) {
51-
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)));
51+
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)));
5252
}
5353

5454
if ($diff = array_diff(array_keys($options), ['prefix'])) {

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Ldap\Tests;
12+
namespace Symfony\Component\Ldap\Tests\Adapter\ExtLdap;
1313

1414
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
1515
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Ldap\Exception\LdapException;
1919
use Symfony\Component\Ldap\Exception\NotBoundException;
2020
use Symfony\Component\Ldap\LdapInterface;
21+
use Symfony\Component\Ldap\Tests\LdapTestCase;
2122

2223
/**
2324
* @requires extension ldap

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Ldap\Tests;
12+
namespace Symfony\Component\Ldap\Tests\Adapter\ExtLdap;
1313

1414
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
1515
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Ldap\Exception\LdapException;
2020
use Symfony\Component\Ldap\Exception\NotBoundException;
2121
use Symfony\Component\Ldap\Exception\UpdateOperationException;
22+
use Symfony\Component\Ldap\Tests\LdapTestCase;
2223

2324
/**
2425
* @requires extension ldap

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

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

3535
/**
36-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
37-
* @param float $initialTtl the expiration delay of locks in seconds
36+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient
37+
* @param float $initialTtl the expiration delay of locks in seconds
3838
*/
3939
public function __construct($redisClient, float $initialTtl = 300.0)
4040
{
41-
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client && !$redisClient instanceof RedisProxy) {
42-
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)));
41+
if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) {
42+
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)));
4343
}
4444

4545
if ($initialTtl <= 0) {
@@ -149,11 +149,11 @@ private function evaluate(string $script, string $resource, array $args)
149149
return $this->redis->_instance($this->redis->_target($resource))->eval($script, array_merge([$resource], $args), 1);
150150
}
151151

152-
if ($this->redis instanceof \Predis\Client) {
152+
if ($this->redis instanceof \Predis\ClientInterface) {
153153
return $this->redis->eval(...array_merge([$script, 1, $resource], $args));
154154
}
155155

156-
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)));
156+
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)));
157157
}
158158

159159
private function getUniqueToken(Key $key): string

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
class StoreFactory
2626
{
2727
/**
28-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|\Memcached|\Zookeeper|string $connection Connection or DSN or Store short name
28+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|\Memcached|\Zookeeper|string $connection Connection or DSN or Store short name
2929
*
3030
* @return PersistingStoreInterface
3131
*/
@@ -35,7 +35,7 @@ public static function createStore($connection)
3535
$connection instanceof \Redis ||
3636
$connection instanceof \RedisArray ||
3737
$connection instanceof \RedisCluster ||
38-
$connection instanceof \Predis\Client ||
38+
$connection instanceof \Predis\ClientInterface ||
3939
$connection instanceof RedisProxy ||
4040
$connection instanceof RedisClusterProxy
4141
) {

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

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

src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private function runWorker(ReceiverInterface $receiver, SymfonyStyle $io, bool $
185185

186186
$count = 0;
187187
try {
188-
$worker->run([], function (?Envelope $envelope) use ($worker, $io, &$count) {
188+
$worker->run([], function (?Envelope $envelope) use ($worker, &$count) {
189189
++$count;
190190
if (null === $envelope) {
191191
$worker->stop();

src/Symfony/Component/Messenger/Tests/WorkerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public function testWorkerWithDecorator()
378378
$worker = new Worker([$receiver], $bus);
379379
$workerWithDecorator = new StopWhenMessageCountIsExceededWorker($worker, 2);
380380
$processedEnvelopes = [];
381-
$workerWithDecorator->run([], function (?Envelope $envelope) use ($worker, &$processedEnvelopes) {
381+
$workerWithDecorator->run([], function (?Envelope $envelope) use (&$processedEnvelopes) {
382382
if (null !== $envelope) {
383383
$processedEnvelopes[] = $envelope;
384384
}

src/Symfony/Component/Mime/Header/ParameterizedHeader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $name, string $value, array $parameters = [])
3636
$this->setParameter($k, $v);
3737
}
3838

39-
if ('content-disposition' === strtolower($name)) {
39+
if ('content-type' !== strtolower($name)) {
4040
$this->encoder = new Rfc2231Encoder();
4141
}
4242
}

0 commit comments

Comments
 (0)
0