diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index eec459b795..6876e3389f 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -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; } - - 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) diff --git a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php index 9d3931d1f4..5c49f7afe1 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisAdapter.php @@ -19,9 +19,9 @@ class RedisAdapter extends AbstractAdapter use RedisTrait; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client - * @param string $namespace The default namespace - * @param int $defaultLifetime The default lifetime + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client + * @param string $namespace The default namespace + * @param int $defaultLifetime The default lifetime */ public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) { diff --git a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php index 94a6ce5140..71230ad69b 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php @@ -68,9 +68,9 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter private $redisServerSupportSPOP = null; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client - * @param string $namespace The default namespace - * @param int $defaultLifetime The default lifetime + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client + * @param string $namespace The default namespace + * @param int $defaultLifetime The default lifetime * * @throws \Symfony\Component\Cache\Exception\LogicException If phpredis with version lower than 3.1.3. */ @@ -79,7 +79,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'); } } @@ -138,7 +138,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) { diff --git a/src/Symfony/Component/Cache/Simple/RedisCache.php b/src/Symfony/Component/Cache/Simple/RedisCache.php index a5f1bee69a..9655a753e1 100644 --- a/src/Symfony/Component/Cache/Simple/RedisCache.php +++ b/src/Symfony/Component/Cache/Simple/RedisCache.php @@ -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) { diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 56581ab549..f3e7a072d4 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -46,7 +46,7 @@ trait RedisTrait private $marshaller; /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient + * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient */ private function init($redisClient, string $namespace, int $defaultLifetime, ?MarshallerInterface $marshaller) { @@ -55,8 +55,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(); @@ -77,7 +77,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 = []) { @@ -248,7 +248,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'; if (isset($params['redis_sentinel'])) { @@ -283,7 +283,7 @@ trait RedisTrait $redis->getConnection()->setSentinelTimeout($params['timeout']); } } 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)); } @@ -302,7 +302,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]; @@ -335,7 +335,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]; @@ -360,7 +360,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]; @@ -383,7 +383,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]; @@ -427,7 +427,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 @@ -436,7 +436,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); @@ -477,7 +477,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 = []; diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index d12bfc6b57..42e0a28530 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -715,7 +715,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 a652671c37..4b8f78a1c5 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/Question/QuestionTest.php b/src/Symfony/Component/Console/Tests/Question/QuestionTest.php index 59b714291a..5da76062c6 100644 --- a/src/Symfony/Component/Console/Tests/Question/QuestionTest.php +++ b/src/Symfony/Component/Console/Tests/Question/QuestionTest.php @@ -140,7 +140,7 @@ class QuestionTest extends TestCase { return [ ['Potato'], - [new \stdclass()], + [new \stdClass()], [false], ]; } diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index e8a92c7297..d48126cbe9 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/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index 752e58f73f..40c209341e 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -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 * * @throws \InvalidArgumentException When unsupported client or options are passed */ @@ -44,11 +44,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'])) { diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php index 96faaedd80..c37122fbf2 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; @@ -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 diff --git a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php index 44d49432b4..fbdcefc15e 100644 --- a/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php +++ b/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.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; @@ -19,6 +19,7 @@ use Symfony\Component\Ldap\Exception\AlreadyExistsException; 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 diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 74984699c6..d8c382579c 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -33,13 +33,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, 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) { @@ -149,11 +149,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 diff --git a/src/Symfony/Component/Lock/Store/StoreFactory.php b/src/Symfony/Component/Lock/Store/StoreFactory.php index 443aa4874c..db354afd8a 100644 --- a/src/Symfony/Component/Lock/Store/StoreFactory.php +++ b/src/Symfony/Component/Lock/Store/StoreFactory.php @@ -25,7 +25,7 @@ use Symfony\Component\Lock\PersistingStoreInterface; 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 PersistingStoreInterface */ @@ -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 ) { diff --git a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php index e05b7d4c3f..d479a0e7c3 100644 --- a/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/AbstractRedisStoreTest.php @@ -32,7 +32,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(); diff --git a/src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php b/src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php index 8b0f4d72a1..a3957ed541 100644 --- a/src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php +++ b/src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php @@ -185,7 +185,7 @@ EOF $count = 0; try { - $worker->run([], function (?Envelope $envelope) use ($worker, $io, &$count) { + $worker->run([], function (?Envelope $envelope) use ($worker, &$count) { ++$count; if (null === $envelope) { $worker->stop(); diff --git a/src/Symfony/Component/Messenger/Tests/WorkerTest.php b/src/Symfony/Component/Messenger/Tests/WorkerTest.php index 8c8e54dda9..ad7477253e 100644 --- a/src/Symfony/Component/Messenger/Tests/WorkerTest.php +++ b/src/Symfony/Component/Messenger/Tests/WorkerTest.php @@ -378,7 +378,7 @@ class WorkerTest extends TestCase $worker = new Worker([$receiver], $bus); $workerWithDecorator = new StopWhenMessageCountIsExceededWorker($worker, 2); $processedEnvelopes = []; - $workerWithDecorator->run([], function (?Envelope $envelope) use ($worker, &$processedEnvelopes) { + $workerWithDecorator->run([], function (?Envelope $envelope) use (&$processedEnvelopes) { if (null !== $envelope) { $processedEnvelopes[] = $envelope; } diff --git a/src/Symfony/Component/Mime/Header/ParameterizedHeader.php b/src/Symfony/Component/Mime/Header/ParameterizedHeader.php index 2eeb079657..d8e50011fa 100644 --- a/src/Symfony/Component/Mime/Header/ParameterizedHeader.php +++ b/src/Symfony/Component/Mime/Header/ParameterizedHeader.php @@ -36,7 +36,7 @@ final class ParameterizedHeader extends UnstructuredHeader $this->setParameter($k, $v); } - if ('content-disposition' === strtolower($name)) { + if ('content-type' !== strtolower($name)) { $this->encoder = new Rfc2231Encoder(); } } diff --git a/src/Symfony/Component/Mime/Tests/Header/ParameterizedHeaderTest.php b/src/Symfony/Component/Mime/Tests/Header/ParameterizedHeaderTest.php index aa8265814b..e41d03857d 100644 --- a/src/Symfony/Component/Mime/Tests/Header/ParameterizedHeaderTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/ParameterizedHeaderTest.php @@ -205,16 +205,25 @@ class ParameterizedHeaderTest extends TestCase $header = new ParameterizedHeader('X-Foo', $value); $header->setCharset('iso-8859-1'); $header->setParameters(['says' => $value]); - $this->assertEquals('X-Foo: =?'.$header->getCharset().'?Q?fo=8Fbar?=; says="=?'.$header->getCharset().'?Q?fo=8Fbar?="', $header->toString()); + $this->assertEquals('X-Foo: =?'.$header->getCharset().'?Q?fo=8Fbar?=; says*='.$header->getCharset()."''fo%8Fbar", $header->toString()); } - public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() + public function testParamsAreEncodedIfNonAscii() { $value = 'fo'.pack('C', 0x8F).'bar'; $header = new ParameterizedHeader('X-Foo', 'bar'); $header->setCharset('iso-8859-1'); $header->setParameters(['says' => $value]); - $this->assertEquals('X-Foo: bar; says="=?'.$header->getCharset().'?Q?fo=8Fbar?="', $header->toString()); + $this->assertEquals('X-Foo: bar; says*='.$header->getCharset()."''fo%8Fbar", $header->toString()); + } + + public function testParamsAreEncodedWithLegacyEncodingEnabled() + { + $value = 'fo'.pack('C', 0x8F).'bar'; + $header = new ParameterizedHeader('Content-Type', 'bar'); + $header->setCharset('iso-8859-1'); + $header->setParameters(['says' => $value]); + $this->assertEquals('Content-Type: bar; says="=?'.$header->getCharset().'?Q?fo=8Fbar?="', $header->toString()); } public function testLanguageInformationAppearsInEncodedWords() @@ -234,6 +243,18 @@ class ParameterizedHeaderTest extends TestCase tag. For example: From: =?US-ASCII*EN?Q?Keith_Moore?= + + -- RFC 2047, 5. Use of encoded-words in message headers + ... + + An 'encoded-word' MUST NOT be used in parameter of a MIME + Content-Type or Content-Disposition field, or in any structured + field body except within a 'comment' or 'phrase'. + + -- RFC 2047, Appendix - changes since RFC 1522 + ... + + clarify that encoded-words are allowed in '*text' fields in both + RFC822 headers and MIME body part headers, but NOT as parameter + values. */ $value = 'fo'.pack('C', 0x8F).'bar'; @@ -241,7 +262,7 @@ class ParameterizedHeaderTest extends TestCase $header->setCharset('iso-8859-1'); $header->setLanguage('en'); $header->setParameters(['says' => $value]); - $this->assertEquals('X-Foo: =?'.$header->getCharset().'*en?Q?fo=8Fbar?=; says="=?'.$header->getCharset().'*en?Q?fo=8Fbar?="', $header->toString()); + $this->assertEquals('X-Foo: =?'.$header->getCharset().'*en?Q?fo=8Fbar?=; says*='.$header->getCharset()."'en'fo%8Fbar", $header->toString()); } public function testSetBody() diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index a5cf951564..308741c7e2 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/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 2177180f4d..085eee0ee0 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Routing\Matcher\Dumper; -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use "CompiledUrlMatcherDumper" instead.', PhpMatcherDumper::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "CompiledUrlMatcherDumper" instead.', PhpMatcherDumper::class), E_USER_DEPRECATED); /** * PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes. diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index 5500406828..4759cf579b 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/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php index 7cd51ce21e..08d4873c28 100644 --- a/src/Symfony/Component/Security/Http/Firewall.php +++ b/src/Symfony/Component/Security/Http/Firewall.php @@ -138,7 +138,7 @@ class Firewall implements EventSubscriberInterface if (\is_callable($listener)) { $listener($event); } else { - @trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, implement "__invoke()" instead.', \get_class($this)), E_USER_DEPRECATED); + @trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, implement "__invoke()" instead.', \get_class($listener)), E_USER_DEPRECATED); $listener->handle($event); } diff --git a/src/Symfony/Component/Security/Http/Firewall/LegacyListenerTrait.php b/src/Symfony/Component/Security/Http/Firewall/LegacyListenerTrait.php index 98933e0f3e..260cb680e0 100644 --- a/src/Symfony/Component/Security/Http/Firewall/LegacyListenerTrait.php +++ b/src/Symfony/Component/Security/Http/Firewall/LegacyListenerTrait.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Security\Http\Firewall; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index e3db00cb00..36842713f8 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -109,7 +109,7 @@ class SwitchUserListenerTest extends TestCase public function testExitUserBasedOnSwitchUserRoleUpdatesToken() { $originalToken = new UsernamePasswordToken('username', '', 'key', []); - $this->tokenStorage->setToken(new UsernamePasswordToken('username', '', 'key', [new SwitchUserRole('ROLE_PREVIOUS', $originalToken, false)], $originalToken)); + $this->tokenStorage->setToken(new UsernamePasswordToken('username', '', 'key', [new SwitchUserRole('ROLE_PREVIOUS', $originalToken, false)])); $this->request->query->set('_switch_user', SwitchUserListener::EXIT_VALUE); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php index 0676490fc0..b978777084 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 78914ae91e..b71d4fc490 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 4bebc5dce8..166629b36c 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): bool { return false; diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php index 70b8be1689..d3409a67b1 100644 --- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php +++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php @@ -94,7 +94,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');