From ea8af453ccf14e24a6cb2fcc3ece5814cbcc0ff4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 21 Jan 2020 13:29:51 +0100 Subject: [PATCH 001/266] updated VERSION for 3.4.37 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4f5a8da7fe..463b49174f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.37-DEV'; + const VERSION = '3.4.37'; const VERSION_ID = 30437; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 37; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 97ffadc705cf607360373f3d09feb89f7f56a558 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 21 Jan 2020 14:12:52 +0100 Subject: [PATCH 002/266] bumped Symfony version to 3.4.38 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 463b49174f..87f102a0fb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.37'; - const VERSION_ID = 30437; + const VERSION = '3.4.38-DEV'; + const VERSION_ID = 30438; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 37; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 38; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From fe7ab3c0abc04784a4f7ab511a6d876bc81cb4d4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 21 Jan 2020 14:13:44 +0100 Subject: [PATCH 003/266] updated VERSION for 4.3.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 2f7669e5c3..9c31bbbd3f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.3.10-DEV'; + const VERSION = '4.3.10'; const VERSION_ID = 40310; const MAJOR_VERSION = 4; const MINOR_VERSION = 3; const RELEASE_VERSION = 10; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2020'; const END_OF_LIFE = '07/2020'; From 896f0f6556799a244a5bee0f5723ec307d3d8330 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 21 Jan 2020 14:21:51 +0100 Subject: [PATCH 004/266] bumped Symfony version to 4.3.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9c31bbbd3f..c91a5cbacf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.3.10'; - const VERSION_ID = 40310; + const VERSION = '4.3.11-DEV'; + const VERSION_ID = 40311; const MAJOR_VERSION = 4; const MINOR_VERSION = 3; - const RELEASE_VERSION = 10; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 11; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2020'; const END_OF_LIFE = '07/2020'; From f3b87451504e3ee8cd881cf2a83013ef67c5e90b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 21 Jan 2020 14:29:15 +0100 Subject: [PATCH 005/266] bumped Symfony version to 4.4.4 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 91b10b3228..434e6b55ba 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.3'; - const VERSION_ID = 40403; + const VERSION = '4.4.4-DEV'; + const VERSION_ID = 40404; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 3; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 4; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 5520e6471f63d0a0c4cc818689a967be5e3639c3 Mon Sep 17 00:00:00 2001 From: Sjoerd Adema Date: Tue, 21 Jan 2020 17:49:30 +0100 Subject: [PATCH 006/266] [HttpKernel] Check if lock can be released Make sure the `$cache->release()` method exists before executing it. --- Kernel.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index 434e6b55ba..7650257963 100644 --- a/Kernel.php +++ b/Kernel.php @@ -634,7 +634,10 @@ public function release() } $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - $cache->release(); + if (method_exists($cache, 'release')) { + $cache->release(); + } + $this->container = require $cachePath; $this->container->set('kernel', $this); From 84023e41c84e2fc54f0212dfe72103ee3bf5de56 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 10 Jan 2020 23:18:38 +0000 Subject: [PATCH 007/266] =?UTF-8?q?[HttpKernel]=C2=A0Fix=20stale-if-error?= =?UTF-8?q?=20behavior,=20add=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpCache/HttpCache.php | 30 +++++- Tests/HttpCache/HttpCacheTest.php | 162 ++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 3 deletions(-) diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index da60e74642..3471758525 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -452,13 +452,37 @@ protected function forward(Request $request, $catch = false, Response $entry = n // always a "master" request (as the real master request can be in cache) $response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $catch); - // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC - if (null !== $entry && \in_array($response->getStatusCode(), [500, 502, 503, 504])) { + /* + * Support stale-if-error given on Responses or as a config option. + * RFC 7234 summarizes in Section 4.2.4 (but also mentions with the individual + * Cache-Control directives) that + * + * A cache MUST NOT generate a stale response if it is prohibited by an + * explicit in-protocol directive (e.g., by a "no-store" or "no-cache" + * cache directive, a "must-revalidate" cache-response-directive, or an + * applicable "s-maxage" or "proxy-revalidate" cache-response-directive; + * see Section 5.2.2). + * + * https://tools.ietf.org/html/rfc7234#section-4.2.4 + * + * We deviate from this in one detail, namely that we *do* serve entries in the + * stale-if-error case even if they have a `s-maxage` Cache-Control directive. + */ + if (null !== $entry + && \in_array($response->getStatusCode(), [500, 502, 503, 504]) + && !$entry->headers->hasCacheControlDirective('no-cache') + && !$entry->mustRevalidate() + ) { if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { $age = $this->options['stale_if_error']; } - if (abs($entry->getTtl()) < $age) { + /* + * stale-if-error gives the (extra) time that the Response may be used *after* it has become stale. + * So we compare the time the $entry has been sitting in the cache already with the + * time it was fresh plus the allowed grace period. + */ + if ($entry->getAge() <= $entry->getMaxAge() + $age) { $this->record($request, 'stale-if-error'); return $entry; diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index ef201de6cf..cac06a80e5 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -1523,6 +1523,168 @@ public function testUsesOriginalRequestForSurrogate() // Surrogate request $cache->handle($request, HttpKernelInterface::SUB_REQUEST); } + + public function testStaleIfErrorMustNotResetLifetime() + { + // Make sure we don't accidentally treat the response as fresh (revalidated) again + // when stale-if-error handling kicks in. + + $responses = [ + [ + 'status' => 200, + 'body' => 'OK', + // This is cacheable and can be used in stale-if-error cases: + 'headers' => ['Cache-Control' => 'public, max-age=10', 'ETag' => 'some-etag'], + ], + [ + 'status' => 500, + 'body' => 'FAIL', + 'headers' => [], + ], + [ + 'status' => 500, + 'body' => 'FAIL', + 'headers' => [], + ], + ]; + + $this->setNextResponses($responses); + $this->cacheConfig['stale_if_error'] = 10; + + $this->request('GET', '/'); // warm cache + + sleep(15); // now the entry is stale, but still within the grace period (10s max-age + 10s stale-if-error) + + $this->request('GET', '/'); // hit backend error + $this->assertEquals(200, $this->response->getStatusCode()); // stale-if-error saved the day + $this->assertEquals(15, $this->response->getAge()); + + sleep(10); // now we're outside the grace period + + $this->request('GET', '/'); // hit backend error + $this->assertEquals(500, $this->response->getStatusCode()); // fail + } + + /** + * @dataProvider getResponseDataThatMayBeServedStaleIfError + */ + public function testResponsesThatMayBeUsedStaleIfError($responseHeaders, $sleepBetweenRequests = null) + { + $responses = [ + [ + 'status' => 200, + 'body' => 'OK', + 'headers' => $responseHeaders, + ], + [ + 'status' => 500, + 'body' => 'FAIL', + 'headers' => [], + ], + ]; + + $this->setNextResponses($responses); + $this->cacheConfig['stale_if_error'] = 10; // after stale, may be served for 10s + + $this->request('GET', '/'); // warm cache + + if ($sleepBetweenRequests) { + sleep($sleepBetweenRequests); + } + + $this->request('GET', '/'); // hit backend error + + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertEquals('OK', $this->response->getContent()); + $this->assertTraceContains('stale-if-error'); + } + + public function getResponseDataThatMayBeServedStaleIfError() + { + // All data sets assume that a 10s stale-if-error grace period has been configured + yield 'public, max-age expired' => [['Cache-Control' => 'public, max-age=60'], 65]; + yield 'public, validateable with ETag, no TTL' => [['Cache-Control' => 'public', 'ETag' => 'some-etag'], 5]; + yield 'public, validateable with Last-Modified, no TTL' => [['Cache-Control' => 'public', 'Last-Modified' => 'yesterday'], 5]; + yield 'public, s-maxage will be served stale-if-error, even if the RFC mandates otherwise' => [['Cache-Control' => 'public, s-maxage=20'], 25]; + } + + /** + * @dataProvider getResponseDataThatMustNotBeServedStaleIfError + */ + public function testResponsesThatMustNotBeUsedStaleIfError($responseHeaders, $sleepBetweenRequests = null) + { + $responses = [ + [ + 'status' => 200, + 'body' => 'OK', + 'headers' => $responseHeaders, + ], + [ + 'status' => 500, + 'body' => 'FAIL', + 'headers' => [], + ], + ]; + + $this->setNextResponses($responses); + $this->cacheConfig['stale_if_error'] = 10; // after stale, may be served for 10s + $this->cacheConfig['strict_smaxage'] = true; // full RFC compliance for this feature + + $this->request('GET', '/'); // warm cache + + if ($sleepBetweenRequests) { + sleep($sleepBetweenRequests); + } + + $this->request('GET', '/'); // hit backend error + + $this->assertEquals(500, $this->response->getStatusCode()); + } + + public function getResponseDataThatMustNotBeServedStaleIfError() + { + // All data sets assume that a 10s stale-if-error grace period has been configured + yield 'public, no TTL but beyond grace period' => [['Cache-Control' => 'public'], 15]; + yield 'public, validateable with ETag, no TTL but beyond grace period' => [['Cache-Control' => 'public', 'ETag' => 'some-etag'], 15]; + yield 'public, validateable with Last-Modified, no TTL but beyond grace period' => [['Cache-Control' => 'public', 'Last-Modified' => 'yesterday'], 15]; + yield 'public, stale beyond grace period' => [['Cache-Control' => 'public, max-age=10'], 30]; + + // Cache-control values that prohibit serving stale responses or responses without positive validation - + // see https://tools.ietf.org/html/rfc7234#section-4.2.4 and + // https://tools.ietf.org/html/rfc7234#section-5.2.2 + yield 'no-cache requires positive validation' => [['Cache-Control' => 'public, no-cache', 'ETag' => 'some-etag']]; + yield 'no-cache requires positive validation, even if fresh' => [['Cache-Control' => 'public, no-cache, max-age=10']]; + yield 'must-revalidate requires positive validation once stale' => [['Cache-Control' => 'public, max-age=10, must-revalidate'], 15]; + yield 'proxy-revalidate requires positive validation once stale' => [['Cache-Control' => 'public, max-age=10, proxy-revalidate'], 15]; + } + + public function testStaleIfErrorWhenStrictSmaxageDisabled() + { + $responses = [ + [ + 'status' => 200, + 'body' => 'OK', + 'headers' => ['Cache-Control' => 'public, s-maxage=20'], + ], + [ + 'status' => 500, + 'body' => 'FAIL', + 'headers' => [], + ], + ]; + + $this->setNextResponses($responses); + $this->cacheConfig['stale_if_error'] = 10; + $this->cacheConfig['strict_smaxage'] = false; + + $this->request('GET', '/'); // warm cache + sleep(25); + $this->request('GET', '/'); // hit backend error + + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertEquals('OK', $this->response->getContent()); + $this->assertTraceContains('stale-if-error'); + } } class TestKernel implements HttpKernelInterface From 62116a9c8fb15faabb158ad9cb785c353c2572e5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 31 Jan 2020 13:45:06 +0100 Subject: [PATCH 008/266] updated VERSION for 4.4.4 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7650257963..828ba08406 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.4-DEV'; + const VERSION = '4.4.4'; const VERSION_ID = 40404; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 4; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From c0fd81ae429344ae848c9c763b8d742a7da1044f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 31 Jan 2020 13:48:55 +0100 Subject: [PATCH 009/266] bumped Symfony version to 4.4.5 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 828ba08406..d6c3976e4d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.4'; - const VERSION_ID = 40404; + const VERSION = '4.4.5-DEV'; + const VERSION_ID = 40405; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 4; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 5; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From de64b09dcafb81019f6b6dc01b42a02d877fe04a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Feb 2020 09:03:00 +0100 Subject: [PATCH 010/266] Fix CS --- Kernel.php | 6 +++--- Log/Logger.php | 2 +- Tests/Controller/ContainerControllerResolverTest.php | 2 +- Tests/DataCollector/RequestDataCollectorTest.php | 2 +- Tests/Log/LoggerTest.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Kernel.php b/Kernel.php index 87f102a0fb..82930d8c27 100644 --- a/Kernel.php +++ b/Kernel.php @@ -236,7 +236,7 @@ public function getBundle($name, $first = true/*, $noDeprecation = false */) } if (!isset($this->bundleMap[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, \get_class($this))); + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, static::class)); } if (true === $first) { @@ -583,7 +583,7 @@ protected function initializeContainer() $oldContainer = null; if ($fresh = $cache->isFresh()) { // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors - $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); + $errorLevel = error_reporting(E_ALL ^ E_WARNING); $fresh = $oldContainer = false; try { if (file_exists($cache->getPath()) && \is_object($this->container = include $cache->getPath())) { @@ -651,7 +651,7 @@ protected function initializeContainer() } if (null === $oldContainer && file_exists($cache->getPath())) { - $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); + $errorLevel = error_reporting(E_ALL ^ E_WARNING); try { $oldContainer = include $cache->getPath(); } catch (\Throwable $e) { diff --git a/Log/Logger.php b/Log/Logger.php index 50cbcd428f..f490293a62 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -105,6 +105,6 @@ private function format($level, $message, array $context) $message = strtr($message, $replacements); } - return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).\PHP_EOL; + return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).PHP_EOL; } } diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index bdb2a00f4b..97d21e95a4 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -39,7 +39,7 @@ public function testGetControllerService() $controller = $resolver->getController($request); - $this->assertInstanceOf(\get_class($this), $controller[0]); + $this->assertInstanceOf(static::class, $controller[0]); $this->assertSame('controllerMethod1', $controller[1]); } diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 9b6264be39..38979bba72 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -99,7 +99,7 @@ public function provideControllerCallables() '"Regular" callable', [$this, 'testControllerInspection'], [ - 'class' => RequestDataCollectorTest::class, + 'class' => self::class, 'method' => 'testControllerInspection', 'file' => __FILE__, 'line' => $r1->getStartLine(), diff --git a/Tests/Log/LoggerTest.php b/Tests/Log/LoggerTest.php index 7439ae1376..79039c1c97 100644 --- a/Tests/Log/LoggerTest.php +++ b/Tests/Log/LoggerTest.php @@ -186,7 +186,7 @@ public function testContextExceptionKeyCanBeExceptionOrOtherValues() public function testFormatter() { $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile, function ($level, $message, $context) { - return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).\PHP_EOL; + return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).PHP_EOL; }); $this->logger->error('An error', ['foo' => 'bar']); From 29ec9509e0b6d01d9685800eaff9df925c891906 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Feb 2020 10:29:10 +0100 Subject: [PATCH 011/266] Fix CS --- Kernel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel.php b/Kernel.php index d6c3976e4d..b124ebe634 100644 --- a/Kernel.php +++ b/Kernel.php @@ -228,7 +228,7 @@ public function getBundles() public function getBundle($name) { if (!isset($this->bundles[$name])) { - $class = \get_class($this); + $class = static::class; $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class; throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, $class)); @@ -473,7 +473,7 @@ protected function build(ContainerBuilder $container) */ protected function getContainerClass() { - $class = \get_class($this); + $class = static::class; $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = $this->name.str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; @@ -510,7 +510,7 @@ protected function initializeContainer() $cachePath = $cache->getPath(); // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors - $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); + $errorLevel = error_reporting(E_ALL ^ E_WARNING); try { if (file_exists($cachePath) && \is_object($this->container = include $cachePath) From 0bb63672cb24bbbb76b46d3ffecd396fdf44f918 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 14 Feb 2020 11:01:23 +0100 Subject: [PATCH 012/266] [HttpKernel] fix registering DebugHandlersListener regardless of the PHP_SAPI --- EventListener/DebugHandlersListener.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index df9df09c0b..957a3cdb0f 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -65,6 +65,9 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ */ public function configure(Event $event = null) { + if ($event instanceof ConsoleEvent && !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) { + return; + } if (!$event instanceof KernelEvent ? !$this->firstCall : !$event->isMasterRequest()) { return; } @@ -148,7 +151,7 @@ public static function getSubscribedEvents() { $events = [KernelEvents::REQUEST => ['configure', 2048]]; - if ('cli' === \PHP_SAPI && \defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { + if (\defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { $events[ConsoleEvents::COMMAND] = ['configure', 2048]; } From 162863821be88d908d51db9b76162ac6613c8b32 Mon Sep 17 00:00:00 2001 From: Daniel Gorgan Date: Fri, 14 Feb 2020 17:15:50 +0200 Subject: [PATCH 013/266] Set previous exception when rethrown from controller resolver --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index c981642fee..619628b5c7 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -88,7 +88,7 @@ public function getController(Request $request) try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage())); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()), 0, $e); } return $callable; From 449c3f7a9b8c47d178f80610afa6e2873ac0a3c0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:16:41 +0100 Subject: [PATCH 014/266] updated VERSION for 3.4.38 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 82930d8c27..1c85a2b08f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.38-DEV'; + const VERSION = '3.4.38'; const VERSION_ID = 30438; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 38; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From ec8ae13f7fc4b7bccb5dc9788888c9df5c8987ac Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:30:13 +0100 Subject: [PATCH 015/266] bumped Symfony version to 3.4.39 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1c85a2b08f..4ef763e486 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.38'; - const VERSION_ID = 30438; + const VERSION = '3.4.39-DEV'; + const VERSION_ID = 30439; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 38; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 39; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 8c8734486dada83a6041ab744709bdc1651a8462 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:31:38 +0100 Subject: [PATCH 016/266] updated VERSION for 4.4.5 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b124ebe634..0b21ee8996 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.5-DEV'; + const VERSION = '4.4.5'; const VERSION_ID = 40405; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 5; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 43fbae22dbc48de3354ae3014465bbc8d6cb3b10 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:35:30 +0100 Subject: [PATCH 017/266] bumped Symfony version to 4.4.6 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0b21ee8996..281c161b38 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.5'; - const VERSION_ID = 40405; + const VERSION = '4.4.6-DEV'; + const VERSION_ID = 40406; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 5; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 6; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 2f04b78a562590794d6081104218ff7b468e5d7a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 15 Mar 2020 10:01:00 +0100 Subject: [PATCH 018/266] Add missing dots at the end of exception messages --- Controller/ControllerResolver.php | 2 +- DataCollector/DumpDataCollector.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 2 +- Kernel.php | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 619628b5c7..4e11ac640b 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -88,7 +88,7 @@ public function getController(Request $request) try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()), 0, $e); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $e->getMessage()), 0, $e); } return $callable; diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 4266b22fec..7c32ec1001 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -217,7 +217,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format)); + throw new \InvalidArgumentException(sprintf('Invalid dump format: %s.', $format)); } $dumps = []; diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index f94a5c0760..4850e589da 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -57,7 +57,7 @@ public function __construct($templating = null, UriSigner $signer = null, $globa public function setTemplating($templating) { if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof Environment) { - throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface'); + throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface.'); } $this->templating = $templating; diff --git a/Kernel.php b/Kernel.php index 4ef763e486..a73788e1ec 100644 --- a/Kernel.php +++ b/Kernel.php @@ -493,7 +493,7 @@ protected function initializeBundles() foreach ($this->registerBundles() as $bundle) { $name = $bundle->getName(); if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name)); + throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s".', $name)); } $this->bundles[$name] = $bundle; @@ -762,10 +762,10 @@ protected function buildContainer() foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir)); + throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n.", $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir)); + throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n.", $name, $dir)); } } From 8e6b70bec54216981afb3354990be8a37d0a0ba2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 15 Mar 2020 11:08:38 +0100 Subject: [PATCH 019/266] Add missing dots at the end of exception messages --- Controller/ContainerControllerResolver.php | 2 +- Controller/ControllerResolver.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index 015eea91fa..7eb028de1f 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -64,7 +64,7 @@ protected function instantiateController($class) throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e); } - throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e); + throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e); } private function throwExceptionIfControllerWasRemoved(string $controller, \Throwable $previous) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index fd9a0accaf..feb69e54ac 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -64,7 +64,7 @@ public function getController(Request $request) } if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($controller))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($controller))); } return $controller; @@ -72,7 +72,7 @@ public function getController(Request $request) if (\is_object($controller)) { if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($controller))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($controller))); } return $controller; @@ -89,7 +89,7 @@ public function getController(Request $request) } if (!\is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($callable))); } return $callable; From d5b3a4b1d9a522dcd6ccca778dfe2cbf832e7de7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 08:32:23 +0100 Subject: [PATCH 020/266] Fix quotes in exception messages --- Bundle/Bundle.php | 2 +- CacheClearer/Psr6CacheClearer.php | 2 +- ControllerMetadata/ArgumentMetadata.php | 2 +- DataCollector/DumpDataCollector.php | 2 +- DependencyInjection/ResettableServicePass.php | 2 +- Fragment/FragmentHandler.php | 2 +- HttpCache/AbstractSurrogate.php | 2 +- Kernel.php | 6 +++--- Tests/CacheClearer/Psr6CacheClearerTest.php | 2 +- Tests/DependencyInjection/ResettableServicePassTest.php | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 5bbed6bef1..530a2749d1 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -70,7 +70,7 @@ public function getContainerExtension() if (null !== $extension) { if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', \get_class($extension))); + throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', \get_class($extension))); } // check naming convention diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index 42add5a686..4b4aafa163 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -40,7 +40,7 @@ public function hasPool($name) public function clearPool($name) { if (!isset($this->pools[$name])) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); + throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]->clear(); diff --git a/ControllerMetadata/ArgumentMetadata.php b/ControllerMetadata/ArgumentMetadata.php index 520e83b5fe..6df388d83a 100644 --- a/ControllerMetadata/ArgumentMetadata.php +++ b/ControllerMetadata/ArgumentMetadata.php @@ -107,7 +107,7 @@ public function isNullable() public function getDefaultValue() { if (!$this->hasDefaultValue) { - throw new \LogicException(sprintf('Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.', $this->name, __CLASS__)); + throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); } return $this->defaultValue; diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 7c32ec1001..280e1ddd08 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -217,7 +217,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s.', $format)); + throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format)); } $dumps = []; diff --git a/DependencyInjection/ResettableServicePass.php b/DependencyInjection/ResettableServicePass.php index 28136be625..51a518dc28 100644 --- a/DependencyInjection/ResettableServicePass.php +++ b/DependencyInjection/ResettableServicePass.php @@ -46,7 +46,7 @@ public function process(ContainerBuilder $container) $attributes = $tags[0]; if (!isset($attributes['method'])) { - throw new RuntimeException(sprintf('Tag %s requires the "method" attribute to be set.', $this->tagName)); + throw new RuntimeException(sprintf('Tag "%s" requires the "method" attribute to be set.', $this->tagName)); } $methods[$id] = $attributes['method']; diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 9629cf7066..b98b1779ad 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -100,7 +100,7 @@ public function render($uri, $renderer = 'inline', array $options = []) protected function deliver(Response $response) { if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); } if (!$response instanceof StreamedResponse) { diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 9b4541793f..472d87e483 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -96,7 +96,7 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); } return $response->getContent(); diff --git a/Kernel.php b/Kernel.php index a73788e1ec..9d1d42eb19 100644 --- a/Kernel.php +++ b/Kernel.php @@ -236,7 +236,7 @@ public function getBundle($name, $first = true/*, $noDeprecation = false */) } if (!isset($this->bundleMap[$name])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, static::class)); + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your "%s.php" file?', $name, static::class)); } if (true === $first) { @@ -762,10 +762,10 @@ protected function buildContainer() foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n.", $name, $dir)); + throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n.", $name, $dir)); + throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } diff --git a/Tests/CacheClearer/Psr6CacheClearerTest.php b/Tests/CacheClearer/Psr6CacheClearerTest.php index 2fbce41d1c..4d46c91762 100644 --- a/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -40,7 +40,7 @@ public function testClearPool() public function testClearPoolThrowsExceptionOnUnreferencedPool() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('Cache pool not found: unknown'); + $this->expectExceptionMessage('Cache pool not found: "unknown"'); (new Psr6CacheClearer())->clearPool('unknown'); } diff --git a/Tests/DependencyInjection/ResettableServicePassTest.php b/Tests/DependencyInjection/ResettableServicePassTest.php index d3c6869320..7ebe5dfb91 100644 --- a/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/Tests/DependencyInjection/ResettableServicePassTest.php @@ -51,7 +51,7 @@ public function testCompilerPass() public function testMissingMethod() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('Tag kernel.reset requires the "method" attribute to be set.'); + $this->expectExceptionMessage('Tag "kernel.reset" requires the "method" attribute to be set.'); $container = new ContainerBuilder(); $container->register(ResettableService::class) ->addTag('kernel.reset'); From eb80a94ddeb61d3409e29010910348c038d2da63 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 11:25:47 +0100 Subject: [PATCH 021/266] Fix quotes in exception messages --- CacheClearer/Psr6CacheClearer.php | 2 +- EventListener/TranslatorListener.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index f69740440e..f5670f1b97 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -31,7 +31,7 @@ public function hasPool($name) public function getPool($name) { if (!$this->hasPool($name)) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); + throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]; diff --git a/EventListener/TranslatorListener.php b/EventListener/TranslatorListener.php index d28eee2b1a..e276b3bd71 100644 --- a/EventListener/TranslatorListener.php +++ b/EventListener/TranslatorListener.php @@ -40,7 +40,7 @@ class TranslatorListener implements EventSubscriberInterface public function __construct($translator, RequestStack $requestStack) { if (!$translator instanceof TranslatorInterface && !$translator instanceof LocaleAwareInterface) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, LocaleAwareInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be an instance of "%s", "%s" given.', __METHOD__, LocaleAwareInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator))); } $this->translator = $translator; $this->requestStack = $requestStack; From 855cb1e24b77fd91dce760e3c981a6881c170f7d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 16:39:23 +0100 Subject: [PATCH 022/266] Fix more quotes in exception messages --- Controller/ArgumentResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index fc6f969a9e..9d5f96ed2c 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -56,7 +56,7 @@ public function getArguments(Request $request, $controller) $resolved = $resolver->resolve($request, $metadata); if (!$resolved instanceof \Generator) { - throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver))); + throw new \InvalidArgumentException(sprintf('"%s::resolve()" must yield at least one value.', \get_class($resolver))); } foreach ($resolved as $append) { From b3524e3e91d84dbcd011686386ffe4ba76461472 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 24 Sep 2019 13:01:54 +0200 Subject: [PATCH 023/266] [DI] fix preloading script generation --- HttpClientKernel.php | 3 +++ HttpKernel.php | 12 ++++++++++++ Kernel.php | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/HttpClientKernel.php b/HttpClientKernel.php index c8421a4b10..912ce313f8 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -21,6 +21,9 @@ use Symfony\Component\Mime\Part\TextPart; use Symfony\Contracts\HttpClient\HttpClientInterface; +// Help opcache.preload discover always-needed symbols +class_exists(ResponseHeaderBag::class); + /** * An implementation of a Symfony HTTP kernel using a "real" HTTP client. * diff --git a/HttpKernel.php b/HttpKernel.php index f1b601361e..681e96321d 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -33,6 +33,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +// Help opcache.preload discover always-needed symbols +class_exists(LegacyEventDispatcherProxy::class); +class_exists(ControllerArgumentsEvent::class); +class_exists(ControllerEvent::class); +class_exists(ExceptionEvent::class); +class_exists(FinishRequestEvent::class); +class_exists(RequestEvent::class); +class_exists(ResponseEvent::class); +class_exists(TerminateEvent::class); +class_exists(ViewEvent::class); +class_exists(KernelEvents::class); + /** * HttpKernel notifies events to convert a Request object to a Response one. * diff --git a/Kernel.php b/Kernel.php index 6c8f019c6e..d6f5a462d6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -38,6 +38,9 @@ use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; +// Help opcache.preload discover always-needed symbols +class_exists(ConfigCache::class); + /** * The Kernel is the heart of the Symfony system. * @@ -805,6 +808,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container 'as_files' => true, 'debug' => $this->debug, 'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(), + 'preload_classes' => array_map('get_class', $this->bundles), ]); $rootCode = array_pop($content); From 36c121cd45c1de6c3479ecb80e0534f366e1fe54 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 22 Mar 2020 21:08:25 +0100 Subject: [PATCH 024/266] [HttpKernel] fix locking for PHP 7.4+ --- Kernel.php | 56 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/Kernel.php b/Kernel.php index d6f5a462d6..958e049bf0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -38,9 +38,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; -// Help opcache.preload discover always-needed symbols -class_exists(ConfigCache::class); - /** * The Kernel is the heart of the Symfony system. * @@ -533,47 +530,20 @@ protected function initializeContainer() try { is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true); - if ($lock = fopen($cachePath, 'w')) { - chmod($cachePath, 0666 & ~umask()); + if ($lock = fopen($cachePath.'.lock', 'w')) { flock($lock, LOCK_EX | LOCK_NB, $wouldBlock); if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) { fclose($lock); - } else { - $cache = new class($cachePath, $this->debug) extends ConfigCache { - public $lock; - - public function write($content, array $metadata = null) - { - rewind($this->lock); - ftruncate($this->lock, 0); - fwrite($this->lock, $content); - - if (null !== $metadata) { - file_put_contents($this->getPath().'.meta', serialize($metadata)); - @chmod($this->getPath().'.meta', 0666 & ~umask()); - } - - if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) { - @opcache_invalidate($this->getPath(), true); - } - } - - public function release() - { - flock($this->lock, LOCK_UN); - fclose($this->lock); - } - }; - $cache->lock = $lock; - - if (!\is_object($this->container = include $cachePath)) { - $this->container = null; - } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { - $this->container->set('kernel', $this); - - return; - } + $lock = null; + } elseif (!\is_object($this->container = include $cachePath)) { + $this->container = null; + } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { + flock($lock, LOCK_UN); + fclose($lock); + $this->container->set('kernel', $this); + + return; } } } catch (\Throwable $e) { @@ -637,8 +607,10 @@ public function release() } $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - if (method_exists($cache, 'release')) { - $cache->release(); + + if ($lock) { + flock($lock, LOCK_UN); + fclose($lock); } $this->container = require $cachePath; From 8efac445a9d97261cf579faa5c7080049334c7c0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 25 Mar 2020 13:02:26 +0100 Subject: [PATCH 025/266] Fixed some typos --- Tests/Controller/ContainerControllerResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 97d21e95a4..b03169de93 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -229,7 +229,7 @@ public function testExceptionWhenUsingControllerWithoutAnInvokeMethod() */ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null) { - // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected excetion and not use the regex + // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected exception and not use the regex $resolver = $this->createControllerResolver(); $this->expectException($exceptionName); $this->expectExceptionMessageRegExp($exceptionMessage); From 02ee1d0d616b031fb48a1c9c3e5dc092dd7e448d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 27 Mar 2020 09:32:28 +0100 Subject: [PATCH 026/266] Update VERSION for 4.4.6 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 958e049bf0..a559f07288 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.6-DEV'; + const VERSION = '4.4.6'; const VERSION_ID = 40406; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 6; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From b1191954896d9d0f20f8080e35e77b96801e66f1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 27 Mar 2020 09:51:41 +0100 Subject: [PATCH 027/266] Bump Symfony version to 4.4.7 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a559f07288..dfbd1c82c8 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.6'; - const VERSION_ID = 40406; + const VERSION = '4.4.7-DEV'; + const VERSION_ID = 40407; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 6; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 7; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From d9df6c0ceb0862a3814d2434abb2a7a304ded675 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 27 Mar 2020 17:16:43 +0100 Subject: [PATCH 028/266] [HttpKernel][LoggerDataCollector] Prevent keys collisions in the sanitized logs processing --- DataCollector/LoggerDataCollector.php | 2 +- Tests/DataCollector/LoggerDataCollectorTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 99a9cf23e8..9c05daa36f 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -172,7 +172,7 @@ private function sanitizeLogs($logs) continue; } - $message = $log['message']; + $message = '_'.$log['message']; $exception = $log['context']['exception']; if ($exception instanceof SilencedErrorContext) { diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index 8b7fbe2a19..b46357ed55 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -132,13 +132,15 @@ public function getCollectTestData() [ ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], ['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], ], [ ['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], ['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], + ['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], ], 0, - 1, + 2, ]; } } From 17532445f689a2109122b0070d966d037a3db2d9 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 25 Mar 2020 22:25:16 +0100 Subject: [PATCH 029/266] add missing gitattributes for phpunit-bridge --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index ebb9287043..84c7add058 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ /Tests export-ignore /phpunit.xml.dist export-ignore +/.gitattributes export-ignore /.gitignore export-ignore From c15b5acab571224b1bf792692ff2ad63239081fe Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 08:25:13 +0200 Subject: [PATCH 030/266] updated VERSION for 3.4.39 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9d1d42eb19..7193c8b935 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.39-DEV'; + const VERSION = '3.4.39'; const VERSION_ID = 30439; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 39; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 73e886d8a9593b21e5fe4ff8db0d3bcec20be41f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 08:41:06 +0200 Subject: [PATCH 031/266] bumped Symfony version to 3.4.40 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7193c8b935..9422d90e9e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.39'; - const VERSION_ID = 30439; + const VERSION = '3.4.40-DEV'; + const VERSION_ID = 30440; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 39; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 40; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From f356a489e51856b99908005eb7f2c51a1dfc95dc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 16:59:15 +0200 Subject: [PATCH 032/266] updated VERSION for 4.4.7 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index dfbd1c82c8..89198bd7cf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.7-DEV'; + const VERSION = '4.4.7'; const VERSION_ID = 40407; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 7; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From aeaa78394daeacf6ea33ff30a160870c21bfa2ce Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 17:04:12 +0200 Subject: [PATCH 033/266] bumped Symfony version to 4.4.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 89198bd7cf..c583aa66d7 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.7'; - const VERSION_ID = 40407; + const VERSION = '4.4.8-DEV'; + const VERSION_ID = 40408; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 7; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 8; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 6cb4a212185e7ed65245fe2b1fd4f52a95d716be Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 4 Apr 2020 13:58:35 +0200 Subject: [PATCH 034/266] [HttpKernel][FrameworkBundle] fix compat with Debug component --- EventListener/DebugHandlersListener.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index dcb54ea891..0e672a299d 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Debug\ErrorHandler as LegacyErrorHandler; use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\ErrorHandler\ErrorHandler; use Symfony\Component\EventDispatcher\Event; @@ -79,7 +80,7 @@ public function configure(Event $event = null) restore_exception_handler(); if ($this->logger || null !== $this->throwAt) { - if ($handler instanceof ErrorHandler) { + if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { if ($this->logger) { $handler->setDefaultLogger($this->logger, $this->levels); if (\is_array($this->levels)) { @@ -138,7 +139,7 @@ public function configure(Event $event = null) } } if ($this->exceptionHandler) { - if ($handler instanceof ErrorHandler) { + if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { $handler->setExceptionHandler($this->exceptionHandler); } $this->exceptionHandler = null; From c0c5cf69726437a036c005a785558a140d8eb430 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 12 Apr 2020 11:28:02 +0200 Subject: [PATCH 035/266] silence E_NOTICE triggered since PHP 7.4 --- Log/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Log/Logger.php b/Log/Logger.php index f490293a62..e05d8c32ec 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -77,7 +77,7 @@ public function log($level, $message, array $context = []) } $formatter = $this->formatter; - fwrite($this->handle, $formatter($level, $message, $context)); + @fwrite($this->handle, $formatter($level, $message, $context)); } /** From 1b3c8e6cea7d9f48a2ab803b300aa4e2b6a9a5b8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Apr 2020 16:22:30 +0200 Subject: [PATCH 036/266] Tweak the code to avoid fabbot false positives --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 4e11ac640b..6244fdb9e5 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -88,7 +88,7 @@ public function getController(Request $request) try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $e->getMessage()), 0, $e); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e); } return $callable; From 01579a057c470714f7e9533568328149255d191a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Apr 2020 18:10:21 +0200 Subject: [PATCH 037/266] Tweak the code to avoid fabbot false positives --- Controller/ControllerResolver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 16a4a4a2e4..b3e21e5f26 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -64,7 +64,7 @@ public function getController(Request $request) } if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($controller))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$this->getControllerError($controller), $request->getPathInfo())); } return $controller; @@ -72,7 +72,7 @@ public function getController(Request $request) if (\is_object($controller)) { if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($controller))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$this->getControllerError($controller), $request->getPathInfo())); } return $controller; @@ -89,7 +89,7 @@ public function getController(Request $request) } if (!\is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($callable))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$this->getControllerError($callable), $request->getPathInfo())); } return $callable; From 5d4ba814f72b96fcfc3e733234b16d76aca18ca0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Apr 2020 18:39:58 +0200 Subject: [PATCH 038/266] Fix code --- Tests/Controller/ContainerControllerResolverTest.php | 2 +- Tests/Controller/ControllerResolverTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index b03169de93..4c4abf5aa4 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -248,7 +248,7 @@ public function getUndefinedControllers() [ 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar', \InvalidArgumentException::class, - '/.?[cC]ontroller(.*?) for URI "\/" is not callable\.( Expected method(.*) Available methods)?/', + '/.?[cC]ontroller(.*?) for URI "\/" is not callable:( Expected method(.*) Available methods)?/', ], ]; } diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index e34427a32e..d2684791fe 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -131,10 +131,10 @@ public function getUndefinedControllers() ['foo', 'InvalidArgumentException', 'Unable to find controller "foo".'], ['oof::bar', 'InvalidArgumentException', 'Class "oof" does not exist.'], ['stdClass', 'InvalidArgumentException', 'Unable to find controller "stdClass".'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::undefinedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::undefinedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'], ]; } From 139d477cc926de9ca03c3d59b51ab6e22450c6df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 19:41:38 +0200 Subject: [PATCH 039/266] updated VERSION for 3.4.40 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9422d90e9e..dc9cc048eb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.40-DEV'; + const VERSION = '3.4.40'; const VERSION_ID = 30440; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 40; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 1799a6c01f0db5851f399151abdb5d6393fec277 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 20:47:42 +0200 Subject: [PATCH 040/266] updated VERSION for 4.4.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c583aa66d7..9cb3a034d6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.8-DEV'; + const VERSION = '4.4.8'; const VERSION_ID = 40408; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 8; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 052e039bedd5c1201af0c981f155c1b8fef95a6c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 20:52:27 +0200 Subject: [PATCH 041/266] bumped Symfony version to 4.4.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9cb3a034d6..8349de676a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.8'; - const VERSION_ID = 40408; + const VERSION = '4.4.9-DEV'; + const VERSION_ID = 40409; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 8; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 9; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 7a6e6ca58dd89cff16488660c2885410a44f1c8e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 4 May 2020 16:41:05 +0200 Subject: [PATCH 042/266] Fix exception messages containing exception messages --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 6244fdb9e5..e3a7211c1b 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -88,7 +88,7 @@ public function getController(Request $request) try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e); } return $callable; From b9dcde9571b45ee7eac70faf634ae6c398ff8efe Mon Sep 17 00:00:00 2001 From: Marc Weistroff Date: Tue, 12 May 2020 14:07:21 +0200 Subject: [PATCH 043/266] Change priority of KernelEvents::RESPONSE subscriber --- EventListener/ProfilerListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index b8464f1627..fec89c3ed3 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -119,7 +119,7 @@ public function onKernelTerminate(PostResponseEvent $event) public static function getSubscribedEvents() { return [ - KernelEvents::RESPONSE => ['onKernelResponse', -100], + KernelEvents::RESPONSE => ['onKernelResponse', -1012], KernelEvents::EXCEPTION => ['onKernelException', 0], KernelEvents::TERMINATE => ['onKernelTerminate', -1024], ]; From 7d9b08c59456c61cbe0e768bddbefa55841c9812 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 16 May 2020 15:57:47 +0200 Subject: [PATCH 044/266] Revert "Change priority of KernelEvents::RESPONSE subscriber" This reverts commit 6ed624ad16d21a5daf8f0e132cbef53ff1e0de59. --- EventListener/ProfilerListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index fec89c3ed3..b8464f1627 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -119,7 +119,7 @@ public function onKernelTerminate(PostResponseEvent $event) public static function getSubscribedEvents() { return [ - KernelEvents::RESPONSE => ['onKernelResponse', -1012], + KernelEvents::RESPONSE => ['onKernelResponse', -100], KernelEvents::EXCEPTION => ['onKernelException', 0], KernelEvents::TERMINATE => ['onKernelTerminate', -1024], ]; From 238f49161af85e68700eb6379826ec2dc03cd9ab Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 18 May 2020 16:22:26 +0200 Subject: [PATCH 045/266] [HttpKernel] Fix error logger when stderr is redirected to /dev/null (FPM) --- Log/Logger.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Log/Logger.php b/Log/Logger.php index e05d8c32ec..bbdd101d7d 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -37,10 +37,10 @@ class Logger extends AbstractLogger private $formatter; private $handle; - public function __construct($minLevel = null, $output = 'php://stderr', callable $formatter = null) + public function __construct($minLevel = null, $output = null, callable $formatter = null) { if (null === $minLevel) { - $minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING; + $minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING; if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { @@ -58,7 +58,7 @@ public function __construct($minLevel = null, $output = 'php://stderr', callable $this->minLevelIndex = self::$levels[$minLevel]; $this->formatter = $formatter ?: [$this, 'format']; - if (false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { + if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); } } @@ -77,7 +77,11 @@ public function log($level, $message, array $context = []) } $formatter = $this->formatter; - @fwrite($this->handle, $formatter($level, $message, $context)); + if ($this->handle) { + @fwrite($this->handle, $formatter($level, $message, $context)); + } else { + error_log($formatter($level, $message, $context, false)); + } } /** @@ -86,7 +90,7 @@ public function log($level, $message, array $context = []) * * @return string */ - private function format($level, $message, array $context) + private function format($level, $message, array $context, $prefixDate = true) { if (false !== strpos($message, '{')) { $replacements = []; @@ -105,6 +109,11 @@ private function format($level, $message, array $context) $message = strtr($message, $replacements); } - return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).PHP_EOL; + $log = sprintf('[%s] %s', $level, $message).PHP_EOL; + if ($prefixDate) { + $log = date(\DateTime::RFC3339).' '.$log; + } + + return $log; } } From 00b5b7c0644d59354ce646179b5c1a45fa7f74db Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Sat, 16 May 2020 11:23:27 +0000 Subject: [PATCH 046/266] [HttpKernel] Fix that the `Store` would not save responses with the X-Content-Digest header present --- HttpCache/Store.php | 29 +++++++++++++++-------------- Tests/HttpCache/StoreTest.php | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index c831ba2ac3..fd04a7b23d 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -177,19 +177,15 @@ public function write(Request $request, Response $response) $key = $this->getCacheKey($request); $storedEnv = $this->persistRequest($request); - // write the response body to the entity store if this is the original response - if (!$response->headers->has('X-Content-Digest')) { - $digest = $this->generateContentDigest($response); + $digest = $this->generateContentDigest($response); + $response->headers->set('X-Content-Digest', $digest); - if (!$this->save($digest, $response->getContent())) { - throw new \RuntimeException('Unable to store the entity.'); - } - - $response->headers->set('X-Content-Digest', $digest); + if (!$this->save($digest, $response->getContent(), false)) { + throw new \RuntimeException('Unable to store the entity.'); + } - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', \strlen($response->getContent())); - } + if (!$response->headers->has('Transfer-Encoding')) { + $response->headers->set('Content-Length', \strlen($response->getContent())); } // read existing cache entries, remove non-varying, and add this one to the list @@ -362,15 +358,20 @@ private function load($key) /** * Save data for the given key. * - * @param string $key The store key - * @param string $data The data to store + * @param string $key The store key + * @param string $data The data to store + * @param bool $overwrite Whether existing data should be overwritten * * @return bool */ - private function save($key, $data) + private function save($key, $data, $overwrite = true) { $path = $this->getPath($key); + if (!$overwrite && file_exists($path)) { + return true; + } + if (isset($this->locks[$key])) { $fp = $this->locks[$key]; @ftruncate($fp, 0); diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 77cb34cfa5..07c4154269 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -97,6 +97,27 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring() $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); } + public function testDoesNotTrustXContentDigestFromUpstream() + { + $response = new Response('test', 200, ['X-Content-Digest' => 'untrusted-from-elsewhere']); + + $cacheKey = $this->store->write($this->request, $response); + $entries = $this->getStoreMetadata($cacheKey); + list(, $res) = $entries[0]; + + $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); + $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $response->headers->get('X-Content-Digest')); + } + + public function testWritesResponseEvenIfXContentDigestIsPresent() + { + // Prime the store + $this->store->write($this->request, new Response('test', 200, ['X-Content-Digest' => 'untrusted-from-elsewhere'])); + + $response = $this->store->lookup($this->request); + $this->assertNotNull($response); + } + public function testFindsAStoredEntryWithLookup() { $this->storeSimpleEntry(); From 2b5cb0043c3250e078fcd23679c6fca0e6aca11e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 May 2020 10:37:50 +0200 Subject: [PATCH 047/266] Use ">=" for the "php" requirement --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 14e1c64cc0..eca3b54b36 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": ">=7.1.3", "symfony/error-handler": "^4.4", "symfony/event-dispatcher": "^4.4", "symfony/http-foundation": "^4.4|^5.0", From 34db0698fe3fbcf53ebe1df127e820a028268c5c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 May 2020 13:30:55 +0200 Subject: [PATCH 048/266] Address deprecation of ReflectionType::getClass(). --- Controller/ControllerResolver.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index e3a7211c1b..688d574ceb 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -136,7 +136,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete } else { $arguments[] = $attributes[$param->name]; } - } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { + } elseif ($this->typeMatchesRequestClass($param, $request)) { $arguments[] = $request; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); @@ -260,4 +260,22 @@ private function getControllerError($callable) return $message; } + + /** + * @return bool + */ + private function typeMatchesRequestClass(\ReflectionParameter $param, Request $request) + { + if (!method_exists($param, 'getType')) { + return $param->getClass() && $param->getClass()->isInstance($request); + } + + if (!($type = $param->getType()) || $type->isBuiltin()) { + return false; + } + + $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type); + + return $class && $class->isInstance($request); + } } From 5b389af7f40a3ce704145b7c719d66bc3a401d48 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 15:23:31 +0200 Subject: [PATCH 049/266] [HttpKernel] Prevent calling method_exists() with non-string values. --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index e3a7211c1b..e01c725454 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -77,7 +77,7 @@ public function getController(Request $request) throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', \get_class($controller), $request->getPathInfo())); } - if (false === strpos($controller, ':')) { + if (\is_string($controller) && false === strpos($controller, ':')) { if (method_exists($controller, '__invoke')) { return $this->instantiateController($controller); } elseif (\function_exists($controller)) { From 62e2503b8815a3d5d1e40c0e4a514a6ddddb6869 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 23 May 2020 18:55:06 +0200 Subject: [PATCH 050/266] Make PHP 8 green on Travis --- Tests/Controller/ArgumentResolverTest.php | 8 ++++---- Tests/Controller/ControllerResolverTest.php | 8 +++++--- .../ArgumentMetadataFactoryTest.php | 6 +++--- .../Controller/LegacyNullableController.php | 19 +++++++++++++++++++ .../Controller/NullableController.php | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 Tests/Fixtures/Controller/LegacyNullableController.php diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index a964aaeb58..bf94728a43 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -216,10 +216,10 @@ public function testGetNullableArguments() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', new \stdClass()); - $request->attributes->set('mandatory', 'mandatory'); + $request->attributes->set('last', 'last'); $controller = [new NullableController(), 'action']; - $this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', new \stdClass(), 'value', 'last'], self::$resolver->getArguments($request, $controller)); } /** @@ -228,10 +228,10 @@ public function testGetNullableArguments() public function testGetNullableArgumentsWithDefaults() { $request = Request::create('/'); - $request->attributes->set('mandatory', 'mandatory'); + $request->attributes->set('last', 'last'); $controller = [new NullableController(), 'action']; - $this->assertEquals([null, null, 'value', 'mandatory'], self::$resolver->getArguments($request, $controller)); + $this->assertEquals([null, null, 'value', 'last'], self::$resolver->getArguments($request, $controller)); } public function testGetSessionArguments() diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index d2684791fe..b0a6b20058 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerResolver; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; +use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\LegacyNullableController; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; class ControllerResolverTest extends TestCase @@ -243,6 +243,7 @@ public function testIfExceptionIsThrownWhenMissingAnArgument() /** * @requires PHP 7.1 + * @requires PHP < 8 * @group legacy */ public function testGetNullableArguments() @@ -253,12 +254,13 @@ public function testGetNullableArguments() $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', new \stdClass()); $request->attributes->set('mandatory', 'mandatory'); - $controller = [new NullableController(), 'action']; + $controller = [new LegacyNullableController(), 'action']; $this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], $resolver->getArguments($request, $controller)); } /** * @requires PHP 7.1 + * @requires PHP < 8 * @group legacy */ public function testGetNullableArgumentsWithDefaults() @@ -267,7 +269,7 @@ public function testGetNullableArgumentsWithDefaults() $request = Request::create('/'); $request->attributes->set('mandatory', 'mandatory'); - $controller = [new NullableController(), 'action']; + $controller = [new LegacyNullableController(), 'action']; $this->assertEquals([null, null, 'value', 'mandatory'], $resolver->getArguments($request, $controller)); } diff --git a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index e5c62a87ca..00715462a2 100644 --- a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -80,7 +80,7 @@ public function testSignature5() $this->assertEquals([ new ArgumentMetadata('foo', 'array', false, true, null, true), - new ArgumentMetadata('bar', null, false, false, null), + new ArgumentMetadata('bar', null, false, true, null, true), ], $arguments); } @@ -122,7 +122,7 @@ public function testNullableTypesSignature() new ArgumentMetadata('foo', 'string', false, false, null, true), new ArgumentMetadata('bar', \stdClass::class, false, false, null, true), new ArgumentMetadata('baz', 'string', false, true, 'value', true), - new ArgumentMetadata('mandatory', null, false, false, null, true), + new ArgumentMetadata('last', 'string', false, true, '', false), ], $arguments); } @@ -142,7 +142,7 @@ private function signature4($foo = 'default', $bar = 500, $baz = []) { } - private function signature5(array $foo = null, $bar) + private function signature5(array $foo = null, $bar = null) { } } diff --git a/Tests/Fixtures/Controller/LegacyNullableController.php b/Tests/Fixtures/Controller/LegacyNullableController.php new file mode 100644 index 0000000000..23dde69d48 --- /dev/null +++ b/Tests/Fixtures/Controller/LegacyNullableController.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; + +class LegacyNullableController +{ + public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory) + { + } +} diff --git a/Tests/Fixtures/Controller/NullableController.php b/Tests/Fixtures/Controller/NullableController.php index 9db4df7b4c..aacae0e3e3 100644 --- a/Tests/Fixtures/Controller/NullableController.php +++ b/Tests/Fixtures/Controller/NullableController.php @@ -13,7 +13,7 @@ class NullableController { - public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory) + public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', string $last = '') { } } From 3361e8316006460cc3124dc5574994ac3c598cc7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 23 May 2020 19:37:50 +0200 Subject: [PATCH 051/266] [HttpKernel] fix test --- Tests/Controller/ControllerResolverTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index b0a6b20058..d249468e88 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -243,11 +243,14 @@ public function testIfExceptionIsThrownWhenMissingAnArgument() /** * @requires PHP 7.1 - * @requires PHP < 8 * @group legacy */ public function testGetNullableArguments() { + if (\PHP_VERSION_ID >= 80000) { + $this->markTestSkipped('PHP < 8 required.'); + } + $resolver = new ControllerResolver(); $request = Request::create('/'); @@ -260,11 +263,14 @@ public function testGetNullableArguments() /** * @requires PHP 7.1 - * @requires PHP < 8 * @group legacy */ public function testGetNullableArgumentsWithDefaults() { + if (\PHP_VERSION_ID >= 80000) { + $this->markTestSkipped('PHP < 8 required.'); + } + $resolver = new ControllerResolver(); $request = Request::create('/'); From 195731b7fa6f7226f7af3964e17eb5c85377e020 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 23 May 2020 00:49:08 +0200 Subject: [PATCH 052/266] Parse and render anonymous classes correctly on php 8 --- Kernel.php | 7 ++----- Tests/KernelTest.php | 21 +++++++++++++++++++++ composer.json | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8349de676a..438ef37f34 100644 --- a/Kernel.php +++ b/Kernel.php @@ -228,10 +228,7 @@ public function getBundles() public function getBundle($name) { if (!isset($this->bundles[$name])) { - $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class; - - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, $class)); + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); } return $this->bundles[$name]; @@ -474,7 +471,7 @@ protected function build(ContainerBuilder $container) protected function getContainerClass() { $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; + $class = false !== strpos($class, "@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = $this->name.str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index deac82b72d..36f8ea6e66 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -640,6 +640,27 @@ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() $this->assertGreaterThan($preReBoot, $kernel->getStartTime()); } + public function testAnonymousKernelGeneratesValidContainerClass(): void + { + $kernel = new class('test', true) extends Kernel { + public function registerBundles(): iterable + { + return []; + } + + public function registerContainerConfiguration(LoaderInterface $loader): void + { + } + + public function getContainerClass(): string + { + return parent::getContainerClass(); + } + }; + + $this->assertRegExp('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); + } + /** * Returns a mock for the BundleInterface. */ diff --git a/composer.json b/composer.json index eca3b54b36..2ae07df884 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.15", "psr/log": "~1.0" }, "require-dev": { From e4e4ed6c008c983645b4eee6b67d8f258cde54df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:14:17 +0200 Subject: [PATCH 053/266] updated VERSION for 3.4.41 --- Kernel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel.php b/Kernel.php index dc9cc048eb..00382a95c1 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,11 +67,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.40'; - const VERSION_ID = 30440; + const VERSION = '3.4.41'; + const VERSION_ID = 30441; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 40; + const RELEASE_VERSION = 41; const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; From 05ff4a5cc1f1d3e24c93e2a19d55288eb306dbcb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:24:17 +0200 Subject: [PATCH 054/266] bumped Symfony version to 3.4.42 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 00382a95c1..a0eb026f60 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.41'; - const VERSION_ID = 30441; + const VERSION = '3.4.42-DEV'; + const VERSION_ID = 30442; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 41; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 42; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 54526b598d7fc86a67850488b194a88a79ab8467 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:25:51 +0200 Subject: [PATCH 055/266] updated VERSION for 4.4.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 438ef37f34..49c7ab594a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.9-DEV'; + const VERSION = '4.4.9'; const VERSION_ID = 40409; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 9; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 9b5f471bbbaf8645a863e79b1ae50752ee5340c6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:29:28 +0200 Subject: [PATCH 056/266] bumped Symfony version to 4.4.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 49c7ab594a..f0a2ee8d29 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.9'; - const VERSION_ID = 40409; + const VERSION = '4.4.10-DEV'; + const VERSION_ID = 40410; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 9; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 10; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From f972768badff84285bbf15ec5a92fbeff4e813d4 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 7 Jun 2020 21:29:41 +0200 Subject: [PATCH 057/266] Update welcome.html.php --- Resources/welcome.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/welcome.html.php b/Resources/welcome.html.php index e1c0ff1192..b8337dc737 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -65,7 +65,7 @@
- You're seeing this page because you haven't configured any homepage URL. + You're seeing this page because you haven't configured any homepage URL and debug mode is enabled.
From 746fd7ae6330c57da3dd454b979bc9f9fd3410e1 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 10 Jun 2020 08:28:31 +0000 Subject: [PATCH 058/266] [HttpKernel] Fix regression where Store does not return response body correctly --- HttpCache/Store.php | 41 +++++++++++++++++++++++------------ Tests/HttpCache/StoreTest.php | 33 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index fd04a7b23d..72793f582d 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -152,8 +152,8 @@ public function lookup(Request $request) } $headers = $match[1]; - if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) { - return $this->restoreResponse($headers, $body); + if (file_exists($path = $this->getPath($headers['x-content-digest'][0]))) { + return $this->restoreResponse($headers, $path); } // TODO the metaStore referenced an entity that doesn't exist in @@ -177,15 +177,28 @@ public function write(Request $request, Response $response) $key = $this->getCacheKey($request); $storedEnv = $this->persistRequest($request); - $digest = $this->generateContentDigest($response); - $response->headers->set('X-Content-Digest', $digest); + if ($response->headers->has('X-Body-File')) { + // Assume the response came from disk, but at least perform some safeguard checks + if (!$response->headers->has('X-Content-Digest')) { + throw new \RuntimeException('A restored response must have the X-Content-Digest header.'); + } - if (!$this->save($digest, $response->getContent(), false)) { - throw new \RuntimeException('Unable to store the entity.'); - } + $digest = $response->headers->get('X-Content-Digest'); + if ($this->getPath($digest) !== $response->headers->get('X-Body-File')) { + throw new \RuntimeException('X-Body-File and X-Content-Digest do not match.'); + } + // Everything seems ok, omit writing content to disk + } else { + $digest = $this->generateContentDigest($response); + $response->headers->set('X-Content-Digest', $digest); - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', \strlen($response->getContent())); + if (!$this->save($digest, $response->getContent(), false)) { + throw new \RuntimeException('Unable to store the entity.'); + } + + if (!$response->headers->has('Transfer-Encoding')) { + $response->headers->set('Content-Length', \strlen($response->getContent())); + } } // read existing cache entries, remove non-varying, and add this one to the list @@ -477,19 +490,19 @@ private function persistResponse(Response $response) * Restores a Response from the HTTP headers and body. * * @param array $headers An array of HTTP headers for the Response - * @param string $body The Response body + * @param string $path Path to the Response body * * @return Response */ - private function restoreResponse($headers, $body = null) + private function restoreResponse($headers, $path = null) { $status = $headers['X-Status'][0]; unset($headers['X-Status']); - if (null !== $body) { - $headers['X-Body-File'] = [$body]; + if (null !== $path) { + $headers['X-Body-File'] = [$path]; } - return new Response($body, $status, $headers); + return new Response($path, $status, $headers); } } diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 07c4154269..6754be45a1 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -118,6 +118,39 @@ public function testWritesResponseEvenIfXContentDigestIsPresent() $this->assertNotNull($response); } + public function testWritingARestoredResponseDoesNotCorruptCache() + { + /* + * This covers the regression reported in https://github.com/symfony/symfony/issues/37174. + * + * A restored response does *not* load the body, but only keep the file path in a special X-Body-File + * header. For reasons (?), the file path was also used as the restored response body. + * It would be up to others (HttpCache...?) to hohor this header and actually load the response content + * from there. + * + * When a restored response was stored again, the Store itself would ignore the header. In the first + * step, this would compute a new Content Digest based on the file path in the restored response body; + * this is covered by "Checkpoint 1" below. But, since the X-Body-File header was left untouched (Checkpoint 2), downstream + * code (HttpCache...) would not immediately notice. + * + * Only upon performing the lookup for a second time, we'd get a Response where the (wrong) Content Digest + * is also reflected in the X-Body-File header, this time also producing wrong content when the downstream + * evaluates it. + */ + $this->store->write($this->request, $this->response); + $digest = $this->response->headers->get('X-Content-Digest'); + $path = $this->getStorePath($digest); + + $response = $this->store->lookup($this->request); + $this->store->write($this->request, $response); + $this->assertEquals($digest, $response->headers->get('X-Content-Digest')); // Checkpoint 1 + $this->assertEquals($path, $response->headers->get('X-Body-File')); // Checkpoint 2 + + $response = $this->store->lookup($this->request); + $this->assertEquals($digest, $response->headers->get('X-Content-Digest')); + $this->assertEquals($path, $response->headers->get('X-Body-File')); + } + public function testFindsAStoredEntryWithLookup() { $this->storeSimpleEntry(); From 350cc5379a80cce3ac6ebf987b354361a12f80be Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 Jun 2020 15:00:25 +0200 Subject: [PATCH 059/266] Fix typo --- Tests/HttpCache/StoreTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 6754be45a1..eee8970b96 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -125,7 +125,7 @@ public function testWritingARestoredResponseDoesNotCorruptCache() * * A restored response does *not* load the body, but only keep the file path in a special X-Body-File * header. For reasons (?), the file path was also used as the restored response body. - * It would be up to others (HttpCache...?) to hohor this header and actually load the response content + * It would be up to others (HttpCache...?) to honor this header and actually load the response content * from there. * * When a restored response was stored again, the Store itself would ignore the header. In the first From 6464a0475496040fe1f48428488d53e485be77a0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 12:57:07 +0200 Subject: [PATCH 060/266] updated VERSION for 3.4.42 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index a0eb026f60..1f0e29b97c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.42-DEV'; + const VERSION = '3.4.42'; const VERSION_ID = 30442; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 42; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 7cc7538970bc7cb71aab6af6e57d5bafcd32eaa5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:14:22 +0200 Subject: [PATCH 061/266] bumped Symfony version to 3.4.43 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1f0e29b97c..7fad1ee281 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.42'; - const VERSION_ID = 30442; + const VERSION = '3.4.43-DEV'; + const VERSION_ID = 30443; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 42; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 43; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 81d42148474e1852a333ed7a732f2a014af75430 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:15:37 +0200 Subject: [PATCH 062/266] updated VERSION for 4.4.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f0a2ee8d29..25e8202cdb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.10-DEV'; + const VERSION = '4.4.10'; const VERSION_ID = 40410; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 10; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 1400e5b5792c6f47da5c1f7c01f5edbc00c04835 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:19:16 +0200 Subject: [PATCH 063/266] bumped Symfony version to 4.4.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 25e8202cdb..6b08101e21 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.10'; - const VERSION_ID = 40410; + const VERSION = '4.4.11-DEV'; + const VERSION_ID = 40411; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 10; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 11; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 8ebcd836e0affce675fb397d18c340cefb196ad4 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 13 Jun 2020 10:25:25 +0200 Subject: [PATCH 064/266] [3.4] Small update in our internal terminology --- DependencyInjection/AddAnnotatedClassesToCachePass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 8bb03bd0c7..b59949379d 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -136,10 +136,10 @@ private function patternsToRegexps($patterns) private function matchAnyRegexps($class, $regexps) { - $blacklisted = false !== strpos($class, 'Test'); + $isTest = false !== strpos($class, 'Test'); foreach ($regexps as $regex) { - if ($blacklisted && false === strpos($regex, 'Test')) { + if ($isTest && false === strpos($regex, 'Test')) { continue; } From e8c115612b24e4bdf1c493512fe36ac5e34106a3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 15 Jun 2020 16:43:28 +0200 Subject: [PATCH 065/266] Fix support for PHP8 union types --- ControllerMetadata/ArgumentMetadataFactory.php | 2 +- EventListener/ErrorListener.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ControllerMetadata/ArgumentMetadataFactory.php b/ControllerMetadata/ArgumentMetadataFactory.php index 9370174c25..6c192a6f5f 100644 --- a/ControllerMetadata/ArgumentMetadataFactory.php +++ b/ControllerMetadata/ArgumentMetadataFactory.php @@ -45,7 +45,7 @@ public function createArgumentMetadata($controller): array */ private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function): ?string { - if (!$type = $parameter->getType()) { + if (!($type = $parameter->getType()) instanceof \ReflectionNamedType) { return null; } $name = $type->getName(); diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 26c361f754..1ca6c9b458 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -99,7 +99,7 @@ public function onControllerArguments(ControllerArgumentsEvent $event) $r = new \ReflectionFunction(\Closure::fromCallable($event->getController())); $r = $r->getParameters()[$k] ?? null; - if ($r && (!$r->hasType() || \in_array($r->getType()->getName(), [FlattenException::class, LegacyFlattenException::class], true))) { + if ($r && (!($r = $r->getType()) instanceof \ReflectionNamedType || \in_array($r->getName(), [FlattenException::class, LegacyFlattenException::class], true))) { $arguments = $event->getArguments(); $arguments[$k] = FlattenException::createFromThrowable($e); $event->setArguments($arguments); From 66a6ceafd959d93bf9bc84886f17e5a1be801837 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 18 Jun 2020 21:30:53 +0200 Subject: [PATCH 066/266] Fix --- ControllerMetadata/ArgumentMetadataFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ControllerMetadata/ArgumentMetadataFactory.php b/ControllerMetadata/ArgumentMetadataFactory.php index 2548a2a083..14e7ca3d11 100644 --- a/ControllerMetadata/ArgumentMetadataFactory.php +++ b/ControllerMetadata/ArgumentMetadataFactory.php @@ -105,7 +105,7 @@ private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbs if (!$type = $parameter->getType()) { return null; } - $name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); + $name = $type instanceof \ReflectionNamedType ? $type->getName() : (string) $type; if ('array' === $name && !$type->isBuiltin()) { // Special case for HHVM with variadics return null; From 1e96d6dea796cd71615658d9e5d57d2effbc8f5f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 8 Jul 2020 19:07:26 +0200 Subject: [PATCH 067/266] Fix PHP 8 deprecations --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 015448b510..8ed79ff7b2 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -274,7 +274,7 @@ private function typeMatchesRequestClass(\ReflectionParameter $param, Request $r return false; } - $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type); + $class = new \ReflectionClass($type instanceof \ReflectionNamedType ? $type->getName() : (string) $type); return $class && $class->isInstance($request); } From 41e230aad04a49be1c241dab5eb6711f7bcab162 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 16 Jul 2020 11:17:05 +0200 Subject: [PATCH 068/266] [SCA] Minor fixes on tests --- Tests/Event/FilterControllerArgumentsEventTest.php | 2 +- Tests/Profiler/FileProfilerStorageTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Event/FilterControllerArgumentsEventTest.php b/Tests/Event/FilterControllerArgumentsEventTest.php index abc51ac51e..53962347d0 100644 --- a/Tests/Event/FilterControllerArgumentsEventTest.php +++ b/Tests/Event/FilterControllerArgumentsEventTest.php @@ -12,6 +12,6 @@ class FilterControllerArgumentsEventTest extends TestCase public function testFilterControllerArgumentsEvent() { $filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1); - $this->assertEquals($filterController->getArguments(), ['test']); + $this->assertEquals(['test'], $filterController->getArguments()); } } diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index 1cc05e41ec..7100659c4d 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -205,9 +205,9 @@ public function testStoreTime() $records = $this->storage->find('', '', 3, 'GET', $start, time() + 3 * 60); $this->assertCount(3, $records, '->find() returns all previously added records'); - $this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order'); + $this->assertEquals('time_2', $records[0]['token'], '->find() returns records ordered by time in descendant order'); + $this->assertEquals('time_1', $records[1]['token'], '->find() returns records ordered by time in descendant order'); + $this->assertEquals('time_0', $records[2]['token'], '->find() returns records ordered by time in descendant order'); $records = $this->storage->find('', '', 3, 'GET', $start, time() + 2 * 60); $this->assertCount(2, $records, '->find() should return only first two of the previously added records'); From 05200f57a89ad1df2f0c2f33fd1596289e4822b2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 13 Jul 2020 00:27:19 +0200 Subject: [PATCH 069/266] Fix PHPUnit 8.5 deprecations. --- Tests/Controller/ContainerControllerResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 4c4abf5aa4..ef1c82638b 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -232,7 +232,7 @@ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionN // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected exception and not use the regex $resolver = $this->createControllerResolver(); $this->expectException($exceptionName); - $this->expectExceptionMessageRegExp($exceptionMessage); + $this->expectExceptionMessageMatches($exceptionMessage); $request = Request::create('/'); $request->attributes->set('_controller', $controller); From 4a1c6b310806adce0f299411951d06747edf9e28 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 05:48:59 +0200 Subject: [PATCH 070/266] updated VERSION for 3.4.43 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7fad1ee281..e824fdcf72 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.43-DEV'; + const VERSION = '3.4.43'; const VERSION_ID = 30443; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 43; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From a50959872fb69315ab98907f97ffcf65d1e86480 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:07:51 +0200 Subject: [PATCH 071/266] Bump Symfony version to 3.4.44 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index e824fdcf72..1b270bfdec 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.43'; - const VERSION_ID = 30443; + const VERSION = '3.4.44-DEV'; + const VERSION_ID = 30444; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 43; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 44; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From a675d2bf04a9328f164910cae6e3918b295151f3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:10:09 +0200 Subject: [PATCH 072/266] Update VERSION for 4.4.11 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6b08101e21..2efa73a375 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.11-DEV'; + const VERSION = '4.4.11'; const VERSION_ID = 40411; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 11; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From d42f9bee7d7975b0ce62413c241f714c083db84b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:14:13 +0200 Subject: [PATCH 073/266] Bump Symfony version to 4.4.12 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 2efa73a375..7c89e610fa 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.11'; - const VERSION_ID = 40411; + const VERSION = '4.4.12-DEV'; + const VERSION_ID = 40412; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 11; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 12; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 6451928305b13d5f126bf3ea48aa41c76cd3ce74 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 8 Aug 2020 16:41:28 +0200 Subject: [PATCH 074/266] Modernized deprecated PHPUnit assertion calls --- .../DataCollector/ConfigDataCollectorTest.php | 4 ++-- Tests/HttpCache/HttpCacheTest.php | 20 +++++++++---------- Tests/HttpCache/HttpCacheTestCase.php | 4 ++-- Tests/KernelTest.php | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index a858eabe15..f2cc4fa0dd 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -31,8 +31,8 @@ public function testCollect() $this->assertTrue($c->isDebug()); $this->assertSame('config', $c->getName()); $this->assertSame('testkernel', $c->getAppName()); - $this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); - $this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); + $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); + $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index cac06a80e5..444db71a3e 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -654,7 +654,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=10/', $this->response->headers->get('Cache-Control')); $this->cacheConfig['default_ttl'] = 10; $this->request('GET', '/'); @@ -663,7 +663,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=10/', $this->response->headers->get('Cache-Control')); } public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() @@ -676,7 +676,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); @@ -684,7 +684,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); // expires the cache $values = $this->getMetaStorageValues(); @@ -704,7 +704,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('invalid'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->setNextResponse(); @@ -714,7 +714,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); } public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() @@ -727,7 +727,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); @@ -755,7 +755,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('store'); $this->assertTraceNotContains('miss'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); @@ -763,7 +763,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); } public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() @@ -776,7 +776,7 @@ public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirectiv $this->assertEquals(200, $this->response->getStatusCode()); $this->assertTraceContains('miss'); $this->assertTraceNotContains('store'); - $this->assertNotRegExp('/s-maxage/', $this->response->headers->get('Cache-Control')); + $this->assertDoesNotMatchRegularExpression('/s-maxage/', $this->response->headers->get('Cache-Control')); $this->assertEquals('Hello World', $this->response->getContent()); } diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index 1eb4617447..3cbea5e4ee 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -91,7 +91,7 @@ public function assertTraceContains($trace) $traces = $this->cache->getTraces(); $traces = current($traces); - $this->assertRegExp('/'.$trace.'/', implode(', ', $traces)); + $this->assertMatchesRegularExpression('/'.$trace.'/', implode(', ', $traces)); } public function assertTraceNotContains($trace) @@ -99,7 +99,7 @@ public function assertTraceNotContains($trace) $traces = $this->cache->getTraces(); $traces = current($traces); - $this->assertNotRegExp('/'.$trace.'/', implode(', ', $traces)); + $this->assertDoesNotMatchRegularExpression('/'.$trace.'/', implode(', ', $traces)); } public function assertExceptionsAreCaught() diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index e4e2e0727b..6cbf59b9b2 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -78,7 +78,7 @@ public function testInitializeContainerClearsOldContainers() $containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16); $this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta')); $this->assertFileExists($containerDir); - $this->assertFileNotExists($containerDir.'.legacy'); + $this->assertFileDoesNotExist($containerDir.'.legacy'); $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); }); $kernel->boot(); @@ -86,8 +86,8 @@ public function testInitializeContainerClearsOldContainers() $this->assertFileExists($containerDir); $this->assertFileExists($containerDir.'.legacy'); - $this->assertFileNotExists($legacyContainerDir); - $this->assertFileNotExists($legacyContainerDir.'.legacy'); + $this->assertFileDoesNotExist($legacyContainerDir); + $this->assertFileDoesNotExist($legacyContainerDir.'.legacy'); } public function testBootInitializesBundlesAndContainer() From 8ee84f9e0e1cd3ab7d0b4d4e870ef3500ed96858 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 9 Aug 2020 14:16:18 +0200 Subject: [PATCH 075/266] PHPUnit's assertContains() performs strict comparisons now. --- Tests/DataCollector/RequestDataCollectorTest.php | 2 +- Tests/Profiler/FileProfilerStorageTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 38979bba72..9bf5bf968d 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -51,7 +51,7 @@ public function testCollect() $this->assertEquals(['name' => 'foo'], $c->getRouteParams()); $this->assertSame([], $c->getSessionAttributes()); $this->assertSame('en', $c->getLocale()); - $this->assertContains(__FILE__, $attributes->get('resource')); + $this->assertContainsEquals(__FILE__, $attributes->get('resource')); $this->assertSame('stdClass', $attributes->get('object')->getType()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders()); diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index 7100659c4d..4e23f13b02 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -293,8 +293,8 @@ public function testStatusCode() $tokens = $this->storage->find('', '', 10, ''); $this->assertCount(2, $tokens); - $this->assertContains($tokens[0]['status_code'], [200, 404]); - $this->assertContains($tokens[1]['status_code'], [200, 404]); + $this->assertContains((int) $tokens[0]['status_code'], [200, 404]); + $this->assertContains((int) $tokens[1]['status_code'], [200, 404]); } public function testMultiRowIndexFile() From a031f696fc43db5f1ba97f33c1e0066a75196472 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 11 Aug 2020 09:56:31 +0200 Subject: [PATCH 076/266] stop using the deprecated at() PHPUnit matcher --- .../ContainerControllerResolverTest.php | 25 ++++------------- .../EventListener/TranslatorListenerTest.php | 28 +++++++++++-------- Tests/HttpKernelTest.php | 4 +-- Tests/KernelTest.php | 8 ++++-- 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index ef1c82638b..8275154657 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; @@ -117,16 +118,10 @@ public function testNonConstructController() $this->expectException('LogicException'); $this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Tests\Controller\ImpossibleConstructController" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->at(0)) + $container->expects($this->exactly(2)) ->method('has') ->with(ImpossibleConstructController::class) - ->willReturn(true) - ; - - $container->expects($this->at(1)) - ->method('has') - ->with(ImpossibleConstructController::class) - ->willReturn(false) + ->willReturnOnConsecutiveCalls(true, false) ; $container->expects($this->atLeastOnce()) @@ -181,18 +176,10 @@ public function testExceptionWhenUsingRemovedControllerService() { $this->expectException('LogicException'); $this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); - $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->at(0)) - ->method('has') - ->with('app.my_controller') - ->willReturn(false) - ; - $container->expects($this->atLeastOnce()) - ->method('getRemovedIds') - ->with() - ->willReturn(['app.my_controller' => true]) - ; + $container = new ContainerBuilder(); + $container->register('app.my_controller'); + $container->removeDefinition('app.my_controller'); $resolver = $this->createControllerResolver(null, $container); diff --git a/Tests/EventListener/TranslatorListenerTest.php b/Tests/EventListener/TranslatorListenerTest.php index 77c2c1c694..79e0d6f1ac 100644 --- a/Tests/EventListener/TranslatorListenerTest.php +++ b/Tests/EventListener/TranslatorListenerTest.php @@ -45,13 +45,15 @@ public function testLocaleIsSetInOnKernelRequest() public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() { $this->translator - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('setLocale') - ->willThrowException(new \InvalidArgumentException()); - $this->translator - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + ['fr'], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -82,13 +84,15 @@ public function testLocaleIsNotSetInOnKernelFinishRequestWhenParentRequestDoesNo public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() { $this->translator - ->expects($this->at(0)) - ->method('setLocale') - ->willThrowException(new \InvalidArgumentException()); - $this->translator - ->expects($this->at(1)) + ->expects($this->exactly(2)) ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + ['fr'], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $this->setMasterRequest($this->createRequest('fr')); $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index af81f021ed..97c58305db 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -314,8 +314,8 @@ public function testVerifyRequestStackPushPopDuringHandle() $request = new Request(); $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(['push', 'pop'])->getMock(); - $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); - $stack->expects($this->at(1))->method('pop'); + $stack->expects($this->once())->method('push')->with($this->equalTo($request)); + $stack->expects($this->once())->method('pop'); $dispatcher = new EventDispatcher(); $kernel = $this->getHttpKernel($dispatcher, null, $stack); diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 6cbf59b9b2..fd840bbb7b 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -219,9 +220,12 @@ public function testShutdownCallsShutdownOnAllBundles() public function testShutdownGivesNullContainerToAllBundles() { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); - $bundle->expects($this->at(3)) + $bundle->expects($this->exactly(2)) ->method('setContainer') - ->with(null); + ->withConsecutive( + [$this->isInstanceOf(ContainerInterface::class)], + [null] + ); $kernel = $this->getKernel(['getBundles']); $kernel->expects($this->any()) From a3d083f0152a8e30d37e01c71ee775e0c789d3a0 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Fri, 14 Aug 2020 16:49:01 +0200 Subject: [PATCH 077/266] [VarDumper] Backport handler lock when using VAR_DUMPER_FORMAT --- DataCollector/DumpDataCollector.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index d9f381b3d6..4e430f8f37 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -235,13 +235,7 @@ public function __destruct() --$i; } - if (isset($_SERVER['VAR_DUMPER_FORMAT'])) { - $html = 'html' === $_SERVER['VAR_DUMPER_FORMAT']; - } else { - $html = !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html'); - } - - if ($html) { + if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) { $dumper = new HtmlDumper('php://output', $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { From 3ab83d293cb851b243ada91325c69ac5d4c0ded3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 17 Aug 2020 09:16:16 +0200 Subject: [PATCH 078/266] Fix CS --- DataCollector/ConfigDataCollector.php | 2 +- Tests/DataCollector/ConfigDataCollectorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 673bf5c5fd..5895ef37d7 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -64,7 +64,7 @@ public function collect(Request $request, Response $response, \Exception $except 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, - 'php_architecture' => PHP_INT_SIZE * 8, + 'php_architecture' => \PHP_INT_SIZE * 8, 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index f2cc4fa0dd..dc455915fa 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -33,7 +33,7 @@ public function testCollect() $this->assertSame('testkernel', $c->getAppName()); $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); - $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); + $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); From ce729cd7e8eb1099d3e2e5370b079b84897f7611 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 17 Aug 2020 09:39:58 +0200 Subject: [PATCH 079/266] Fix CS --- Tests/Controller/ContainerControllerResolverTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index c029c0b5f8..c39dac3ca5 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -14,7 +14,6 @@ use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; From 4b232e313f2f6e538c17c196db156c183601779a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 13 Aug 2020 19:28:52 +0200 Subject: [PATCH 080/266] stop using deprecated PHPUnit APIs --- .../EventListener/LocaleAwareListenerTest.php | 28 +++++++++++-------- Tests/KernelTest.php | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Tests/EventListener/LocaleAwareListenerTest.php b/Tests/EventListener/LocaleAwareListenerTest.php index ef3b7d1b42..0064429048 100644 --- a/Tests/EventListener/LocaleAwareListenerTest.php +++ b/Tests/EventListener/LocaleAwareListenerTest.php @@ -47,13 +47,15 @@ public function testLocaleIsSetInOnKernelRequest() public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() { $this->localeAwareService - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->localeAwareService - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + [$this->anything()], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -89,13 +91,15 @@ public function testLocaleIsSetToDefaultOnKernelFinishRequestWhenParentRequestDo public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() { $this->localeAwareService - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->localeAwareService - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + [$this->anything()], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $this->requestStack->push($this->createRequest('fr')); $this->requestStack->push($subRequest = $this->createRequest('de')); diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 4d40a1b34f..b4075c98ba 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -662,7 +662,7 @@ public function getContainerClass(): string } }; - $this->assertRegExp('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); + $this->assertMatchesRegularExpression('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); } /** From 27dcaa8c6b18c75df9f37badeb4d3564ffaa1326 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 07:53:42 +0200 Subject: [PATCH 081/266] Update VERSION for 3.4.44 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1b270bfdec..e0aa029eb6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.44-DEV'; + const VERSION = '3.4.44'; const VERSION_ID = 30444; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 44; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 16620a5c57955b6cd5f244507ff9c5d58e6f803a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 07:58:19 +0200 Subject: [PATCH 082/266] Bump Symfony version to 3.4.45 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index e0aa029eb6..4c52d2e18e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.44'; - const VERSION_ID = 30444; + const VERSION = '3.4.45-DEV'; + const VERSION_ID = 30445; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 44; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 45; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From f93f6b3e52a590749994cc23d8fb879472ceb76c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 08:09:42 +0200 Subject: [PATCH 083/266] Update VERSION for 4.4.12 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7c89e610fa..77806d80ca 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.12-DEV'; + const VERSION = '4.4.12'; const VERSION_ID = 40412; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 12; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From a5ed890bd448a456a592e14b46996140eeface4b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 08:14:12 +0200 Subject: [PATCH 084/266] Bump Symfony version to 4.4.13 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 77806d80ca..e7c70c8fd4 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.12'; - const VERSION_ID = 40412; + const VERSION = '4.4.13-DEV'; + const VERSION_ID = 40413; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 12; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 13; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 8e8d0edc74a13fe592ca5b1c392b41c63f519ecc Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 15 Jun 2020 07:28:47 +0000 Subject: [PATCH 085/266] Remove headers with internal meaning from HttpClient responses --- HttpClientKernel.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 912ce313f8..2056a673a6 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -58,6 +58,10 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $response = new Response($response->getContent(!$catch), $response->getStatusCode(), $response->getHeaders(!$catch)); + $response->headers->remove('X-Body-File'); + $response->headers->remove('X-Body-Eval'); + $response->headers->remove('X-Content-Digest'); + $response->headers = new class($response->headers->all()) extends ResponseHeaderBag { protected function computeCacheControlValue(): string { From 2bb7b90ecdc79813c0bf237b7ff20e79062b5188 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 2 Sep 2020 10:09:29 +0200 Subject: [PATCH 086/266] Update VERSION for 4.4.13 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index e7c70c8fd4..f11acbb9bf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.13-DEV'; + const VERSION = '4.4.13'; const VERSION_ID = 40413; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 13; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 8b64594b1fd829539d118459bb9bb32aea4909d1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 2 Sep 2020 10:14:21 +0200 Subject: [PATCH 087/266] Bump Symfony version to 4.4.14 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f11acbb9bf..18d3c01f33 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.13'; - const VERSION_ID = 40413; + const VERSION = '4.4.14-DEV'; + const VERSION_ID = 40414; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 13; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 14; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 87cdfb2cca262abf7de881265b818a6b832f0c73 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 Sep 2020 18:06:40 +0200 Subject: [PATCH 088/266] Enable "native_constant_invocation" CS rule --- Bundle/Bundle.php | 2 +- CacheClearer/ChainCacheClearer.php | 2 +- CacheClearer/Psr6CacheClearer.php | 2 +- CacheWarmer/CacheWarmerAggregate.php | 4 +- Client.php | 2 +- Controller/ControllerResolver.php | 4 +- Controller/TraceableControllerResolver.php | 2 +- DataCollector/ConfigDataCollector.php | 6 +- DataCollector/DataCollector.php | 6 +- DataCollector/DumpDataCollector.php | 2 +- DataCollector/EventDataCollector.php | 2 +- DataCollector/LoggerDataCollector.php | 6 +- DataCollector/RequestDataCollector.php | 4 +- DataCollector/Util/ValueExporter.php | 2 +- Debug/FileLinkFormatter.php | 2 +- DependencyInjection/AddClassesToCachePass.php | 2 +- DependencyInjection/Extension.php | 4 +- .../LazyLoadingFragmentHandler.php | 2 +- ...RegisterControllerArgumentLocatorsPass.php | 2 +- EventListener/DebugHandlersListener.php | 8 +-- .../AbstractSurrogateFragmentRenderer.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 2 +- HttpCache/Esi.php | 4 +- HttpCache/Ssi.php | 4 +- HttpCache/Store.php | 12 ++-- HttpKernel.php | 4 +- Kernel.php | 36 ++++++------ Log/Logger.php | 2 +- Profiler/FileProfilerStorage.php | 4 +- Profiler/Profiler.php | 2 +- Tests/ClientTest.php | 12 ++-- .../DataCollector/ConfigDataCollectorTest.php | 8 +-- .../DataCollector/LoggerDataCollectorTest.php | 24 ++++---- .../DebugHandlersListenerTest.php | 4 +- Tests/HttpCache/HttpCacheTest.php | 58 +++++++++---------- Tests/Log/LoggerTest.php | 4 +- Tests/Profiler/FileProfilerStorageTest.php | 2 +- UriSigner.php | 2 +- 38 files changed, 126 insertions(+), 126 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 530a2749d1..d0f9811e97 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -171,7 +171,7 @@ public function registerCommands(Application $application) } $r = new \ReflectionClass($class); if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { - @trigger_error(sprintf('Auto-registration of the command "%s" is deprecated since Symfony 3.4 and won\'t be supported in 4.0. Use PSR-4 based service discovery instead.', $class), E_USER_DEPRECATED); + @trigger_error(sprintf('Auto-registration of the command "%s" is deprecated since Symfony 3.4 and won\'t be supported in 4.0. Use PSR-4 based service discovery instead.', $class), \E_USER_DEPRECATED); $application->add($r->newInstance()); } diff --git a/CacheClearer/ChainCacheClearer.php b/CacheClearer/ChainCacheClearer.php index f82ada5c4b..a71cc4056a 100644 --- a/CacheClearer/ChainCacheClearer.php +++ b/CacheClearer/ChainCacheClearer.php @@ -49,7 +49,7 @@ public function clear($cacheDir) */ public function add(CacheClearerInterface $clearer) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), \E_USER_DEPRECATED); $this->clearers[] = $clearer; } diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index 4b4aafa163..4271e0f88a 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -27,7 +27,7 @@ public function __construct(array $pools = []) public function addPool(CacheItemPoolInterface $pool) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.', __METHOD__), \E_USER_DEPRECATED); $this->pools[] = $pool; } diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index eca4e6aede..010a3998c6 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -68,7 +68,7 @@ public function isOptional() */ public function setWarmers(array $warmers) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), \E_USER_DEPRECATED); $this->warmers = []; foreach ($warmers as $warmer) { @@ -82,7 +82,7 @@ public function setWarmers(array $warmers) public function add(CacheWarmerInterface $warmer) { if ($this->triggerDeprecation) { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0, inject the list of clearers as a constructor argument instead.', __METHOD__), \E_USER_DEPRECATED); } $this->warmers[] = $warmer; diff --git a/Client.php b/Client.php index 958c4c81f9..14794727f3 100644 --- a/Client.php +++ b/Client.php @@ -170,7 +170,7 @@ protected function filterFiles(array $files) $value->getClientOriginalName(), $value->getClientMimeType(), 0, - UPLOAD_ERR_INI_SIZE, + \UPLOAD_ERR_INI_SIZE, true ); } else { diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 8ed79ff7b2..6248be1814 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -101,7 +101,7 @@ public function getController(Request $request) */ public function getArguments(Request $request, $controller) { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), \E_USER_DEPRECATED); if (\is_array($controller)) { $r = new \ReflectionMethod($controller[0], $controller[1]); @@ -125,7 +125,7 @@ public function getArguments(Request $request, $controller) */ protected function doGetArguments(Request $request, $controller, array $parameters) { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), \E_USER_DEPRECATED); $attributes = $request->attributes->all(); $arguments = []; diff --git a/Controller/TraceableControllerResolver.php b/Controller/TraceableControllerResolver.php index 6f39f81d2a..09701cfe04 100644 --- a/Controller/TraceableControllerResolver.php +++ b/Controller/TraceableControllerResolver.php @@ -60,7 +60,7 @@ public function getController(Request $request) */ public function getArguments(Request $request, $controller) { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.', __METHOD__, TraceableArgumentResolver::class), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.', __METHOD__, TraceableArgumentResolver::class), \E_USER_DEPRECATED); $ret = $this->argumentResolver->getArguments($request, $controller); diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 5895ef37d7..8ad6279e5f 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -63,13 +63,13 @@ public function collect(Request $request, Response $response, \Exception $except 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', - 'php_version' => PHP_VERSION, + 'php_version' => \PHP_VERSION, 'php_architecture' => \PHP_INT_SIZE * 8, 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), - 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), - 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), + 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), + 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), 'bundles' => [], 'sapi_name' => \PHP_SAPI, ]; diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 94307cf56c..7119545b68 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -45,7 +45,7 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable public function serialize() { - $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); + $trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object']; return $isCalledFromOverridingMethod ? $this->data : serialize($this->data); @@ -77,7 +77,7 @@ protected function cloneVar($var) $this->cloner->setMaxItems(-1); $this->cloner->addCasters($this->getCasters()); } else { - @trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since Symfony 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since Symfony 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), \E_USER_DEPRECATED); $this->cloner = false; } } @@ -103,7 +103,7 @@ protected function cloneVar($var) */ protected function varToString($var) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), \E_USER_DEPRECATED); if (null === $this->valueExporter) { $this->valueExporter = new ValueExporter(); diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 280e1ddd08..e5c276de6c 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -71,7 +71,7 @@ public function dump(Data $data) $this->isCollected = false; } - $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7); + $trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 7); $file = $trace[0]['file']; $line = $trace[0]['line']; diff --git a/DataCollector/EventDataCollector.php b/DataCollector/EventDataCollector.php index 78e9e29198..e3f8576cdc 100644 --- a/DataCollector/EventDataCollector.php +++ b/DataCollector/EventDataCollector.php @@ -28,7 +28,7 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter public function __construct(EventDispatcherInterface $dispatcher = null) { if ($dispatcher instanceof TraceableEventDispatcherInterface && !method_exists($dispatcher, 'reset')) { - @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', TraceableEventDispatcherInterface::class, \get_class($dispatcher)), E_USER_DEPRECATED); + @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', TraceableEventDispatcherInterface::class, \get_class($dispatcher)), \E_USER_DEPRECATED); } $this->dispatcher = $dispatcher; } diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 9c05daa36f..c2c337a017 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -30,7 +30,7 @@ public function __construct($logger = null, $containerPathPrefix = null) { if (null !== $logger && $logger instanceof DebugLoggerInterface) { if (!method_exists($logger, 'clear')) { - @trigger_error(sprintf('Implementing "%s" without the "clear()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DebugLoggerInterface::class, \get_class($logger)), E_USER_DEPRECATED); + @trigger_error(sprintf('Implementing "%s" without the "clear()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DebugLoggerInterface::class, \get_class($logger)), \E_USER_DEPRECATED); } $this->logger = $logger; @@ -148,7 +148,7 @@ private function getContainerCompilerLogs() } $logs = []; - foreach (file($file, FILE_IGNORE_NEW_LINES) as $log) { + foreach (file($file, \FILE_IGNORE_NEW_LINES) as $log) { $log = explode(': ', $log, 2); if (!isset($log[1]) || !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $log[0])) { $log = ['Unknown Compiler Pass', implode(': ', $log)]; @@ -221,7 +221,7 @@ private function isSilencedOrDeprecationErrorLog(array $log) return true; } - if ($exception instanceof \ErrorException && \in_array($exception->getSeverity(), [E_DEPRECATED, E_USER_DEPRECATED], true)) { + if ($exception instanceof \ErrorException && \in_array($exception->getSeverity(), [\E_DEPRECATED, \E_USER_DEPRECATED], true)) { return true; } diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 246c0c7f6f..41372a5654 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -62,8 +62,8 @@ public function collect(Request $request, Response $response, \Exception $except if ($request->hasSession()) { $session = $request->getSession(); if ($session->isStarted()) { - $sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated()); - $sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed()); + $sessionMetadata['Created'] = date(\DATE_RFC822, $session->getMetadataBag()->getCreated()); + $sessionMetadata['Last used'] = date(\DATE_RFC822, $session->getMetadataBag()->getLastUsed()); $sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime(); $sessionAttributes = $session->all(); $flashes = $session->getFlashBag()->peekAll(); diff --git a/DataCollector/Util/ValueExporter.php b/DataCollector/Util/ValueExporter.php index 36570b4d5f..f84aeeae59 100644 --- a/DataCollector/Util/ValueExporter.php +++ b/DataCollector/Util/ValueExporter.php @@ -11,7 +11,7 @@ namespace Symfony\Component\HttpKernel\DataCollector\Util; -@trigger_error('The '.__NAMESPACE__.'\ValueExporter class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the VarDumper component instead.', E_USER_DEPRECATED); +@trigger_error('The '.__NAMESPACE__.'\ValueExporter class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the VarDumper component instead.', \E_USER_DEPRECATED); /** * @author Bernhard Schussek diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index e7347d4902..63ae6e6aab 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -36,7 +36,7 @@ public function __construct($fileLinkFormat = null, RequestStack $requestStack = $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !\is_array($fileLinkFormat)) { $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f); - $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE); + $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE); } $this->fileLinkFormat = $fileLinkFormat; diff --git a/DependencyInjection/AddClassesToCachePass.php b/DependencyInjection/AddClassesToCachePass.php index 8ae78e0d84..8b3dcb7f61 100644 --- a/DependencyInjection/AddClassesToCachePass.php +++ b/DependencyInjection/AddClassesToCachePass.php @@ -11,7 +11,7 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; -@trigger_error('The '.__NAMESPACE__.'\AddClassesToCachePass class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED); +@trigger_error('The '.__NAMESPACE__.'\AddClassesToCachePass class is deprecated since Symfony 3.3 and will be removed in 4.0.', \E_USER_DEPRECATED); /** * Sets the classes to compile in the cache for the container. diff --git a/DependencyInjection/Extension.php b/DependencyInjection/Extension.php index ec69392e53..55a4759dbf 100644 --- a/DependencyInjection/Extension.php +++ b/DependencyInjection/Extension.php @@ -33,7 +33,7 @@ abstract class Extension extends BaseExtension public function getClassesToCompile() { if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); + @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', \E_USER_DEPRECATED); } return $this->classes; @@ -59,7 +59,7 @@ public function getAnnotatedClassesToCompile() public function addClassesToCompile(array $classes) { if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); + @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', \E_USER_DEPRECATED); } $this->classes = array_merge($this->classes, $classes); diff --git a/DependencyInjection/LazyLoadingFragmentHandler.php b/DependencyInjection/LazyLoadingFragmentHandler.php index 1722ef58b1..4deaaf0d1a 100644 --- a/DependencyInjection/LazyLoadingFragmentHandler.php +++ b/DependencyInjection/LazyLoadingFragmentHandler.php @@ -51,7 +51,7 @@ public function __construct(ContainerInterface $container, RequestStack $request */ public function addRendererService($name, $renderer) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0.', __METHOD__), \E_USER_DEPRECATED); $this->rendererIds[$name] = $renderer; } diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index d021c6ee8a..c7d3d279a4 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -89,7 +89,7 @@ public function process(ContainerBuilder $container) } foreach (['action', 'argument', 'id'] as $k) { if (!isset($attributes[$k][0])) { - throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, JSON_UNESCAPED_UNICODE), $id)); + throw new InvalidArgumentException(sprintf('Missing "%s" attribute on tag "%s" %s for service "%s".', $k, $this->controllerTag, json_encode($attributes, \JSON_UNESCAPED_UNICODE), $id)); } } if (!isset($methods[$action = strtolower($attributes['action'])])) { diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index 957a3cdb0f..5f530631e6 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -49,12 +49,12 @@ class DebugHandlersListener implements EventSubscriberInterface * @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null, $scope = true) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, $throwAt = \E_ALL, $scream = true, $fileLinkFormat = null, $scope = true) { $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; - $this->levels = null === $levels ? E_ALL : $levels; - $this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null)); + $this->levels = null === $levels ? \E_ALL : $levels; + $this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null)); $this->scream = (bool) $scream; $this->fileLinkFormat = $fileLinkFormat; $this->scope = (bool) $scope; @@ -93,7 +93,7 @@ public function configure(Event $event = null) $handler->screamAt($levels); } if ($this->scope) { - $handler->scopeAt($levels & ~E_USER_DEPRECATED & ~E_DEPRECATED); + $handler->scopeAt($levels & ~\E_USER_DEPRECATED & ~\E_DEPRECATED); } else { $handler->scopeAt(0, true); } diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index 430486e549..3d050c8852 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -63,7 +63,7 @@ public function render($uri, Request $request, array $options = []) { if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) { if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) { - @trigger_error('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated since Symfony 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', E_USER_DEPRECATED); + @trigger_error('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated since Symfony 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', \E_USER_DEPRECATED); } return $this->inlineStrategy->render($uri, $request, $options); diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index 4850e589da..ed0188c5b2 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -109,7 +109,7 @@ public function render($uri, Request $request, array $options = []) } $renderedAttributes = ''; if (\count($attributes) > 0) { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; + $flags = \ENT_QUOTES | \ENT_SUBSTITUTE; foreach ($attributes as $attribute => $value) { $renderedAttributes .= sprintf( ' %s="%s"', diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 96e6ca4bfe..3d461a7fe3 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -80,13 +80,13 @@ public function process(Request $request, Response $response) $content = preg_replace('#.*?#s', '', $content); $content = preg_replace('#]+>#s', '', $content); - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('##', $content, -1, \PREG_SPLIT_DELIM_CAPTURE); $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); $i = 1; while (isset($chunks[$i])) { $options = []; - preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); + preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, \PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; } diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 40aac64f2a..6dba4e11df 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -65,13 +65,13 @@ public function process(Request $request, Response $response) // we don't use a proper XML parser here as we can have SSI tags in a plain text response $content = $response->getContent(); - $chunks = preg_split('##', $content, -1, PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('##', $content, -1, \PREG_SPLIT_DELIM_CAPTURE); $chunks[0] = str_replace($this->phpEscapeMap[0], $this->phpEscapeMap[1], $chunks[0]); $i = 1; while (isset($chunks[$i])) { $options = []; - preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); + preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, \PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; } diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 72793f582d..0a93eb0eee 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -50,7 +50,7 @@ public function cleanup() { // unlock everything foreach ($this->locks as $lock) { - flock($lock, LOCK_UN); + flock($lock, \LOCK_UN); fclose($lock); } @@ -72,7 +72,7 @@ public function lock(Request $request) return $path; } $h = fopen($path, 'cb'); - if (!flock($h, LOCK_EX | LOCK_NB)) { + if (!flock($h, \LOCK_EX | \LOCK_NB)) { fclose($h); return $path; @@ -94,7 +94,7 @@ public function unlock(Request $request) $key = $this->getCacheKey($request); if (isset($this->locks[$key])) { - flock($this->locks[$key], LOCK_UN); + flock($this->locks[$key], \LOCK_UN); fclose($this->locks[$key]); unset($this->locks[$key]); @@ -117,8 +117,8 @@ public function isLocked(Request $request) } $h = fopen($path, 'rb'); - flock($h, LOCK_EX | LOCK_NB, $wouldBlock); - flock($h, LOCK_UN); // release the lock we just acquired + flock($h, \LOCK_EX | \LOCK_NB, $wouldBlock); + flock($h, \LOCK_UN); // release the lock we just acquired fclose($h); return (bool) $wouldBlock; @@ -340,7 +340,7 @@ private function doPurge($url) { $key = $this->getCacheKey(Request::create($url)); if (isset($this->locks[$key])) { - flock($this->locks[$key], LOCK_UN); + flock($this->locks[$key], \LOCK_UN); fclose($this->locks[$key]); unset($this->locks[$key]); } diff --git a/HttpKernel.php b/HttpKernel.php index 9769d5e802..8c20695d8c 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -51,7 +51,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ControllerReso $this->argumentResolver = $argumentResolver; if (null === $this->argumentResolver) { - @trigger_error(sprintf('As of 3.1 an %s is used to resolve arguments. In 4.0 the $argumentResolver becomes the %s if no other is provided instead of using the $resolver argument.', ArgumentResolverInterface::class, ArgumentResolver::class), E_USER_DEPRECATED); + @trigger_error(sprintf('As of 3.1 an %s is used to resolve arguments. In 4.0 the $argumentResolver becomes the %s if no other is provided instead of using the $resolver argument.', ArgumentResolverInterface::class, ArgumentResolver::class), \E_USER_DEPRECATED); // fallback in case of deprecations $this->argumentResolver = $resolver; } @@ -239,7 +239,7 @@ private function handleException(\Exception $e, $request, $type) // the developer asked for a specific status code if ($response->headers->has('X-Status-Code')) { - @trigger_error(sprintf('Using the X-Status-Code header is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s::allowCustomResponseCode() instead.', GetResponseForExceptionEvent::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Using the X-Status-Code header is deprecated since Symfony 3.3 and will be removed in 4.0. Use %s::allowCustomResponseCode() instead.', GetResponseForExceptionEvent::class), \E_USER_DEPRECATED); $response->setStatusCode($response->headers->get('X-Status-Code')); diff --git a/Kernel.php b/Kernel.php index 4c52d2e18e..de9025061a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -232,7 +232,7 @@ public function getBundle($name, $first = true/*, $noDeprecation = false */) } if (!$first && !$noDeprecation) { - @trigger_error(sprintf('Passing "false" as the second argument to "%s()" is deprecated as of 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('Passing "false" as the second argument to "%s()" is deprecated as of 3.4 and will be removed in 4.0.', __METHOD__), \E_USER_DEPRECATED); } if (!isset($this->bundleMap[$name])) { @@ -397,7 +397,7 @@ public function getContainer() public function loadClassCache($name = 'classes', $extension = '.php') { if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); + @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', \E_USER_DEPRECATED); } $this->loadClassCache = [$name, $extension]; @@ -411,7 +411,7 @@ public function loadClassCache($name = 'classes', $extension = '.php') public function setClassCache(array $classes) { if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); + @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', \E_USER_DEPRECATED); } file_put_contents(($this->warmupDir ?: $this->getCacheDir()).'/classes.map', sprintf('debug && null !== $this->startTime ? $this->startTime : -INF; + return $this->debug && null !== $this->startTime ? $this->startTime : -\INF; } /** @@ -463,7 +463,7 @@ public function getCharset() protected function doLoadClassCache($name, $extension) { if (\PHP_VERSION_ID >= 70000) { - @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); + @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', \E_USER_DEPRECATED); } $cacheDir = $this->warmupDir ?: $this->getCacheDir(); @@ -498,7 +498,7 @@ protected function initializeBundles() $this->bundles[$name] = $bundle; if ($parentName = $bundle->getParent()) { - @trigger_error('Bundle inheritance is deprecated as of 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); + @trigger_error('Bundle inheritance is deprecated as of 3.4 and will be removed in 4.0.', \E_USER_DEPRECATED); if (isset($directChildren[$parentName])) { throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName])); @@ -583,7 +583,7 @@ protected function initializeContainer() $oldContainer = null; if ($fresh = $cache->isFresh()) { // Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors - $errorLevel = error_reporting(E_ALL ^ E_WARNING); + $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); $fresh = $oldContainer = false; try { if (file_exists($cache->getPath()) && \is_object($this->container = include $cache->getPath())) { @@ -605,7 +605,7 @@ protected function initializeContainer() if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) { $collectedLogs = []; $previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { - if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { + if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) { return $previousHandler ? $previousHandler($type, $message, $file, $line) : false; } @@ -615,7 +615,7 @@ protected function initializeContainer() return null; } - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); + $backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3); // Clean the trace by removing first frames added by the error handler itself. for ($i = 0; isset($backtrace[$i]); ++$i) { if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { @@ -651,7 +651,7 @@ protected function initializeContainer() } if (null === $oldContainer && file_exists($cache->getPath())) { - $errorLevel = error_reporting(E_ALL ^ E_WARNING); + $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); try { $oldContainer = include $cache->getPath(); } catch (\Throwable $e) { @@ -673,7 +673,7 @@ protected function initializeContainer() static $legacyContainers = []; $oldContainerDir = \dirname($oldContainer->getFileName()); $legacyContainers[$oldContainerDir.'.legacy'] = true; - foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', GLOB_NOSORT) as $legacyContainer) { + foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', \GLOB_NOSORT) as $legacyContainer) { if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) { (new Filesystem())->remove(substr($legacyContainer, 0, -7)); } @@ -736,13 +736,13 @@ protected function getKernelParameters() protected function getEnvParameters() { if (0 === \func_num_args() || func_get_arg(0)) { - @trigger_error(sprintf('The "%s()" method is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax to get the value of any environment variable from configuration files instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s()" method is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax to get the value of any environment variable from configuration files instead.', __METHOD__), \E_USER_DEPRECATED); } $parameters = []; foreach ($_SERVER as $key => $value) { if (0 === strpos($key, 'SYMFONY__')) { - @trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.', $key), E_USER_DEPRECATED); + @trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.', $key), \E_USER_DEPRECATED); $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value; } } @@ -921,14 +921,14 @@ public static function stripComments($source) $token = $tokens[$i]; if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; - } elseif (T_START_HEREDOC === $token[0]) { + } elseif (\T_START_HEREDOC === $token[0]) { $output .= $rawChunk.$token[1]; do { $token = $tokens[++$i]; $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; - } while (T_END_HEREDOC !== $token[0]); + } while (\T_END_HEREDOC !== $token[0]); $rawChunk = ''; - } elseif (T_WHITESPACE === $token[0]) { + } elseif (\T_WHITESPACE === $token[0]) { if ($ignoreSpace) { $ignoreSpace = false; @@ -937,13 +937,13 @@ public static function stripComments($source) // replace multiple new lines with a single newline $rawChunk .= preg_replace(['/\n{2,}/S'], "\n", $token[1]); - } elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { + } elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) { $ignoreSpace = true; } else { $rawChunk .= $token[1]; // The PHP-open tag already has a new-line - if (T_OPEN_TAG === $token[0]) { + if (\T_OPEN_TAG === $token[0]) { $ignoreSpace = true; } } diff --git a/Log/Logger.php b/Log/Logger.php index bbdd101d7d..509d1e293b 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -109,7 +109,7 @@ private function format($level, $message, array $context, $prefixDate = true) $message = strtr($message, $replacements); } - $log = sprintf('[%s] %s', $level, $message).PHP_EOL; + $log = sprintf('[%s] %s', $level, $message).\PHP_EOL; if ($prefixDate) { $log = date(\DateTime::RFC3339).' '.$log; } diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index 8589b96f57..c70830ae2f 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -58,7 +58,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null, $st } $file = fopen($file, 'r'); - fseek($file, 0, SEEK_END); + fseek($file, 0, \SEEK_END); $result = []; while (\count($result) < $limit && $line = $this->readLineFromFile($file)) { @@ -251,7 +251,7 @@ protected function readLineFromFile($file) $position += $upTo; $line = substr($buffer, $upTo + 1).$line; - fseek($file, max(0, $position), SEEK_SET); + fseek($file, max(0, $position), \SEEK_SET); if ('' !== $line) { break; diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index c510afa3e0..5cca92d765 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -212,7 +212,7 @@ public function set(array $collectors = []) public function add(DataCollectorInterface $collector) { if (!method_exists($collector, 'reset')) { - @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DataCollectorInterface::class, \get_class($collector)), E_USER_DEPRECATED); + @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', DataCollectorInterface::class, \get_class($collector)), \E_USER_DEPRECATED); } $this->collectors[$collector->getName()] = $collector; diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index b141c16d64..4cae90e919 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -100,8 +100,8 @@ public function testUploadedFile() $client = new Client($kernel); $files = [ - ['tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 1, 'error' => UPLOAD_ERR_OK], - new UploadedFile($source, 'original', 'mime/original', 1, UPLOAD_ERR_OK, true), + ['tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 1, 'error' => \UPLOAD_ERR_OK], + new UploadedFile($source, 'original', 'mime/original', 1, \UPLOAD_ERR_OK, true), ]; $file = null; @@ -131,7 +131,7 @@ public function testUploadedFileWhenNoFileSelected() $kernel = new TestHttpKernel(); $client = new Client($kernel); - $file = ['tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE]; + $file = ['tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => \UPLOAD_ERR_NO_FILE]; $client->request('POST', '/', [], ['foo' => $file]); @@ -150,14 +150,14 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs([$source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true]) + ->setConstructorArgs([$source, 'original', 'mime/original', 123, \UPLOAD_ERR_OK, true]) ->setMethods(['getSize']) ->getMock() ; $file->expects($this->once()) ->method('getSize') - ->willReturn(INF) + ->willReturn(\INF) ; $client->request('POST', '/', [], [$file]); @@ -169,7 +169,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $file = $files[0]; $this->assertFalse($file->isValid()); - $this->assertEquals(UPLOAD_ERR_INI_SIZE, $file->getError()); + $this->assertEquals(\UPLOAD_ERR_INI_SIZE, $file->getError()); $this->assertEquals('mime/original', $file->getClientMimeType()); $this->assertEquals('original', $file->getClientOriginalName()); $this->assertEquals(0, $file->getClientSize()); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index dc455915fa..3cfeed418c 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -31,16 +31,16 @@ public function testCollect() $this->assertTrue($c->isDebug()); $this->assertSame('config', $c->getName()); $this->assertSame('testkernel', $c->getAppName()); - $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); - $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); + $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION); + $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', \PHP_VERSION); $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); $this->assertNull($c->getToken()); $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); - $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); - $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); + $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); + $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); } } diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index b46357ed55..d6d230ef2f 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -113,14 +113,14 @@ public function getCollectTestData() yield 'logs with some deprecations' => [ 1, [ - ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo', 'context' => ['exception' => new \ErrorException('deprecated', 0, E_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo2', 'context' => ['exception' => new \ErrorException('deprecated', 0, E_USER_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, \E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo', 'context' => ['exception' => new \ErrorException('deprecated', 0, \E_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo2', 'context' => ['exception' => new \ErrorException('deprecated', 0, \E_USER_DEPRECATED)], 'priority' => 100, 'priorityName' => 'DEBUG'], ], [ - ['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo', 'context' => ['exception' => ['deprecated', E_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], - ['message' => 'foo2', 'context' => ['exception' => ['deprecated', E_USER_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], + ['message' => 'foo3', 'context' => ['exception' => ['warning', \E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo', 'context' => ['exception' => ['deprecated', \E_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], + ['message' => 'foo2', 'context' => ['exception' => ['deprecated', \E_USER_DEPRECATED]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false], ], 2, 0, @@ -130,14 +130,14 @@ public function getCollectTestData() yield 'logs with some silent errors' => [ 1, [ - ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, \E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(\E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => '0', 'context' => ['exception' => new SilencedErrorContext(\E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], ], [ - ['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], - ['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], - ['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], + ['message' => 'foo3', 'context' => ['exception' => ['warning', \E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => 'foo3', 'context' => ['exception' => [\E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], + ['message' => '0', 'context' => ['exception' => [\E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], ], 0, 2, diff --git a/Tests/EventListener/DebugHandlersListenerTest.php b/Tests/EventListener/DebugHandlersListenerTest.php index 44af0149f7..03cb14bddf 100644 --- a/Tests/EventListener/DebugHandlersListenerTest.php +++ b/Tests/EventListener/DebugHandlersListenerTest.php @@ -60,8 +60,8 @@ public function testConfigure() $loggers = $eHandler->setLoggers([]); - $this->assertArrayHasKey(E_DEPRECATED, $loggers); - $this->assertSame([$logger, LogLevel::INFO], $loggers[E_DEPRECATED]); + $this->assertArrayHasKey(\E_DEPRECATED, $loggers); + $this->assertSame([$logger, LogLevel::INFO], $loggers[\E_DEPRECATED]); } public function testConfigureForHttpKernelWithNoTerminateWithException() diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 444db71a3e..d080598fe8 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -129,8 +129,8 @@ public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822), 'Content-Type' => 'text/plain'], 'Hello World'); - $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(\DATE_RFC2822), 'Content-Type' => 'text/plain'], 'Hello World'); + $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); @@ -161,24 +161,24 @@ public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch( $this->setNextResponse(200, [], '', function ($request, $response) use ($time) { $response->setStatusCode(200); $response->headers->set('ETag', '12345'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); $response->headers->set('Content-Type', 'text/plain'); $response->setContent('Hello World'); }); // only ETag matches $t = \DateTime::createFromFormat('U', time() - 3600); - $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); // only Last-Modified matches - $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); // Both matches - $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); } @@ -257,7 +257,7 @@ public function testStoresResponsesWhenNoCacheRequestDirectivePresent() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'no-cache']); $this->assertHttpKernelIsCalled(); @@ -393,7 +393,7 @@ public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIs public function testFetchesResponseFromBackendWhenCacheMisses() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -405,7 +405,7 @@ public function testDoesNotCacheSomeStatusCodeResponses() { foreach (array_merge(range(201, 202), range(204, 206), range(303, 305), range(400, 403), range(405, 409), range(411, 417), range(500, 505)) as $code) { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse($code, ['Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse($code, ['Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals($code, $this->response->getStatusCode()); @@ -417,7 +417,7 @@ public function testDoesNotCacheSomeStatusCodeResponses() public function testDoesNotCacheResponsesWithExplicitNoStoreDirective() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'no-store']); + $this->setNextResponse(200, ['Expires' => $time->format(\DATE_RFC2822), 'Cache-Control' => 'no-store']); $this->request('GET', '/'); $this->assertTraceNotContains('store'); @@ -436,7 +436,7 @@ public function testDoesNotCacheResponsesWithoutFreshnessInformationOrAValidator public function testCachesResponsesWithExplicitNoCacheDirective() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Expires' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, no-cache']); + $this->setNextResponse(200, ['Expires' => $time->format(\DATE_RFC2822), 'Cache-Control' => 'public, no-cache']); $this->request('GET', '/'); $this->assertTraceContains('store'); @@ -462,7 +462,7 @@ public function testRevalidatesResponsesWithNoCacheDirectiveEvenIfFresh() public function testCachesResponsesWithAnExpirationHeader() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -511,7 +511,7 @@ public function testCachesResponsesWithASMaxAgeDirective() public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInformation() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Last-Modified' => $time->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -535,7 +535,7 @@ public function testHitsCachedResponsesWithExpiresHeader() { $time1 = \DateTime::createFromFormat('U', time() - 5); $time2 = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Date' => $time1->format(DATE_RFC2822), 'Expires' => $time2->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Date' => $time1->format(\DATE_RFC2822), 'Expires' => $time2->format(\DATE_RFC2822)]); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); @@ -559,7 +559,7 @@ public function testHitsCachedResponsesWithExpiresHeader() public function testHitsCachedResponseWithMaxAgeDirective() { $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, ['Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 'public, max-age=10']); + $this->setNextResponse(200, ['Date' => $time->format(\DATE_RFC2822), 'Cache-Control' => 'public, max-age=10']); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); @@ -623,7 +623,7 @@ public function testDegradationWhenCacheLocked() public function testHitsCachedResponseWithSMaxAgeDirective() { $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, ['Date' => $time->format(DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0']); + $this->setNextResponse(200, ['Date' => $time->format(\DATE_RFC2822), 'Cache-Control' => 's-maxage=10, max-age=0']); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); @@ -691,7 +691,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertCount(1, $values); $tmp = unserialize($values[0]); $time = \DateTime::createFromFormat('U', time() - 5); - $tmp[0][1]['date'] = $time->format(DATE_RFC2822); + $tmp[0][1]['date'] = $time->format(\DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); @@ -741,7 +741,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertCount(1, $values); $tmp = unserialize($values[0]); $time = \DateTime::createFromFormat('U', time() - 5); - $tmp[0][1]['date'] = $time->format(DATE_RFC2822); + $tmp[0][1]['date'] = $time->format(\DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); @@ -783,7 +783,7 @@ public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirectiv public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(\DATE_RFC2822)]); // build initial request $this->request('GET', '/'); @@ -801,7 +801,7 @@ public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() $this->assertCount(1, $values); $tmp = unserialize($values[0]); $time = \DateTime::createFromFormat('U', time()); - $tmp[0][1]['expires'] = $time->format(DATE_RFC2822); + $tmp[0][1]['expires'] = $time->format(\DATE_RFC2822); $r = new \ReflectionObject($this->store); $m = $r->getMethod('save'); $m->setAccessible(true); @@ -825,8 +825,8 @@ public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInform $time = \DateTime::createFromFormat('U', time()); $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time) { $response->headers->set('Cache-Control', 'public'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); - if ($time->format(DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); + if ($time->format(\DATE_RFC2822) == $request->headers->get('IF_MODIFIED_SINCE')) { $response->setStatusCode(304); $response->setContent(''); } @@ -914,7 +914,7 @@ public function testServesResponseWhileFreshAndRevalidatesWithLastModifiedInform $this->setNextResponse(200, [], 'Hello World', function (Request $request, Response $response) use ($time) { $response->setSharedMaxAge(10); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); }); // prime the cache @@ -931,7 +931,7 @@ public function testServesResponseWhileFreshAndRevalidatesWithLastModifiedInform sleep(15); // expire the cache $this->setNextResponse(304, [], '', function (Request $request, Response $response) use ($time) { - $this->assertEquals($time->format(DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE')); + $this->assertEquals($time->format(\DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE')); }); $this->request('GET', '/'); @@ -947,7 +947,7 @@ public function testReplacesCachedResponsesWhenValidationResultsInNon304Response $time = \DateTime::createFromFormat('U', time()); $count = 0; $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time, &$count) { - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); $response->headers->set('Cache-Control', 'public'); switch (++$count) { case 1: @@ -1019,14 +1019,14 @@ public function testSendsNoContentWhenFresh() $time = \DateTime::createFromFormat('U', time()); $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time) { $response->headers->set('Cache-Control', 'public, max-age=10'); - $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); + $response->headers->set('Last-Modified', $time->format(\DATE_RFC2822)); }); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); $this->assertEquals('Hello World', $this->response->getContent()); - $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(304, $this->response->getStatusCode()); $this->assertEquals('', $this->response->getContent()); @@ -1427,7 +1427,7 @@ public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses() 'headers' => [ 'Surrogate-Control' => 'content="ESI/1.0"', 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), + 'Last-Modified' => $time->format(\DATE_RFC2822), ], ], [ @@ -1455,7 +1455,7 @@ public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponsesAndHeadReq 'headers' => [ 'Surrogate-Control' => 'content="ESI/1.0"', 'ETag' => 'hey', - 'Last-Modified' => $time->format(DATE_RFC2822), + 'Last-Modified' => $time->format(\DATE_RFC2822), ], ], [ diff --git a/Tests/Log/LoggerTest.php b/Tests/Log/LoggerTest.php index 79039c1c97..fd304579e1 100644 --- a/Tests/Log/LoggerTest.php +++ b/Tests/Log/LoggerTest.php @@ -59,7 +59,7 @@ public static function assertLogsMatch(array $expected, array $given) */ public function getLogs() { - return file($this->tmpFile, FILE_IGNORE_NEW_LINES); + return file($this->tmpFile, \FILE_IGNORE_NEW_LINES); } public function testImplements() @@ -186,7 +186,7 @@ public function testContextExceptionKeyCanBeExceptionOrOtherValues() public function testFormatter() { $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile, function ($level, $message, $context) { - return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).PHP_EOL; + return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).\PHP_EOL; }); $this->logger->error('An error', ['foo' => 'bar']); diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index 4e23f13b02..5d817acee2 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -329,7 +329,7 @@ public function testReadLineFromFile() $h = tmpfile(); fwrite($h, "line1\n\n\nline2\n"); - fseek($h, 0, SEEK_END); + fseek($h, 0, \SEEK_END); $this->assertEquals('line2', $r->invoke($this->storage, $h)); $this->assertEquals('line1', $r->invoke($this->storage, $h)); diff --git a/UriSigner.php b/UriSigner.php index ffe31a2121..3927f10114 100644 --- a/UriSigner.php +++ b/UriSigner.php @@ -89,7 +89,7 @@ private function computeHash($uri) private function buildUrl(array $url, array $params = []) { - ksort($params, SORT_STRING); + ksort($params, \SORT_STRING); $url['query'] = http_build_query($params, '', '&'); $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; From 91147206512280859f5f0fe029c4df56ffa201c1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 6 Sep 2020 23:24:45 +0200 Subject: [PATCH 089/266] [HttpKernel] Adjust tests to new "class not found" error message format. --- Tests/Controller/ControllerResolverTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index d5ac4ad5c2..de6dfc2546 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -170,9 +170,9 @@ public function getUndefinedControllers() $controller = new ControllerTest(); return [ - ['foo', \Error::class, 'Class \'foo\' not found'], - ['oof::bar', \Error::class, 'Class \'oof\' not found'], - [['oof', 'bar'], \Error::class, 'Class \'oof\' not found'], + ['foo', \Error::class, \PHP_VERSION_ID < 80000 ? 'Class \'foo\' not found' : 'Class "foo" not found'], + ['oof::bar', \Error::class, \PHP_VERSION_ID < 80000 ? 'Class \'oof\' not found' : 'Class "oof" not found'], + [['oof', 'bar'], \Error::class, \PHP_VERSION_ID < 80000 ? 'Class \'oof\' not found' : 'Class "oof" not found'], ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', \InvalidArgumentException::class, 'The controller for URI "/" is not callable: Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'], ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', \InvalidArgumentException::class, 'The controller for URI "/" is not callable: Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', \InvalidArgumentException::class, 'The controller for URI "/" is not callable: Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], From 5e67d95d6290dbbb663e125f50636b03d040337d Mon Sep 17 00:00:00 2001 From: David Molineus Date: Wed, 16 Sep 2020 17:27:48 +0200 Subject: [PATCH 090/266] [HttpKernel] Do not override max_redirects option in HttpClientKernel --- HttpClientKernel.php | 3 +-- Tests/HttpClientKernelTest.php | 46 ++++++++++++++++++++++++++++++++++ composer.json | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 Tests/HttpClientKernelTest.php diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 2056a673a6..7acb04c893 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -35,7 +35,7 @@ final class HttpClientKernel implements HttpKernelInterface public function __construct(HttpClientInterface $client = null) { - if (!class_exists(HttpClient::class)) { + if (null === $client && !class_exists(HttpClient::class)) { throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); } @@ -53,7 +53,6 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $response = $this->client->request($request->getMethod(), $request->getUri(), [ 'headers' => $headers, 'body' => $body, - 'max_redirects' => 0, ] + $request->attributes->get('http_client_options', [])); $response = new Response($response->getContent(!$catch), $response->getStatusCode(), $response->getHeaders(!$catch)); diff --git a/Tests/HttpClientKernelTest.php b/Tests/HttpClientKernelTest.php new file mode 100644 index 0000000000..2b904bf9a2 --- /dev/null +++ b/Tests/HttpClientKernelTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpClientKernel; +use Symfony\Contracts\HttpClient\HttpClientInterface; +use Symfony\Contracts\HttpClient\ResponseInterface; + +class HttpClientKernelTest extends TestCase +{ + public function testHandlePassesMaxRedirectsHttpClientOption() + { + $request = new Request(); + $request->attributes->set('http_client_options', ['max_redirects' => 50]); + + $response = $this->getMockBuilder(ResponseInterface::class)->getMock(); + $response->expects($this->once())->method('getStatusCode')->willReturn(200); + + $client = $this->getMockBuilder(HttpClientInterface::class)->getMock(); + $client + ->expects($this->once()) + ->method('request') + ->willReturnCallback(function (string $method, string $uri, array $options) use ($request, $response) { + $this->assertSame($request->getMethod(), $method); + $this->assertSame($request->getUri(), $uri); + $this->assertArrayHasKey('max_redirects', $options); + $this->assertSame(50, $options['max_redirects']); + + return $response; + }); + + $kernel = new HttpClientKernel($client); + $kernel->handle($request); + } +} diff --git a/composer.json b/composer.json index 2ae07df884..1dce985571 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "php": ">=7.1.3", "symfony/error-handler": "^4.4", "symfony/event-dispatcher": "^4.4", + "symfony/http-client-contracts": "^1.1|^2", "symfony/http-foundation": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", From 1f09d9eec88dd6d141f4d37751bc035da6a47418 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Sep 2020 05:46:58 +0200 Subject: [PATCH 091/266] Update VERSION for 3.4.45 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index de9025061a..d5d65bf69f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.45-DEV'; + const VERSION = '3.4.45'; const VERSION_ID = 30445; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 45; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 06ea93c980380a48a661a25c2360177766737b51 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Sep 2020 06:03:03 +0200 Subject: [PATCH 092/266] Bump Symfony version to 3.4.46 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d5d65bf69f..4c2040e349 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.45'; - const VERSION_ID = 30445; + const VERSION = '3.4.46-DEV'; + const VERSION_ID = 30446; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 45; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 46; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From e3eac6daeb0c65965a6201bd2de9564a802fe0a9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Sep 2020 06:25:44 +0200 Subject: [PATCH 093/266] Update VERSION for 4.4.14 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 79378914d3..a0cb941908 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.14-DEV'; + const VERSION = '4.4.14'; const VERSION_ID = 40414; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 14; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 543b3ba9f0feabb1f03c4b5e150c901c39d8075e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Sep 2020 06:29:46 +0200 Subject: [PATCH 094/266] Bump Symfony version to 4.4.15 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a0cb941908..7816b6ce3b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.14'; - const VERSION_ID = 40414; + const VERSION = '4.4.15-DEV'; + const VERSION_ID = 40415; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 14; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 15; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 6544745997b06c7dcecf0d4a70f09e5de1db7ca8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 4 Oct 2020 09:48:13 +0200 Subject: [PATCH 095/266] Update VERSION for 4.4.15 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7816b6ce3b..26720d4b0e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.15-DEV'; + const VERSION = '4.4.15'; const VERSION_ID = 40415; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 15; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 27e31b609d8c70928300f70e28e74ccacbb009f6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 4 Oct 2020 09:55:30 +0200 Subject: [PATCH 096/266] Bump Symfony version to 4.4.16 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 26720d4b0e..d5bf69ea73 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.15'; - const VERSION_ID = 40415; + const VERSION = '4.4.16-DEV'; + const VERSION_ID = 40416; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 15; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 16; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 9a86870909b09c0ce36f029f786790229fe1598d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2020 13:13:36 +0200 Subject: [PATCH 097/266] Remove "branch-alias", populate "version" --- composer.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 7f471c680e..b1d4b7bc61 100644 --- a/composer.json +++ b/composer.json @@ -66,9 +66,5 @@ ] }, "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } + "version": "3.4-dev" } From 2934f07ca62230531d51e905f48d4b20cfe46def Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 6 Oct 2020 16:37:11 +0200 Subject: [PATCH 098/266] Update versions in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b1d4b7bc61..a2961007d7 100644 --- a/composer.json +++ b/composer.json @@ -66,5 +66,5 @@ ] }, "minimum-stability": "dev", - "version": "3.4-dev" + "version": "3.4.x-dev" } From 4a3f2b74eab3dae7fe6f735f90f233c714e03770 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 7 Oct 2020 14:58:11 +0200 Subject: [PATCH 099/266] Remove "version" from composer.json files, use "branch-version" instead --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a2961007d7..388fff70d0 100644 --- a/composer.json +++ b/composer.json @@ -66,5 +66,7 @@ ] }, "minimum-stability": "dev", - "version": "3.4.x-dev" + "extra": { + "branch-version": "3.4-dev" + } } From d4483d4176202eee11fadfc51782280eb522f29e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 13 Oct 2020 15:20:16 +0200 Subject: [PATCH 100/266] Fix branch-version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 388fff70d0..94e77c6b36 100644 --- a/composer.json +++ b/composer.json @@ -67,6 +67,6 @@ }, "minimum-stability": "dev", "extra": { - "branch-version": "3.4-dev" + "branch-version": "3.4" } } From e3512ba92ea313e903b9ed7dd40bcf64b1f346f1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 24 Oct 2020 12:23:57 +0200 Subject: [PATCH 101/266] Remove branch-version (keep them for contracts only) --- composer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 94e77c6b36..06a67607ec 100644 --- a/composer.json +++ b/composer.json @@ -65,8 +65,5 @@ "/Tests/" ] }, - "minimum-stability": "dev", - "extra": { - "branch-version": "3.4" - } + "minimum-stability": "dev" } From bd2d874eac07ef2d7cffc20120482654fe6a00f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 25 Oct 2020 21:41:30 +0100 Subject: [PATCH 102/266] Fix transient tests --- Tests/HttpCache/ResponseCacheStrategyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index 22cadf7129..fd67af368b 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -216,7 +216,7 @@ public function testResponseIsExiprableWhenEmbeddedResponseCombinesExpiryAndVali $cacheStrategy->add($embeddedResponse); $cacheStrategy->update($masterResponse); - $this->assertSame('60', $masterResponse->headers->getCacheControlDirective('s-maxage')); + $this->assertEqualsWithDelta(60, (int) $masterResponse->headers->getCacheControlDirective('s-maxage'), 1); } public function testResponseIsExpirableButNotValidateableWhenMasterResponseCombinesExpirationAndValidation() From 109b2a46e470a487ec8b0ffea4b0bb993aaf42ed Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 28 Oct 2020 06:50:56 +0100 Subject: [PATCH 103/266] Update VERSION for 4.4.16 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index d5bf69ea73..c21108b040 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.16-DEV'; + const VERSION = '4.4.16'; const VERSION_ID = 40416; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 16; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 3cb45dc339f5102d5af9d1c252adcfd19450c19c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 28 Oct 2020 06:54:40 +0100 Subject: [PATCH 104/266] Bump Symfony version to 4.4.17 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index c21108b040..079d375aba 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.16'; - const VERSION_ID = 40416; + const VERSION = '4.4.17-DEV'; + const VERSION_ID = 40417; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 16; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 17; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From c77a26800864b7b69fba9329a7d740508cf12f20 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 28 Oct 2020 08:52:32 +0100 Subject: [PATCH 105/266] Use short array deconstruction syntax. --- Controller/ControllerResolver.php | 4 ++-- DataCollector/DumpDataCollector.php | 2 +- .../RegisterControllerArgumentLocatorsPass.php | 6 +++--- .../RemoveEmptyControllerArgumentLocatorsPass.php | 4 ++-- Kernel.php | 4 ++-- Profiler/FileProfilerStorage.php | 2 +- .../ControllerArgumentValueResolverPassTest.php | 4 ++-- Tests/HttpCache/StoreTest.php | 4 ++-- Tests/HttpCache/TestHttpKernel.php | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 44f34d8ee8..9c2fdd9807 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -116,7 +116,7 @@ protected function createController($controller) return $controller; } - list($class, $method) = explode('::', $controller, 2); + [$class, $method] = explode('::', $controller, 2); try { $controller = [$this->instantiateController($class), $method]; @@ -176,7 +176,7 @@ private function getControllerError($callable): string return 'Invalid array callable, expected [controller, method].'; } - list($controller, $method) = $callable; + [$controller, $method] = $callable; if (\is_string($controller) && !class_exists($controller)) { return sprintf('Class "%s" does not exist.', $controller); diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 4e430f8f37..f864e355f9 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -75,7 +75,7 @@ public function dump(Data $data) $this->stopwatch->start('dump'); } - list('name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt) = $this->sourceContextProvider->getContext(); + ['name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt] = $this->sourceContextProvider->getContext(); if ($this->dumper instanceof Connection) { if (!$this->dumper->write($data)) { diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index f214fd125a..40c850cf66 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -99,7 +99,7 @@ public function process(ContainerBuilder $container) if (!isset($methods[$action = strtolower($attributes['action'])])) { throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "%s" for service "%s": no public "%s()" method found on class "%s".', $this->controllerTag, $id, $attributes['action'], $class)); } - list($r, $parameters) = $methods[$action]; + [$r, $parameters] = $methods[$action]; $found = false; foreach ($parameters as $p) { @@ -117,7 +117,7 @@ public function process(ContainerBuilder $container) } } - foreach ($methods as list($r, $parameters)) { + foreach ($methods as [$r, $parameters]) { /** @var \ReflectionMethod $r */ // create a per-method map of argument-names to service/type-references @@ -139,7 +139,7 @@ public function process(ContainerBuilder $container) } elseif (isset($bindings[$bindingName = $type.' $'.$p->name]) || isset($bindings[$bindingName = '$'.$p->name]) || isset($bindings[$bindingName = $type])) { $binding = $bindings[$bindingName]; - list($bindingValue, $bindingId, , $bindingType, $bindingFile) = $binding->getValues(); + [$bindingValue, $bindingId, , $bindingType, $bindingFile] = $binding->getValues(); $binding->setValues([$bindingValue, $bindingId, true, $bindingType, $bindingFile]); if (!$bindingValue instanceof Reference) { diff --git a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php index 596b6188f6..c09f2bfdf3 100644 --- a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php @@ -42,9 +42,9 @@ public function process(ContainerBuilder $container) } else { // any methods listed for call-at-instantiation cannot be actions $reason = false; - list($id, $action) = explode('::', $controller); + [$id, $action] = explode('::', $controller); $controllerDef = $container->getDefinition($id); - foreach ($controllerDef->getMethodCalls() as list($method)) { + foreach ($controllerDef->getMethodCalls() as [$method]) { if (0 === strcasecmp($action, $method)) { $reason = sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id); break; diff --git a/Kernel.php b/Kernel.php index 079d375aba..746eec8869 100644 --- a/Kernel.php +++ b/Kernel.php @@ -262,7 +262,7 @@ public function locateResource($name/*, $dir = null, $first = true, $triggerDepr $bundleName = substr($name, 1); $path = ''; if (false !== strpos($bundleName, '/')) { - list($bundleName, $path) = explode('/', $bundleName, 2); + [$bundleName, $path] = explode('/', $bundleName, 2); } $isResource = 0 === strpos($path, 'Resources') && null !== $dir; @@ -893,7 +893,7 @@ public function serialize() public function unserialize($data) { @trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED); - list($environment, $debug) = unserialize($data, ['allowed_classes' => false]); + [$environment, $debug] = unserialize($data, ['allowed_classes' => false]); $this->__construct($environment, $debug); } diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index 5f23e5e05d..b74563ac13 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -61,7 +61,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null, $st $result = []; while (\count($result) < $limit && $line = $this->readLineFromFile($file)) { $values = str_getcsv($line); - list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values; + [$csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode] = $values; $csvTime = (int) $csvTime; if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method) || $statusCode && false === strpos($csvStatusCode, $statusCode)) { diff --git a/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php b/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php index 2694d002cf..c95a7fb524 100644 --- a/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php +++ b/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php @@ -39,7 +39,7 @@ public function testServicesAreOrderedAccordingToPriority() $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); - foreach ($services as $id => list($tag)) { + foreach ($services as $id => [$tag]) { $container->register($id)->addTag('controller.argument_value_resolver', $tag); } @@ -72,7 +72,7 @@ public function testInDebugWithStopWatchDefinition() $container->register('debug.stopwatch', Stopwatch::class); $container->setDefinition('argument_resolver', $definition); - foreach ($services as $id => list($tag)) { + foreach ($services as $id => [$tag]) { $container->register($id)->addTag('controller.argument_value_resolver', $tag); } diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 1f5f472802..fc1ef64663 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -92,7 +92,7 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring() { $cacheKey = $this->storeSimpleEntry(); $entries = $this->getStoreMetadata($cacheKey); - list(, $res) = $entries[0]; + [, $res] = $entries[0]; $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); } @@ -103,7 +103,7 @@ public function testDoesNotTrustXContentDigestFromUpstream() $cacheKey = $this->store->write($this->request, $response); $entries = $this->getStoreMetadata($cacheKey); - list(, $res) = $entries[0]; + [, $res] = $entries[0]; $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $response->headers->get('X-Content-Digest')); diff --git a/Tests/HttpCache/TestHttpKernel.php b/Tests/HttpCache/TestHttpKernel.php index 5b204d8269..c116c31b65 100644 --- a/Tests/HttpCache/TestHttpKernel.php +++ b/Tests/HttpCache/TestHttpKernel.php @@ -43,13 +43,13 @@ public function assert(\Closure $callback) { $trustedConfig = [Request::getTrustedProxies(), Request::getTrustedHeaderSet()]; - list($trustedProxies, $trustedHeaderSet, $backendRequest) = $this->backendRequest; + [$trustedProxies, $trustedHeaderSet, $backendRequest] = $this->backendRequest; Request::setTrustedProxies($trustedProxies, $trustedHeaderSet); try { $callback($backendRequest); } finally { - list($trustedProxies, $trustedHeaderSet) = $trustedConfig; + [$trustedProxies, $trustedHeaderSet] = $trustedConfig; Request::setTrustedProxies($trustedProxies, $trustedHeaderSet); } } From aab798445a46e1ac8d417a90c89b9377109c588d Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 30 Oct 2020 14:31:03 +0100 Subject: [PATCH 106/266] Remove Symfony 3 compatibility code. --- EventListener/AbstractSessionListener.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 0a6789d85a..3da47dd8d0 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -55,12 +55,8 @@ public function onKernelRequest(GetResponseEvent $event) $session = null; $request = $event->getRequest(); - if ($request->hasSession()) { - // no-op - } elseif (method_exists($request, 'setSessionFactory')) { + if (!$request->hasSession()) { $request->setSessionFactory(function () { return $this->getSession(); }); - } elseif ($session = $this->getSession()) { - $request->setSession($session); } $session = $session ?? ($this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : null); From 615304c758744b5869bbef2de42066eb4cdbdcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Fri, 30 Oct 2020 21:47:32 +0100 Subject: [PATCH 107/266] Fix session called initized several time --- EventListener/AbstractSessionListener.php | 3 +- Tests/EventListener/SessionListenerTest.php | 34 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 3da47dd8d0..ce38d88608 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -56,7 +56,8 @@ public function onKernelRequest(GetResponseEvent $event) $session = null; $request = $event->getRequest(); if (!$request->hasSession()) { - $request->setSessionFactory(function () { return $this->getSession(); }); + $sess = null; + $request->setSessionFactory(function () use (&$sess) { return $sess ?? $sess = $this->getSession(); }); } $session = $session ?? ($this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : null); diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 8fc9f6bc9c..b3799bdb41 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -20,11 +20,13 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; use Symfony\Component\HttpKernel\EventListener\SessionListener; use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\KernelInterface; class SessionListenerTest extends TestCase { @@ -178,4 +180,36 @@ public function testSurrogateMasterRequestIsPublic() $this->assertTrue($response->headers->has('Expires')); $this->assertLessThanOrEqual((new \DateTime('now', new \DateTimeZone('UTC'))), (new \DateTime($response->headers->get('Expires')))); } + + public function testGetSessionIsCalledOnce() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $sessionStorage = $this->getMockBuilder(NativeSessionStorage::class)->getMock(); + $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); + + $sessionStorage->expects($this->once()) + ->method('setOptions') + ->with(['cookie_secure' => true]); + + $requestStack = new RequestStack(); + $requestStack->push($masterRequest = new Request([], [], [], [], [], ['HTTPS' => 'on'])); + + $container = new Container(); + $container->set('session_storage', $sessionStorage); + $container->set('session', $session); + $container->set('request_stack', $requestStack); + + $event = new GetResponseEvent($kernel, $masterRequest, HttpKernelInterface::MASTER_REQUEST); + + $listener = new SessionListener($container); + $listener->onKernelRequest($event); + + $subRequest = $masterRequest->duplicate(); + // at this point both master and subrequest have a closure to build the session + + $masterRequest->getSession(); + + // calling the factory on the subRequest should not trigger a second call to storage->sesOptions() + $subRequest->getSession(); + } } From 6bf4e638a73c873811e8f1b2f2d5abf505376e2e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 2 Nov 2020 17:05:56 +0100 Subject: [PATCH 108/266] [HttpKernel] fix merge --- Tests/EventListener/SessionListenerTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index b3799bdb41..8131ff2ea1 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -20,7 +20,6 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; @@ -199,7 +198,7 @@ public function testGetSessionIsCalledOnce() $container->set('session', $session); $container->set('request_stack', $requestStack); - $event = new GetResponseEvent($kernel, $masterRequest, HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($kernel, $masterRequest, HttpKernelInterface::MASTER_REQUEST); $listener = new SessionListener($container); $listener->onKernelRequest($event); From bfe099ec08ee84a1c228754435018cf5b96bd492 Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Fri, 13 Nov 2020 13:20:22 +0100 Subject: [PATCH 109/266] Update ExceptionEvent.php --- Event/ExceptionEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Event/ExceptionEvent.php b/Event/ExceptionEvent.php index 3dae0d4ce6..313a3615b2 100644 --- a/Event/ExceptionEvent.php +++ b/Event/ExceptionEvent.php @@ -18,7 +18,7 @@ * current request. The propagation of this event is stopped as soon as a * response is set. * - * You can also call setException() to replace the thrown exception. This + * You can also call setThrowable() to replace the thrown exception. This * exception will be thrown if no response is set during processing of this * event. * From 7b7dd57b262a20c6bca60a28d2b3ee6b7e5479fd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 17 Nov 2020 19:23:27 +0100 Subject: [PATCH 110/266] do not depend on the actual time to fix a transient test --- Tests/HttpCache/ResponseCacheStrategyTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index fd67af368b..62179ba154 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -239,6 +239,7 @@ public function testResponseIsExpirableButNotValidateableWhenMasterResponseCombi } /** + * @group time-sensitive * @dataProvider cacheControlMergingProvider */ public function testCacheControlMerging(array $expects, array $master, array $surrogates) From 9f5605ee05406d8afa40dc4f2954c6a61de3a984 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 29 Nov 2020 10:23:08 +0100 Subject: [PATCH 111/266] Update VERSION for 4.4.17 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 746eec8869..88b77741c5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.17-DEV'; + const VERSION = '4.4.17'; const VERSION_ID = 40417; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 17; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 2a35d1406f69921a5d3d0ed8545f45a26c26f64b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 29 Nov 2020 10:27:10 +0100 Subject: [PATCH 112/266] Bump Symfony version to 4.4.18 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 88b77741c5..cda7223b9a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.17'; - const VERSION_ID = 40417; + const VERSION = '4.4.18-DEV'; + const VERSION_ID = 40418; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 17; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 18; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 9a66282aafef9f6a3eef662bdc10657126c090f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Auswo=CC=88ger?= Date: Sun, 29 Nov 2020 22:21:38 +0100 Subject: [PATCH 113/266] Fix bug with whitespace in Kernel::stripComments() --- Kernel.php | 5 +++++ Tests/KernelTest.php | 51 ++++++++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Kernel.php b/Kernel.php index cda7223b9a..2eaf01573a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -858,6 +858,9 @@ public static function stripComments($source) // replace multiple new lines with a single newline $rawChunk .= preg_replace(['/\n{2,}/S'], "\n", $token[1]); } elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) { + if (!\in_array($rawChunk[\strlen($rawChunk) - 1], [' ', "\n", "\r", "\t"], true)) { + $rawChunk .= ' '; + } $ignoreSpace = true; } else { $rawChunk .= $token[1]; @@ -865,6 +868,8 @@ public static function stripComments($source) // The PHP-open tag already has a new-line if (\T_OPEN_TAG === $token[0]) { $ignoreSpace = true; + } else { + $ignoreSpace = false; } } } diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index b4075c98ba..2b486e6673 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -239,10 +239,37 @@ public function testHandleBootsTheKernel() $kernel->handle($request, $type, $catch); } - public function testStripComments() + /** + * @dataProvider getStripCommentsCodes + */ + public function testStripComments(string $source, string $expected) + { + $output = Kernel::stripComments($source); + + // Heredocs are preserved, making the output mixing Unix and Windows line + // endings, switching to "\n" everywhere on Windows to avoid failure. + if ('\\' === \DIRECTORY_SEPARATOR) { + $expected = str_replace("\r\n", "\n", $expected); + $output = str_replace("\r\n", "\n", $output); + } + + $this->assertEquals($expected, $output); + } + + public function getStripCommentsCodes(): array { - $source = <<<'EOF' + return [ + ['assertEquals($expected, $output); +EOF + ], + ]; } /** From 2292c59f379d35f505093dc0cb439d30e76348bc Mon Sep 17 00:00:00 2001 From: kick-the-bucket Date: Mon, 30 Nov 2020 18:59:21 +0200 Subject: [PATCH 114/266] Remove unused @throws tags and handling of never thrown exceptions --- DataCollector/RequestDataCollector.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index ba68c6b99a..56bc6ec194 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -53,12 +53,7 @@ public function collect(Request $request, Response $response/*, \Throwable $exce } } - try { - $content = $request->getContent(); - } catch (\LogicException $e) { - // the user already got the request content as a resource - $content = false; - } + $content = $request->getContent(); $sessionMetadata = []; $sessionAttributes = []; From 1eb9998bf3877878cfea68fa594316300945e8fa Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 8 Dec 2020 17:59:59 +0100 Subject: [PATCH 115/266] Apply "visibility_required" CS rule to constants php-cs-fixer fix --rules='{"visibility_required": ["property", "method", "const"]}' --- EventListener/AbstractSessionListener.php | 2 +- HttpKernelInterface.php | 4 ++-- Kernel.php | 18 +++++++++--------- KernelEvents.php | 16 ++++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index ce38d88608..0e99ee55c2 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -37,7 +37,7 @@ */ abstract class AbstractSessionListener implements EventSubscriberInterface { - const NO_AUTO_CACHE_CONTROL_HEADER = 'Symfony-Session-NoAutoCacheControl'; + public const NO_AUTO_CACHE_CONTROL_HEADER = 'Symfony-Session-NoAutoCacheControl'; protected $container; private $sessionUsageStack = []; diff --git a/HttpKernelInterface.php b/HttpKernelInterface.php index 7595d29d04..85fedbbe26 100644 --- a/HttpKernelInterface.php +++ b/HttpKernelInterface.php @@ -21,8 +21,8 @@ */ interface HttpKernelInterface { - const MASTER_REQUEST = 1; - const SUB_REQUEST = 2; + public const MASTER_REQUEST = 1; + public const SUB_REQUEST = 2; /** * Handles a Request to convert it to a Response. diff --git a/Kernel.php b/Kernel.php index 2eaf01573a..18fbb9ebe7 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,15 +76,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.18-DEV'; - const VERSION_ID = 40418; - const MAJOR_VERSION = 4; - const MINOR_VERSION = 4; - const RELEASE_VERSION = 18; - const EXTRA_VERSION = 'DEV'; - - const END_OF_MAINTENANCE = '11/2022'; - const END_OF_LIFE = '11/2023'; + public const VERSION = '4.4.18-DEV'; + public const VERSION_ID = 40418; + public const MAJOR_VERSION = 4; + public const MINOR_VERSION = 4; + public const RELEASE_VERSION = 18; + public const EXTRA_VERSION = 'DEV'; + + public const END_OF_MAINTENANCE = '11/2022'; + public const END_OF_LIFE = '11/2023'; public function __construct(string $environment, bool $debug) { diff --git a/KernelEvents.php b/KernelEvents.php index 682561c324..b16141c602 100644 --- a/KernelEvents.php +++ b/KernelEvents.php @@ -27,7 +27,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\RequestEvent") */ - const REQUEST = 'kernel.request'; + public const REQUEST = 'kernel.request'; /** * The EXCEPTION event occurs when an uncaught exception appears. @@ -37,7 +37,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\ExceptionEvent") */ - const EXCEPTION = 'kernel.exception'; + public const EXCEPTION = 'kernel.exception'; /** * The VIEW event occurs when the return value of a controller @@ -48,7 +48,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\ViewEvent") */ - const VIEW = 'kernel.view'; + public const VIEW = 'kernel.view'; /** * The CONTROLLER event occurs once a controller was found for @@ -59,7 +59,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\ControllerEvent") */ - const CONTROLLER = 'kernel.controller'; + public const CONTROLLER = 'kernel.controller'; /** * The CONTROLLER_ARGUMENTS event occurs once controller arguments have been resolved. @@ -69,7 +69,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent") */ - const CONTROLLER_ARGUMENTS = 'kernel.controller_arguments'; + public const CONTROLLER_ARGUMENTS = 'kernel.controller_arguments'; /** * The RESPONSE event occurs once a response was created for @@ -80,7 +80,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\ResponseEvent") */ - const RESPONSE = 'kernel.response'; + public const RESPONSE = 'kernel.response'; /** * The TERMINATE event occurs once a response was sent. @@ -89,7 +89,7 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\TerminateEvent") */ - const TERMINATE = 'kernel.terminate'; + public const TERMINATE = 'kernel.terminate'; /** * The FINISH_REQUEST event occurs when a response was generated for a request. @@ -99,5 +99,5 @@ final class KernelEvents * * @Event("Symfony\Component\HttpKernel\Event\FinishRequestEvent") */ - const FINISH_REQUEST = 'kernel.finish_request'; + public const FINISH_REQUEST = 'kernel.finish_request'; } From dc6703d71c0d80d24aa0114353d7c97b231f5b83 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 9 Dec 2020 11:47:41 +0100 Subject: [PATCH 116/266] Add missing param annotation abouts $fileLinkFormat --- DataCollector/DumpDataCollector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index f864e355f9..df4ec5f670 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Cloner\VarCloner; @@ -43,6 +44,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface private $sourceContextProvider; /** + * @param string|FileLinkFormatter|null $fileLinkFormat * @param DataDumperInterface|Connection|null $dumper */ public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, $dumper = null) From b5c5333a197df480370b6f5fc2f293ef0d624d98 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 11 Dec 2020 13:39:31 +0100 Subject: [PATCH 117/266] Remove void return type from test methods --- Tests/KernelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 2b486e6673..18974a720b 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -663,7 +663,7 @@ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() $this->assertGreaterThan($preReBoot, $kernel->getStartTime()); } - public function testAnonymousKernelGeneratesValidContainerClass(): void + public function testAnonymousKernelGeneratesValidContainerClass() { $kernel = new class('test', true) extends Kernel { public function registerBundles(): iterable From eaff9a43e74513508867ecfa66ef94fbb96ab128 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 18 Dec 2020 14:32:33 +0100 Subject: [PATCH 118/266] Update VERSION for 4.4.18 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 18fbb9ebe7..d0ea1ff626 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.18-DEV'; + public const VERSION = '4.4.18'; public const VERSION_ID = 40418; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 18; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From f953fa44b0a08d0597ad0c115efc523630d029f7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 18 Dec 2020 14:39:05 +0100 Subject: [PATCH 119/266] Bump Symfony version to 4.4.19 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d0ea1ff626..22c3751b43 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.18'; - public const VERSION_ID = 40418; + public const VERSION = '4.4.19-DEV'; + public const VERSION_ID = 40419; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 18; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 19; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 2455a111174c991e6145beec6eeed1d366a742b7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 27 Dec 2020 00:49:32 +0100 Subject: [PATCH 120/266] CS: Apply ternary_to_null_coalescing fixer --- DataCollector/ConfigDataCollector.php | 2 +- DataCollector/LoggerDataCollector.php | 12 ++++++------ DataCollector/RequestDataCollector.php | 6 +++--- EventListener/RouterListener.php | 2 +- Fragment/AbstractSurrogateFragmentRenderer.php | 4 ++-- Fragment/HIncludeFragmentRenderer.php | 2 +- HttpCache/Esi.php | 2 +- HttpCache/Store.php | 4 ++-- Log/Logger.php | 2 +- UriSigner.php | 6 +++--- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index f005f1d970..179c7515c7 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -219,7 +219,7 @@ public function getPhpVersion() */ public function getPhpVersionExtra() { - return isset($this->data['php_version_extra']) ? $this->data['php_version_extra'] : null; + return $this->data['php_version_extra'] ?? null; } /** diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 07dd254d33..2797a347c8 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -81,32 +81,32 @@ public function lateCollect() public function getLogs() { - return isset($this->data['logs']) ? $this->data['logs'] : []; + return $this->data['logs'] ?? []; } public function getPriorities() { - return isset($this->data['priorities']) ? $this->data['priorities'] : []; + return $this->data['priorities'] ?? []; } public function countErrors() { - return isset($this->data['error_count']) ? $this->data['error_count'] : 0; + return $this->data['error_count'] ?? 0; } public function countDeprecations() { - return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0; + return $this->data['deprecation_count'] ?? 0; } public function countWarnings() { - return isset($this->data['warning_count']) ? $this->data['warning_count'] : 0; + return $this->data['warning_count'] ?? 0; } public function countScreams() { - return isset($this->data['scream_count']) ? $this->data['scream_count'] : 0; + return $this->data['scream_count'] ?? 0; } public function getCompilerLogs() diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 56bc6ec194..0e3c13ba06 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -88,7 +88,7 @@ public function collect(Request $request, Response $response/*, \Throwable $exce 'format' => $request->getRequestFormat(), 'content' => $content, 'content_type' => $response->headers->get('Content-Type', 'text/html'), - 'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '', + 'status_text' => Response::$statusTexts[$statusCode] ?? '', 'status_code' => $statusCode, 'request_query' => $request->query->all(), 'request_request' => $request->request->all(), @@ -339,12 +339,12 @@ public function getController() */ public function getRedirect() { - return isset($this->data['redirect']) ? $this->data['redirect'] : false; + return $this->data['redirect'] ?? false; } public function getForwardToken() { - return isset($this->data['forward_token']) ? $this->data['forward_token'] : null; + return $this->data['forward_token'] ?? null; } /** diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index ee88debae4..0071979688 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -116,7 +116,7 @@ public function onKernelRequest(GetResponseEvent $event) if (null !== $this->logger) { $this->logger->info('Matched route "{route}".', [ - 'route' => isset($parameters['_route']) ? $parameters['_route'] : 'n/a', + 'route' => $parameters['_route'] ?? 'n/a', 'route_parameters' => $parameters, 'request_uri' => $request->getUri(), 'method' => $request->getMethod(), diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index f81199d883..06d8c380bd 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -71,12 +71,12 @@ public function render($uri, Request $request, array $options = []) $uri = $this->generateSignedFragmentUri($uri, $request); } - $alt = isset($options['alt']) ? $options['alt'] : null; + $alt = $options['alt'] ?? null; if ($alt instanceof ControllerReference) { $alt = $this->generateSignedFragmentUri($alt, $request); } - $tag = $this->surrogate->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : ''); + $tag = $this->surrogate->renderIncludeTag($uri, $alt, $options['ignore_errors'] ?? false, $options['comment'] ?? ''); return new Response($tag); } diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index cca653342c..9004102f7e 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -100,7 +100,7 @@ public function render($uri, Request $request, array $options = []) // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content. $uri = str_replace('&', '&', $uri); - $template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate; + $template = $options['default'] ?? $this->globalDefaultTemplate; if (null !== $this->templating && $template && $this->templateExists($template)) { $content = $this->templating->render($template); } else { diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 3d461a7fe3..0bad63e748 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -97,7 +97,7 @@ public function process(Request $request, Response $response) $chunks[$i] = sprintf('surrogate->handle($this, %s, %s, %s) ?>'."\n", var_export($options['src'], true), - var_export(isset($options['alt']) ? $options['alt'] : '', true), + var_export($options['alt'] ?? '', true), isset($options['onerror']) && 'continue' === $options['onerror'] ? 'true' : 'false' ); ++$i; diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 9536d78879..bfaaebe944 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -277,8 +277,8 @@ private function requestsMatch(?string $vary, array $env1, array $env2): bool foreach (preg_split('/[\s,]+/', $vary) as $header) { $key = str_replace('_', '-', strtolower($header)); - $v1 = isset($env1[$key]) ? $env1[$key] : null; - $v2 = isset($env2[$key]) ? $env2[$key] : null; + $v1 = $env1[$key] ?? null; + $v2 = $env2[$key] ?? null; if ($v1 !== $v2) { return false; } diff --git a/Log/Logger.php b/Log/Logger.php index c97673dd89..0181817bdf 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -43,7 +43,7 @@ public function __construct(string $minLevel = null, $output = null, callable $f $minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING; if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { - switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { + switch ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) { case -1: $minLevel = LogLevel::ERROR; break; case 1: $minLevel = LogLevel::NOTICE; break; case 2: $minLevel = LogLevel::INFO; break; diff --git a/UriSigner.php b/UriSigner.php index a11a05f848..e4f988b265 100644 --- a/UriSigner.php +++ b/UriSigner.php @@ -93,12 +93,12 @@ private function buildUrl(array $url, array $params = []): string $url['query'] = http_build_query($params, '', '&'); $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; - $host = isset($url['host']) ? $url['host'] : ''; + $host = $url['host'] ?? ''; $port = isset($url['port']) ? ':'.$url['port'] : ''; - $user = isset($url['user']) ? $url['user'] : ''; + $user = $url['user'] ?? ''; $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($url['path']) ? $url['path'] : ''; + $path = $url['path'] ?? ''; $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : ''; From aca93aee3b5c9bd9f13d0e60b179bb40dd814413 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Jan 2021 10:24:35 +0100 Subject: [PATCH 121/266] Bump license year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9e936ec044..9ff2d0d630 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2020 Fabien Potencier +Copyright (c) 2004-2021 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 62b9794344217e2ba9c61aebb1f26237d778cce7 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 4 Jan 2021 12:47:14 +0100 Subject: [PATCH 122/266] harden test to not depend on the actual time --- Tests/Profiler/FileProfilerStorageTest.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index e0480cc1e8..d2daa67bce 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -190,26 +190,25 @@ public function testRetrieveByUrl() public function testStoreTime() { - $dt = new \DateTime('now'); - $start = $dt->getTimestamp(); + $start = $now = time(); for ($i = 0; $i < 3; ++$i) { - $dt->modify('+1 minute'); + $now += 60; $profile = new Profile('time_'.$i); $profile->setIp('127.0.0.1'); $profile->setUrl('http://foo.bar'); - $profile->setTime($dt->getTimestamp()); + $profile->setTime($now); $profile->setMethod('GET'); $this->storage->write($profile); } - $records = $this->storage->find('', '', 3, 'GET', $start, time() + 3 * 60); + $records = $this->storage->find('', '', 3, 'GET', $start, $start + 3 * 60); $this->assertCount(3, $records, '->find() returns all previously added records'); $this->assertEquals('time_2', $records[0]['token'], '->find() returns records ordered by time in descendant order'); $this->assertEquals('time_1', $records[1]['token'], '->find() returns records ordered by time in descendant order'); $this->assertEquals('time_0', $records[2]['token'], '->find() returns records ordered by time in descendant order'); - $records = $this->storage->find('', '', 3, 'GET', $start, time() + 2 * 60); + $records = $this->storage->find('', '', 3, 'GET', $start, $start + 2 * 60); $this->assertCount(2, $records, '->find() should return only first two of the previously added records'); } From 91b3efe1aed585971d8063d0ecf2833bdc47fd5f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 10 Jan 2021 09:16:05 +0100 Subject: [PATCH 123/266] Improve composer.json descriptions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 59dd77b637..459e5f4682 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "symfony/http-kernel", "type": "library", - "description": "Symfony HttpKernel Component", + "description": "Provides a structured process for converting a Request into a Response", "keywords": [], "homepage": "https://symfony.com", "license": "MIT", From c9a14960a283d8d5c8ea9fb3ba0a61794481fa3b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 10 Jan 2021 13:29:43 +0100 Subject: [PATCH 124/266] Use ::class keyword when possible --- Tests/Controller/ArgumentResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index f2a726de39..c0ed800bb4 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -132,7 +132,7 @@ public function testGetArgumentsFailsOnUnresolvedValue() self::$resolver->getArguments($request, $controller); $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); + $this->assertInstanceOf(\RuntimeException::class, $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); } } From 41a1b8c907bcfcd583817f7f404b7e864c51e64d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 11 Jan 2021 09:47:58 +0100 Subject: [PATCH 125/266] Use ::class keyword when possible --- DataCollector/ConfigDataCollector.php | 2 +- Kernel.php | 4 +-- Tests/Bundle/BundleTest.php | 2 +- Tests/CacheClearer/ChainCacheClearerTest.php | 2 +- Tests/CacheClearer/Psr6CacheClearerTest.php | 2 +- .../CacheWarmer/CacheWarmerAggregateTest.php | 2 +- Tests/CacheWarmer/CacheWarmerTest.php | 2 +- Tests/Config/FileLocatorTest.php | 6 ++--- .../NotTaggedControllerValueResolverTest.php | 8 +++--- .../ServiceValueResolverTest.php | 2 +- Tests/Controller/ArgumentResolverTest.php | 12 ++++----- .../ContainerControllerResolverTest.php | 4 +-- Tests/Controller/ControllerResolverTest.php | 4 +-- .../ArgumentMetadataTest.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 2 +- .../DataCollector/LoggerDataCollectorTest.php | 6 ++--- .../RequestDataCollectorTest.php | 16 ++++++------ Tests/DataCollector/TimeDataCollectorTest.php | 2 +- Tests/Debug/TraceableEventDispatcherTest.php | 8 +++--- .../FragmentRendererPassTest.php | 2 +- .../LazyLoadingFragmentHandlerTest.php | 6 ++--- ...sterControllerArgumentLocatorsPassTest.php | 16 ++++++------ .../ResettableServicePassTest.php | 2 +- .../AddRequestFormatsListenerTest.php | 4 +-- .../DebugHandlersListenerTest.php | 8 +++--- Tests/EventListener/ErrorListenerTest.php | 10 +++---- Tests/EventListener/ExceptionListenerTest.php | 10 +++---- Tests/EventListener/FragmentListenerTest.php | 4 +-- .../EventListener/LocaleAwareListenerTest.php | 2 +- Tests/EventListener/LocaleListenerTest.php | 12 ++++----- Tests/EventListener/ProfilerListenerTest.php | 10 +++---- Tests/EventListener/ResponseListenerTest.php | 2 +- Tests/EventListener/RouterListenerTest.php | 26 +++++++++---------- Tests/EventListener/SurrogateListenerTest.php | 6 ++--- .../EventListener/TestSessionListenerTest.php | 4 +-- .../EventListener/TranslatorListenerTest.php | 4 +-- .../ValidateRequestListenerTest.php | 4 +-- Tests/Fragment/EsiFragmentRendererTest.php | 6 ++--- Tests/Fragment/FragmentHandlerTest.php | 10 +++---- .../Fragment/HIncludeFragmentRendererTest.php | 4 +-- Tests/Fragment/InlineFragmentRendererTest.php | 10 +++---- .../Fragment/RoutableFragmentRendererTest.php | 4 +-- Tests/Fragment/SsiFragmentRendererTest.php | 6 ++--- Tests/HttpCache/EsiTest.php | 6 ++--- Tests/HttpCache/HttpCacheTest.php | 8 +++--- Tests/HttpCache/SsiTest.php | 6 ++--- Tests/HttpCache/StoreTest.php | 4 +-- Tests/HttpKernelBrowserTest.php | 10 +++---- Tests/HttpKernelTest.php | 10 +++---- Tests/KernelTest.php | 26 +++++++++---------- Tests/Log/LoggerTest.php | 6 ++--- 51 files changed, 168 insertions(+), 168 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 179c7515c7..d4b298c594 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -69,7 +69,7 @@ public function collect(Request $request, Response $response/*, \Throwable $exce 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => \PHP_VERSION, 'php_architecture' => \PHP_INT_SIZE * 8, - 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', + 'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), 'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), diff --git a/Kernel.php b/Kernel.php index 22c3751b43..b91fc66a9f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -748,7 +748,7 @@ protected function getContainerBuilder() if ($this instanceof CompilerPassInterface) { $container->addCompilerPass($this, PassConfig::TYPE_BEFORE_OPTIMIZATION, -10000); } - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) { + if (class_exists(\ProxyManager\Configuration::class) && class_exists(RuntimeInstantiator::class)) { $container->setProxyInstantiator(new RuntimeInstantiator()); } @@ -766,7 +766,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container // cache the container $dumper = new PhpDumper($container); - if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) { + if (class_exists(\ProxyManager\Configuration::class) && class_exists(ProxyDumper::class)) { $dumper->setProxyDumper(new ProxyDumper()); } diff --git a/Tests/Bundle/BundleTest.php b/Tests/Bundle/BundleTest.php index be03734dc4..0937eebcc4 100644 --- a/Tests/Bundle/BundleTest.php +++ b/Tests/Bundle/BundleTest.php @@ -30,7 +30,7 @@ public function testGetContainerExtension() public function testGetContainerExtensionWithInvalidClass() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface'); $bundle = new ExtensionNotValidBundle(); $bundle->getContainerExtension(); diff --git a/Tests/CacheClearer/ChainCacheClearerTest.php b/Tests/CacheClearer/ChainCacheClearerTest.php index b97559e321..a0b4bd8c41 100644 --- a/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/Tests/CacheClearer/ChainCacheClearerTest.php @@ -41,6 +41,6 @@ public function testInjectClearersInConstructor() protected function getMockClearer() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock(); + return $this->getMockBuilder(\Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface::class)->getMock(); } } diff --git a/Tests/CacheClearer/Psr6CacheClearerTest.php b/Tests/CacheClearer/Psr6CacheClearerTest.php index 6e0a47e930..c7c683428e 100644 --- a/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -39,7 +39,7 @@ public function testClearPool() public function testClearPoolThrowsExceptionOnUnreferencedPool() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Cache pool not found: "unknown"'); (new Psr6CacheClearer())->clearPool('unknown'); } diff --git a/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/Tests/CacheWarmer/CacheWarmerAggregateTest.php index 4266c0a182..cf9493a295 100644 --- a/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ b/Tests/CacheWarmer/CacheWarmerAggregateTest.php @@ -70,7 +70,7 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa protected function getCacheWarmerMock() { - $warmer = $this->getMockBuilder('Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface') + $warmer = $this->getMockBuilder(\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/CacheWarmer/CacheWarmerTest.php b/Tests/CacheWarmer/CacheWarmerTest.php index 8359d99f5f..c3286d0020 100644 --- a/Tests/CacheWarmer/CacheWarmerTest.php +++ b/Tests/CacheWarmer/CacheWarmerTest.php @@ -38,7 +38,7 @@ public function testWriteCacheFileCreatesTheFile() public function testWriteNonWritableCacheFileThrowsARuntimeException() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $nonWritableFile = '/this/file/is/very/probably/not/writable'; $warmer = new TestCacheWarmer($nonWritableFile); $warmer->warmUp(\dirname($nonWritableFile)); diff --git a/Tests/Config/FileLocatorTest.php b/Tests/Config/FileLocatorTest.php index 6bfaeca2f5..d992286752 100644 --- a/Tests/Config/FileLocatorTest.php +++ b/Tests/Config/FileLocatorTest.php @@ -18,7 +18,7 @@ class FileLocatorTest extends TestCase { public function testLocate() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') @@ -30,7 +30,7 @@ public function testLocate() $kernel ->expects($this->never()) ->method('locateResource'); - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $locator->locate('/some/path'); } @@ -39,7 +39,7 @@ public function testLocate() */ public function testLocateWithGlobalResourcePath() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') diff --git a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php index 4f85b0f351..efb7322efa 100644 --- a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php @@ -55,7 +55,7 @@ public function testDoNotSupportEmptyController() public function testController() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -66,7 +66,7 @@ public function testController() public function testControllerWithATrailingBackSlash() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -77,7 +77,7 @@ public function testControllerWithATrailingBackSlash() public function testControllerWithMethodNameStartUppercase() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -88,7 +88,7 @@ public function testControllerWithMethodNameStartUppercase() public function testControllerNameIsAnArray() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); diff --git a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index 4036727bce..743eefa3e5 100644 --- a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -107,7 +107,7 @@ public function testControllerNameIsAnArray() public function testErrorIsTruncated() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Cannot autowire argument $dummy of "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyController::index()": it references class "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyService" but no such service exists.'); $container = new ContainerBuilder(); $container->addCompilerPass(new RegisterControllerArgumentLocatorsPass()); diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index c0ed800bb4..da521ff204 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -164,7 +164,7 @@ public function testGetVariadicArguments() public function testGetVariadicArgumentsWithoutArrayInRequest() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', 'foo'); @@ -175,7 +175,7 @@ public function testGetVariadicArgumentsWithoutArrayInRequest() public function testGetArgumentWithoutArray() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $factory = new ArgumentMetadataFactory(); $valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock(); $resolver = new ArgumentResolver($factory, [$valueResolver]); @@ -192,7 +192,7 @@ public function testGetArgumentWithoutArray() public function testIfExceptionIsThrownWhenMissingAnArgument() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $request = Request::create('/'); $controller = [$this, 'controllerWithFoo']; @@ -251,7 +251,7 @@ public function testGetSessionArgumentsWithInterface() public function testGetSessionMissMatchWithInterface() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $session = $this->getMockBuilder(SessionInterface::class)->getMock(); $request = Request::create('/'); $request->setSession($session); @@ -262,7 +262,7 @@ public function testGetSessionMissMatchWithInterface() public function testGetSessionMissMatchWithImplementation() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $session = new Session(new MockArraySessionStorage()); $request = Request::create('/'); $request->setSession($session); @@ -273,7 +273,7 @@ public function testGetSessionMissMatchWithImplementation() public function testGetSessionMissMatchOnNull() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $request = Request::create('/'); $controller = [$this, 'controllerWithExtendingSession']; diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index c39dac3ca5..7f4564688c 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -151,7 +151,7 @@ public function getControllers() public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsName() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->once()) @@ -175,7 +175,7 @@ public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsNam public function testExceptionWhenUsingRemovedControllerService() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); $container = $this->getMockBuilder(Container::class)->getMock(); $container->expects($this->once()) diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index de6dfc2546..834f925c43 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -20,7 +20,7 @@ class ControllerResolverTest extends TestCase { public function testGetControllerWithoutControllerParameter() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.'); $resolver = $this->createControllerResolver($logger); @@ -94,7 +94,7 @@ public function testGetControllerWithInvokableClass() public function testGetControllerOnObjectWithoutInvokeMethod() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $resolver = $this->createControllerResolver(); $request = Request::create('/'); diff --git a/Tests/ControllerMetadata/ArgumentMetadataTest.php b/Tests/ControllerMetadata/ArgumentMetadataTest.php index 5ce4b1f76b..fef6cd0002 100644 --- a/Tests/ControllerMetadata/ArgumentMetadataTest.php +++ b/Tests/ControllerMetadata/ArgumentMetadataTest.php @@ -34,7 +34,7 @@ public function testDefaultValueAvailable() public function testDefaultValueUnavailable() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $argument = new ArgumentMetadata('foo', 'string', false, false, null, false); $this->assertFalse($argument->isNullable()); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index b7f2cd90f3..df6af954f3 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -33,7 +33,7 @@ public function testCollect() $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION); $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', \PHP_VERSION); $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); - $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); + $this->assertSame(class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); $this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts()); diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index de9364bb47..4204b8ef03 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -24,7 +24,7 @@ class LoggerDataCollectorTest extends TestCase public function testCollectWithUnexpectedFormat() { $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') + ->getMockBuilder(DebugLoggerInterface::class) ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('countErrors')->willReturn(123); @@ -91,7 +91,7 @@ public function testWithSubRequest() public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null) { $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') + ->getMockBuilder(DebugLoggerInterface::class) ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('countErrors')->willReturn($nb); @@ -123,7 +123,7 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount public function testReset() { $logger = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') + ->getMockBuilder(DebugLoggerInterface::class) ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('clear'); diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 852839c9b1..bb29b4ba52 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -39,12 +39,12 @@ public function testCollect() $attributes = $c->getRequestAttributes(); $this->assertSame('request', $c->getName()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestHeaders()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestServer()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestCookies()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestHeaders()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestServer()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestCookies()); + $this->assertInstanceOf(ParameterBag::class, $attributes); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestRequest()); + $this->assertInstanceOf(ParameterBag::class, $c->getRequestQuery()); $this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies()); $this->assertSame('html', $c->getFormat()); $this->assertEquals('foobar', $c->getRoute()); @@ -54,7 +54,7 @@ public function testCollect() $this->assertContainsEquals(__FILE__, $attributes->get('resource')); $this->assertSame('stdClass', $attributes->get('object')->getType()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders()); + $this->assertInstanceOf(ParameterBag::class, $c->getResponseHeaders()); $this->assertSame('OK', $c->getStatusText()); $this->assertSame(200, $c->getStatusCode()); $this->assertSame('application/json', $c->getContentType()); @@ -288,7 +288,7 @@ protected function createResponse() */ protected function injectController($collector, $controller, $request) { - $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); + $resolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock()); $event = new ControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST); $collector->onKernelController($event); diff --git a/Tests/DataCollector/TimeDataCollectorTest.php b/Tests/DataCollector/TimeDataCollectorTest.php index 9de9eb599a..ab231ac4c5 100644 --- a/Tests/DataCollector/TimeDataCollectorTest.php +++ b/Tests/DataCollector/TimeDataCollectorTest.php @@ -43,7 +43,7 @@ public function testCollect() $c->collect($request, new Response()); $this->assertEquals(0, $c->getStartTime()); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); $kernel->expects($this->once())->method('getStartTime')->willReturn(123456.0); $c = new TimeDataCollector($kernel); diff --git a/Tests/Debug/TraceableEventDispatcherTest.php b/Tests/Debug/TraceableEventDispatcherTest.php index cf8a3b8a1e..c4d42ec648 100644 --- a/Tests/Debug/TraceableEventDispatcherTest.php +++ b/Tests/Debug/TraceableEventDispatcherTest.php @@ -45,7 +45,7 @@ public function testStopwatchSections() public function testStopwatchCheckControllerOnRequestEvent() { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') + $stopwatch = $this->getMockBuilder(Stopwatch::class) ->setMethods(['isStarted']) ->getMock(); $stopwatch->expects($this->once()) @@ -61,7 +61,7 @@ public function testStopwatchCheckControllerOnRequestEvent() public function testStopwatchStopControllerOnRequestEvent() { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') + $stopwatch = $this->getMockBuilder(Stopwatch::class) ->setMethods(['isStarted', 'stop']) ->getMock(); $stopwatch->expects($this->once()) @@ -110,9 +110,9 @@ public function testListenerCanRemoveItselfWhenExecuted() protected function getHttpKernel($dispatcher, $controller) { - $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); + $controllerResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); $controllerResolver->expects($this->once())->method('getController')->willReturn($controller); - $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); + $argumentResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface::class)->getMock(); $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); diff --git a/Tests/DependencyInjection/FragmentRendererPassTest.php b/Tests/DependencyInjection/FragmentRendererPassTest.php index 49567d40be..ab0efe32f5 100644 --- a/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -29,7 +29,7 @@ class FragmentRendererPassTest extends TestCase */ public function testContentRendererWithoutInterface() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $builder = new ContainerBuilder(); $fragmentHandlerDefinition = $builder->register('fragment.handler'); $builder->register('my_content_renderer', 'Symfony\Component\DependencyInjection\Definition') diff --git a/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 39a1cb73b1..493178d470 100644 --- a/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -20,14 +20,14 @@ class LazyLoadingFragmentHandlerTest extends TestCase { public function testRender() { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); + $renderer = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); $renderer->expects($this->once())->method('getName')->willReturn('foo'); $renderer->expects($this->any())->method('render')->willReturn(new Response()); - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); - $container = $this->getMockBuilder('Psr\Container\ContainerInterface')->getMock(); + $container = $this->getMockBuilder(\Psr\Container\ContainerInterface::class)->getMock(); $container->expects($this->once())->method('has')->with('foo')->willReturn(true); $container->expects($this->once())->method('get')->willReturn($renderer); diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index a3b7969be1..8a65b4ff38 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -27,7 +27,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase { public function testInvalidClass() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -42,7 +42,7 @@ public function testInvalidClass() public function testNoAction() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -57,7 +57,7 @@ public function testNoAction() public function testNoArgument() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -72,7 +72,7 @@ public function testNoArgument() public function testNoService() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -87,7 +87,7 @@ public function testNoService() public function testInvalidMethod() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -102,7 +102,7 @@ public function testInvalidMethod() public function testInvalidArgument() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -197,7 +197,7 @@ public function testSkipSetContainer() public function testExceptionOnNonExistentTypeHint() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -211,7 +211,7 @@ public function testExceptionOnNonExistentTypeHint() public function testExceptionOnNonExistentTypeHintDifferentNamespace() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); diff --git a/Tests/DependencyInjection/ResettableServicePassTest.php b/Tests/DependencyInjection/ResettableServicePassTest.php index 9dbc2b08a4..b28f90d362 100644 --- a/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/Tests/DependencyInjection/ResettableServicePassTest.php @@ -57,7 +57,7 @@ public function testCompilerPass() public function testMissingMethod() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); + $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectExceptionMessage('Tag "kernel.reset" requires the "method" attribute to be set.'); $container = new ContainerBuilder(); $container->register(ResettableService::class) diff --git a/Tests/EventListener/AddRequestFormatsListenerTest.php b/Tests/EventListener/AddRequestFormatsListenerTest.php index da8dc6fb0b..6c4459fc2a 100644 --- a/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -41,7 +41,7 @@ protected function tearDown(): void public function testIsAnEventSubscriber() { - $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); + $this->assertInstanceOf(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class, $this->listener); } public function testRegisteredEvent() @@ -66,7 +66,7 @@ public function testSetAdditionalFormats() protected function getRequestMock() { - return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + return $this->getMockBuilder(Request::class)->getMock(); } protected function getRequestEventMock(Request $request) diff --git a/Tests/EventListener/DebugHandlersListenerTest.php b/Tests/EventListener/DebugHandlersListenerTest.php index 7e336a1d6c..fb18d63fbe 100644 --- a/Tests/EventListener/DebugHandlersListenerTest.php +++ b/Tests/EventListener/DebugHandlersListenerTest.php @@ -35,7 +35,7 @@ class DebugHandlersListenerTest extends TestCase { public function testConfigure() { - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $userHandler = function () {}; $listener = new DebugHandlersListener($userHandler, $logger); $eHandler = new ErrorHandler(); @@ -67,7 +67,7 @@ public function testConfigureForHttpKernelWithNoTerminateWithException() $listener = new DebugHandlersListener(null); $eHandler = new ErrorHandler(); $event = new KernelEvent( - $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), + $this->getMockBuilder(HttpKernelInterface::class)->getMock(), Request::create('/'), HttpKernelInterface::MASTER_REQUEST ); @@ -91,7 +91,7 @@ public function testConsoleEvent() { $dispatcher = new EventDispatcher(); $listener = new DebugHandlersListener(null); - $app = $this->getMockBuilder('Symfony\Component\Console\Application')->getMock(); + $app = $this->getMockBuilder(Application::class)->getMock(); $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet()); $command = new Command(__FUNCTION__); $command->setApplication($app); @@ -121,7 +121,7 @@ public function testConsoleEvent() } $xHandler = $eHandler->setExceptionHandler('var_dump'); - $this->assertInstanceOf('Closure', $xHandler); + $this->assertInstanceOf(\Closure::class, $xHandler); $app->expects($this->once()) ->method(method_exists(Application::class, 'renderThrowable') ? 'renderThrowable' : 'renderException'); diff --git a/Tests/EventListener/ErrorListenerTest.php b/Tests/EventListener/ErrorListenerTest.php index cdf6874f35..4428e3d1a6 100644 --- a/Tests/EventListener/ErrorListenerTest.php +++ b/Tests/EventListener/ErrorListenerTest.php @@ -99,7 +99,7 @@ public function testHandleWithLogger($event, $event2) public function provider() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + if (!class_exists(Request::class)) { return [[null, null]]; } @@ -115,9 +115,9 @@ public function provider() public function testSubRequestFormat() { - $listener = new ErrorListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); + $listener = new ErrorListener('foo', $this->getMockBuilder(LoggerInterface::class)->getMock()); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); @@ -135,12 +135,12 @@ public function testSubRequestFormat() public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); - $listener = new ErrorListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); + $listener = new ErrorListener('foo', $this->getMockBuilder(LoggerInterface::class)->getMock(), true); $dispatcher->addSubscriber($listener); diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index 28113c14af..91ff62d906 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -96,7 +96,7 @@ public function testHandleWithLogger($event, $event2) public function provider() { - if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + if (!class_exists(Request::class)) { return [[null, null]]; } @@ -112,9 +112,9 @@ public function provider() public function testSubRequestFormat() { - $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock()); + $listener = new ExceptionListener('foo', $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock()); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); @@ -132,12 +132,12 @@ public function testSubRequestFormat() public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); - $listener = new ExceptionListener('foo', $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(), true); + $listener = new ExceptionListener('foo', $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(), true); $dispatcher->addSubscriber($listener); diff --git a/Tests/EventListener/FragmentListenerTest.php b/Tests/EventListener/FragmentListenerTest.php index 5b045a8fc4..e0b857debd 100644 --- a/Tests/EventListener/FragmentListenerTest.php +++ b/Tests/EventListener/FragmentListenerTest.php @@ -52,7 +52,7 @@ public function testOnlyTriggeredIfControllerWasNotDefinedYet() public function testAccessDeniedWithNonSafeMethods() { - $this->expectException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); $request = Request::create('http://example.com/_fragment', 'POST'); $listener = new FragmentListener(new UriSigner('foo')); @@ -63,7 +63,7 @@ public function testAccessDeniedWithNonSafeMethods() public function testAccessDeniedWithWrongSignature() { - $this->expectException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); $request = Request::create('http://example.com/_fragment', 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']); $listener = new FragmentListener(new UriSigner('foo')); diff --git a/Tests/EventListener/LocaleAwareListenerTest.php b/Tests/EventListener/LocaleAwareListenerTest.php index 0064429048..0d14e5a987 100644 --- a/Tests/EventListener/LocaleAwareListenerTest.php +++ b/Tests/EventListener/LocaleAwareListenerTest.php @@ -110,7 +110,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() private function createHttpKernel() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } private function createRequest($locale) diff --git a/Tests/EventListener/LocaleListenerTest.php b/Tests/EventListener/LocaleListenerTest.php index cb502a89ee..705600d70e 100644 --- a/Tests/EventListener/LocaleListenerTest.php +++ b/Tests/EventListener/LocaleListenerTest.php @@ -26,7 +26,7 @@ class LocaleListenerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); + $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->disableOriginalConstructor()->getMock(); } public function testIsAnEventSubscriber() @@ -70,10 +70,10 @@ public function testLocaleFromRequestAttribute() public function testLocaleSetForRoutingContext() { // the request context is updated - $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); + $context = $this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->willReturn($context); $request = Request::create('/'); @@ -86,10 +86,10 @@ public function testLocaleSetForRoutingContext() public function testRouterResetWithParentRequestOnKernelFinishRequest() { // the request context is updated - $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); + $context = $this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder(\Symfony\Component\Routing\Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->willReturn($context); $parentRequest = Request::create('/'); @@ -116,6 +116,6 @@ public function testRequestLocaleIsNotOverridden() private function getEvent(Request $request): RequestEvent { - return new RequestEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); + return new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); } } diff --git a/Tests/EventListener/ProfilerListenerTest.php b/Tests/EventListener/ProfilerListenerTest.php index 3aaff12316..4b076ef17d 100644 --- a/Tests/EventListener/ProfilerListenerTest.php +++ b/Tests/EventListener/ProfilerListenerTest.php @@ -30,7 +30,7 @@ public function testKernelTerminate() { $profile = new Profile('token'); - $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + $profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class) ->disableOriginalConstructor() ->getMock(); @@ -38,17 +38,17 @@ public function testKernelTerminate() ->method('collect') ->willReturn($profile); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); - $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + $masterRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class) ->disableOriginalConstructor() ->getMock(); - $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + $subRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') + $response = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Response::class) ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/EventListener/ResponseListenerTest.php b/Tests/EventListener/ResponseListenerTest.php index 1aaa64bc89..31cfa38477 100644 --- a/Tests/EventListener/ResponseListenerTest.php +++ b/Tests/EventListener/ResponseListenerTest.php @@ -32,7 +32,7 @@ protected function setUp(): void $listener = new ResponseListener('UTF-8'); $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); - $this->kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $this->kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } protected function tearDown(): void diff --git a/Tests/EventListener/RouterListenerTest.php b/Tests/EventListener/RouterListenerTest.php index 2c1e7721b4..59e63deea8 100644 --- a/Tests/EventListener/RouterListenerTest.php +++ b/Tests/EventListener/RouterListenerTest.php @@ -33,7 +33,7 @@ class RouterListenerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock(); + $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->getMock(); } /** @@ -41,7 +41,7 @@ protected function setUp(): void */ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort) { - $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface') + $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class) ->disableOriginalConstructor() ->getMock(); $context = new RequestContext(); @@ -81,7 +81,7 @@ private function createRequestEventForUri(string $uri): RequestEvent public function testInvalidMatcher() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); new RouterListener(new \stdClass(), $this->requestStack); } @@ -91,10 +91,10 @@ public function testRequestMatcher() $request = Request::create('http://localhost/'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->with($this->isInstanceOf(Request::class)) ->willReturn([]); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); @@ -107,10 +107,10 @@ public function testSubRequestWithDifferentMethod() $request = Request::create('http://localhost/', 'post'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->any()) ->method('matchRequest') - ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->with($this->isInstanceOf(Request::class)) ->willReturn([]); $context = new RequestContext(); @@ -133,12 +133,12 @@ public function testSubRequestWithDifferentMethod() */ public function testLoggingParameter($parameter, $log, $parameters) { - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->once()) ->method('matchRequest') ->willReturn($parameter); - $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); $logger->expects($this->once()) ->method('info') ->with($this->equalTo($log), $this->equalTo($parameters)); @@ -162,7 +162,7 @@ public function testWithBadRequest() { $requestStack = new RequestStack(); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher->expects($this->never())->method('matchRequest'); $dispatcher = new EventDispatcher(); @@ -184,7 +184,7 @@ public function testNoRoutingConfigurationResponse() { $requestStack = new RequestStack(); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $requestMatcher ->expects($this->once()) ->method('matchRequest') @@ -204,12 +204,12 @@ public function testNoRoutingConfigurationResponse() public function testRequestWithBadHost() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = Request::create('http://bad host %22/'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); + $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener->onKernelRequest($event); diff --git a/Tests/EventListener/SurrogateListenerTest.php b/Tests/EventListener/SurrogateListenerTest.php index fc51de252e..e4b8b2d558 100644 --- a/Tests/EventListener/SurrogateListenerTest.php +++ b/Tests/EventListener/SurrogateListenerTest.php @@ -26,7 +26,7 @@ class SurrogateListenerTest extends TestCase public function testFilterDoesNothingForSubRequests() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -40,7 +40,7 @@ public function testFilterDoesNothingForSubRequests() public function testFilterWhenThereIsSomeEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -54,7 +54,7 @@ public function testFilterWhenThereIsSomeEsiIncludes() public function testFilterWhenThereIsNoEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $response = new Response('foo'); $listener = new SurrogateListener(new Esi()); diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index 1d9ea37977..e0a5cc69da 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -42,7 +42,7 @@ class TestSessionListenerTest extends TestCase protected function setUp(): void { - $this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener'); + $this->listener = $this->getMockForAbstractClass(\Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener::class); $this->session = $this->getSession(); $this->listener->expects($this->any()) ->method('getSession') @@ -209,7 +209,7 @@ private function fixSessionId($sessionId) private function getSession() { - $mock = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session') + $mock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class) ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/EventListener/TranslatorListenerTest.php b/Tests/EventListener/TranslatorListenerTest.php index e5447079dc..1fe4d1f2fa 100644 --- a/Tests/EventListener/TranslatorListenerTest.php +++ b/Tests/EventListener/TranslatorListenerTest.php @@ -31,7 +31,7 @@ class TranslatorListenerTest extends TestCase protected function setUp(): void { $this->translator = $this->getMockBuilder(LocaleAwareInterface::class)->getMock(); - $this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); + $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); $this->listener = new TranslatorListener($this->translator, $this->requestStack); } @@ -105,7 +105,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() private function createHttpKernel() { - return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); } private function createRequest($locale) diff --git a/Tests/EventListener/ValidateRequestListenerTest.php b/Tests/EventListener/ValidateRequestListenerTest.php index 7cec68143b..96b686d91b 100644 --- a/Tests/EventListener/ValidateRequestListenerTest.php +++ b/Tests/EventListener/ValidateRequestListenerTest.php @@ -28,9 +28,9 @@ protected function tearDown(): void public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() { - $this->expectException('Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException'); + $this->expectException(\Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException::class); $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); $request = new Request(); $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); diff --git a/Tests/Fragment/EsiFragmentRendererTest.php b/Tests/Fragment/EsiFragmentRendererTest.php index df74ade154..c9af77149c 100644 --- a/Tests/Fragment/EsiFragmentRendererTest.php +++ b/Tests/Fragment/EsiFragmentRendererTest.php @@ -67,7 +67,7 @@ public function testRenderControllerReference() public function testRenderControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -79,7 +79,7 @@ public function testRenderControllerReferenceWithoutSignerThrowsException() public function testRenderAltControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -91,7 +91,7 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException() private function getInlineStrategy($called = false) { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); + $inline = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::class)->disableOriginalConstructor()->getMock(); if ($called) { $inline->expects($this->once())->method('render'); diff --git a/Tests/Fragment/FragmentHandlerTest.php b/Tests/Fragment/FragmentHandlerTest.php index 15e543a214..fa011c8f29 100644 --- a/Tests/Fragment/FragmentHandlerTest.php +++ b/Tests/Fragment/FragmentHandlerTest.php @@ -25,7 +25,7 @@ class FragmentHandlerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack') + $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class) ->disableOriginalConstructor() ->getMock() ; @@ -38,14 +38,14 @@ protected function setUp(): void public function testRenderWhenRendererDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $handler = new FragmentHandler($this->requestStack); $handler->render('/', 'foo'); } public function testRenderWithUnknownRenderer() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $handler = $this->getHandler($this->returnValue(new Response('foo'))); $handler->render('/', 'bar'); @@ -53,7 +53,7 @@ public function testRenderWithUnknownRenderer() public function testDeliverWithUnsuccessfulResponse() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Error when rendering "http://localhost/" (Status code is 404).'); $handler = $this->getHandler($this->returnValue(new Response('foo', 404))); @@ -69,7 +69,7 @@ public function testRender() protected function getHandler($returnValue, $arguments = []) { - $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); + $renderer = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); $renderer ->expects($this->any()) ->method('getName') diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index cdef37565b..ae1cb15516 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -23,7 +23,7 @@ class HIncludeFragmentRendererTest extends TestCase { public function testRenderExceptionWhenControllerAndNoSigner() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new HIncludeFragmentRenderer(); $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/')); } @@ -86,7 +86,7 @@ public function testRenderWithTwigAndDefaultText() */ public function testRenderWithDefaultTextLegacy() { - $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); + $engine = $this->getMockBuilder(\Symfony\Component\Templating\EngineInterface::class)->getMock(); $engine->expects($this->once()) ->method('exists') ->with('default') diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index a064a76c7d..c25297dbe4 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -71,7 +71,7 @@ public function testRenderWithTrustedHeaderDisabled() public function testRenderExceptionNoIgnoreErrors() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); $dispatcher->expects($this->never())->method('dispatch'); @@ -106,7 +106,7 @@ public function testRenderExceptionIgnoreErrorsWithAlt() private function getKernel($returnValue) { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); $kernel ->expects($this->any()) ->method('handle') @@ -118,7 +118,7 @@ private function getKernel($returnValue) public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { - $controllerResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock(); + $controllerResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); $controllerResolver ->expects($this->once()) ->method('getController') @@ -129,7 +129,7 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() }) ; - $argumentResolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface')->getMock(); + $argumentResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface::class)->getMock(); $argumentResolver ->expects($this->once()) ->method('getArguments') @@ -258,7 +258,7 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() */ private function getKernelExpectingRequest(Request $request, $strict = false) { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); $kernel ->expects($this->once()) ->method('handle') diff --git a/Tests/Fragment/RoutableFragmentRendererTest.php b/Tests/Fragment/RoutableFragmentRendererTest.php index 151adb0e97..5980284afe 100644 --- a/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/Tests/Fragment/RoutableFragmentRendererTest.php @@ -60,7 +60,7 @@ public function testGenerateFragmentUriWithARequest() */ public function testGenerateFragmentUriWithNonScalar($controller) { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->callGenerateFragmentUriMethod($controller, Request::create('/')); } @@ -74,7 +74,7 @@ public function getGenerateFragmentUriDataWithNonScalar() private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) { - $renderer = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer'); + $renderer = $this->getMockForAbstractClass(\Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer::class); $r = new \ReflectionObject($renderer); $m = $r->getMethod('generateFragmentUri'); $m->setAccessible(true); diff --git a/Tests/Fragment/SsiFragmentRendererTest.php b/Tests/Fragment/SsiFragmentRendererTest.php index df30e67727..db203f91de 100644 --- a/Tests/Fragment/SsiFragmentRendererTest.php +++ b/Tests/Fragment/SsiFragmentRendererTest.php @@ -58,7 +58,7 @@ public function testRenderControllerReference() public function testRenderControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -70,7 +70,7 @@ public function testRenderControllerReferenceWithoutSignerThrowsException() public function testRenderAltControllerReferenceWithoutSignerThrowsException() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $strategy = new SsiFragmentRenderer(new Ssi(), $this->getInlineStrategy()); $request = Request::create('/'); @@ -82,7 +82,7 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException() private function getInlineStrategy($called = false) { - $inline = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer')->disableOriginalConstructor()->getMock(); + $inline = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::class)->disableOriginalConstructor()->getMock(); if ($called) { $inline->expects($this->once())->method('render'); diff --git a/Tests/HttpCache/EsiTest.php b/Tests/HttpCache/EsiTest.php index cdf729e331..5246721a64 100644 --- a/Tests/HttpCache/EsiTest.php +++ b/Tests/HttpCache/EsiTest.php @@ -155,7 +155,7 @@ public function testProcessEscapesPhpTags() public function testProcessWhenNoSrcInAnEsi() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $esi = new Esi(); $request = Request::create('/'); @@ -193,7 +193,7 @@ public function testHandle() public function testHandleWhenResponseIsNot200() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $esi = new Esi(); $response = new Response('foo'); $response->setStatusCode(404); @@ -222,7 +222,7 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() protected function getCache($request, $response) { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->willReturn($request) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 6ad64e4791..932f46c6ef 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -25,7 +25,7 @@ class HttpCacheTest extends HttpCacheTestCase { public function testTerminateDelegatesTerminationOnlyForTerminableInterface() { - $storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface') + $storeMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\StoreInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -37,7 +37,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $this->assertFalse($kernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); // implements TerminableInterface - $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel') + $kernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class) ->disableOriginalConstructor() ->setMethods(['terminate', 'registerBundles', 'registerContainerConfiguration']) ->getMock(); @@ -1488,8 +1488,8 @@ public function testDoesNotCacheOptionsRequest() public function testUsesOriginalRequestForSurrogate() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock(); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $store = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\StoreInterface::class)->getMock(); $kernel ->expects($this->exactly(2)) diff --git a/Tests/HttpCache/SsiTest.php b/Tests/HttpCache/SsiTest.php index 3d68052cdc..23c7410a28 100644 --- a/Tests/HttpCache/SsiTest.php +++ b/Tests/HttpCache/SsiTest.php @@ -122,7 +122,7 @@ public function testProcessEscapesPhpTags() public function testProcessWhenNoSrcInAnSsi() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $ssi = new Ssi(); $request = Request::create('/'); @@ -160,7 +160,7 @@ public function testHandle() public function testHandleWhenResponseIsNot200() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $ssi = new Ssi(); $response = new Response('foo'); $response->setStatusCode(404); @@ -189,7 +189,7 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() protected function getCache($request, $response) { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->willReturn($request) diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index fc1ef64663..da1f649127 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -157,7 +157,7 @@ public function testFindsAStoredEntryWithLookup() $response = $this->store->lookup($this->request); $this->assertNotNull($response); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + $this->assertInstanceOf(Response::class, $response); } public function testDoesNotFindAnEntryWithLookupWhenNoneExists() @@ -206,7 +206,7 @@ public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate() $this->storeSimpleEntry(); $this->store->invalidate($this->request); $response = $this->store->lookup($this->request); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + $this->assertInstanceOf(Response::class, $response); $this->assertFalse($response->isFresh()); } diff --git a/Tests/HttpKernelBrowserTest.php b/Tests/HttpKernelBrowserTest.php index 4d4fe5ae72..eab6c5221c 100644 --- a/Tests/HttpKernelBrowserTest.php +++ b/Tests/HttpKernelBrowserTest.php @@ -30,10 +30,10 @@ public function testDoRequest() $client->request('GET', '/'); $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Request', $client->getRequest()); - $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $client->getResponse()); + $this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest()); + $this->assertInstanceOf(\Symfony\Component\HttpFoundation\Request::class, $client->getRequest()); + $this->assertInstanceOf(\Symfony\Component\BrowserKit\Response::class, $client->getInternalResponse()); + $this->assertInstanceOf(Response::class, $client->getResponse()); $client->request('GET', 'http://www.example.com/'); $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); @@ -148,7 +148,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $client = new HttpKernelBrowser($kernel); $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') + ->getMockBuilder(UploadedFile::class) ->setConstructorArgs([$source, 'original', 'mime/original', \UPLOAD_ERR_OK, true]) ->setMethods(['getSize', 'getClientSize']) ->getMock() diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 7a5b0b8c60..5c954261b6 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -31,7 +31,7 @@ class HttpKernelTest extends TestCase { public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true); @@ -39,7 +39,7 @@ public function testHandleWhenControllerThrowsAnExceptionAndCatchIsTrue() public function testHandleWhenControllerThrowsAnExceptionAndCatchIsFalseAndNoListenerIsRegistered() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $kernel = $this->getHttpKernel(new EventDispatcher(), function () { throw new \RuntimeException(); }); $kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false); @@ -156,7 +156,7 @@ public function testHandleWhenAListenerReturnsAResponse() public function testHandleWhenNoControllerIsFound() { - $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $dispatcher = new EventDispatcher(); $kernel = $this->getHttpKernel($dispatcher, false); @@ -303,7 +303,7 @@ public function testVerifyRequestStackPushPopDuringHandle() { $request = new Request(); - $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(['push', 'pop'])->getMock(); + $stack = $this->getMockBuilder(RequestStack::class)->setMethods(['push', 'pop'])->getMock(); $stack->expects($this->once())->method('push')->with($this->equalTo($request)); $stack->expects($this->once())->method('pop'); @@ -315,7 +315,7 @@ public function testVerifyRequestStackPushPopDuringHandle() public function testInconsistentClientIpsOnMasterRequests() { - $this->expectException('Symfony\Component\HttpKernel\Exception\BadRequestHttpException'); + $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $request = new Request(); $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); $request->server->set('REMOTE_ADDR', '1.1.1.1'); diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 18974a720b..570e6f0298 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -77,7 +77,7 @@ public function testClone() public function testClassNameValidityGetter() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The environment "test.env" contains invalid characters, it can only contain characters allowed in PHP class names.'); // We check the classname that will be generated by using a $env that // contains invalid characters. @@ -125,7 +125,7 @@ public function testBootInitializesBundlesAndContainer() public function testBootSetsTheContainerToTheBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle->expects($this->once()) ->method('setContainer'); @@ -167,7 +167,7 @@ public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() public function testShutdownCallsShutdownOnAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle->expects($this->once()) ->method('shutdown'); @@ -179,7 +179,7 @@ public function testShutdownCallsShutdownOnAllBundles() public function testShutdownGivesNullContainerToAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); + $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); $bundle->expects($this->exactly(2)) ->method('setContainer') ->withConsecutive( @@ -202,7 +202,7 @@ public function testHandleCallsHandleOnHttpKernel() $catch = true; $request = new Request(); - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') + $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) ->disableOriginalConstructor() ->getMock(); $httpKernelMock @@ -224,7 +224,7 @@ public function testHandleBootsTheKernel() $catch = true; $request = new Request(); - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') + $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) ->disableOriginalConstructor() ->getMock(); @@ -381,25 +381,25 @@ public function testSerialize() public function testLocateResourceThrowsExceptionWhenNameIsNotValid() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->getKernel()->locateResource('Foo'); } public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() { - $this->expectException('RuntimeException'); + $this->expectException(\RuntimeException::class); $this->getKernel()->locateResource('@FooBundle/../bar'); } public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->getKernel()->locateResource('@FooBundle/config/routing.xml'); } public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() { - $this->expectException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) @@ -501,7 +501,7 @@ public function testLocateResourceOnDirectories() public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() { - $this->expectException('LogicException'); + $this->expectException(\LogicException::class); $this->expectExceptionMessage('Trying to register two bundles with the same name "DuplicateName"'); $fooBundle = $this->getBundle(__DIR__.'/Fixtures/FooBundle', null, 'FooBundle', 'DuplicateName'); $barBundle = $this->getBundle(__DIR__.'/Fixtures/BarBundle', null, 'BarBundle', 'DuplicateName'); @@ -547,7 +547,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $this->assertFalse($httpKernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); // implements TerminableInterface - $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') + $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) ->disableOriginalConstructor() ->setMethods(['terminate']) ->getMock(); @@ -690,7 +690,7 @@ public function getContainerClass(): string protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null): BundleInterface { $bundle = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') + ->getMockBuilder(BundleInterface::class) ->setMethods(['getPath', 'getName']) ->disableOriginalConstructor() ; diff --git a/Tests/Log/LoggerTest.php b/Tests/Log/LoggerTest.php index 607ab31cb8..fb2b43cc82 100644 --- a/Tests/Log/LoggerTest.php +++ b/Tests/Log/LoggerTest.php @@ -109,19 +109,19 @@ public function testLogLevelDisabled() public function testThrowsOnInvalidLevel() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); $this->logger->log('invalid level', 'Foo'); } public function testThrowsOnInvalidMinLevel() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); new Logger('invalid'); } public function testInvalidOutput() { - $this->expectException('Psr\Log\InvalidArgumentException'); + $this->expectException(\Psr\Log\InvalidArgumentException::class); new Logger(LogLevel::DEBUG, '/'); } From 9579bea317a26811bfcfecea051ba3ba02d6a6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sat, 12 Dec 2020 16:46:18 +0100 Subject: [PATCH 126/266] Dont allow unserializing classes with a destructor --- DataCollector/DataCollector.php | 4 ++++ DataCollector/DumpDataCollector.php | 2 +- Kernel.php | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 832a5d9ebf..3938dab6a1 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -123,6 +123,10 @@ public function __sleep() public function __wakeup() { if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'unserialize'))->getDeclaringClass()->name) { + if (\is_object($this->data)) { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + @trigger_error(sprintf('Implementing the "%s::unserialize()" method is deprecated since Symfony 4.3, store all the serialized state in the "data" property instead.', $c), \E_USER_DEPRECATED); $this->unserialize($this->data); } diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index df4ec5f670..af8b3a9458 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -184,7 +184,7 @@ public function __wakeup() $fileLinkFormat = array_pop($this->data); $this->dataCount = \count($this->data); - self::__construct($this->stopwatch, $fileLinkFormat, $charset); + self::__construct($this->stopwatch, \is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \is_string($charset) ? $charset : null); } public function getDumpsCount() diff --git a/Kernel.php b/Kernel.php index b91fc66a9f..c9317c81ca 100644 --- a/Kernel.php +++ b/Kernel.php @@ -920,6 +920,10 @@ public function __sleep() public function __wakeup() { + if (\is_object($this->environment) || \is_object($this->debug)) { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) { @trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3.', $c), \E_USER_DEPRECATED); $this->unserialize($this->serialized); From dd23275704a4f73da76ace9bbc479ac15ba09406 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 14 Jan 2021 00:57:45 +0100 Subject: [PATCH 127/266] [travis] use PHP 8.0 to patch return types and run deps=low --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 459e5f4682..0094dc575f 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "symfony/translation": "^4.2|^5.0", "symfony/translation-contracts": "^1.1|^2", "psr/cache": "~1.0", - "twig/twig": "^1.34|^2.4|^3.0" + "twig/twig": "^1.43|^2.13|^3.0.4" }, "provide": { "psr/log-implementation": "1.0" @@ -53,7 +53,7 @@ "symfony/console": ">=5", "symfony/dependency-injection": "<4.3", "symfony/translation": "<4.2", - "twig/twig": "<1.34|<2.4,>=2" + "twig/twig": "<1.43|<2.13,>=2" }, "suggest": { "symfony/browser-kit": "", From 27eff2a1cc7c86fb408fbd1f014bc9bab14fb485 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 14 Jan 2021 16:08:15 +0100 Subject: [PATCH 128/266] CS fix --- DataCollector/DumpDataCollector.php | 2 +- HttpCache/Store.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index af8b3a9458..ae751c4f2e 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -194,7 +194,7 @@ public function getDumpsCount() public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) { - $data = fopen('php://memory', 'r+b'); + $data = fopen('php://memory', 'r+'); if ('html' === $format) { $dumper = new HtmlDumper($data, $this->charset); diff --git a/HttpCache/Store.php b/HttpCache/Store.php index bfaaebe944..3b69289f17 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -69,7 +69,7 @@ public function lock(Request $request) if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) { return $path; } - $h = fopen($path, 'cb'); + $h = fopen($path, 'c'); if (!flock($h, \LOCK_EX | \LOCK_NB)) { fclose($h); @@ -114,7 +114,7 @@ public function isLocked(Request $request) return false; } - $h = fopen($path, 'rb'); + $h = fopen($path, 'r'); flock($h, \LOCK_EX | \LOCK_NB, $wouldBlock); flock($h, \LOCK_UN); // release the lock we just acquired fclose($h); @@ -379,7 +379,7 @@ private function save(string $key, string $data, bool $overwrite = true): bool } $tmpFile = tempnam(\dirname($path), basename($path)); - if (false === $fp = @fopen($tmpFile, 'wb')) { + if (false === $fp = @fopen($tmpFile, 'w')) { @unlink($tmpFile); return false; From 8445c3a1c2b1de33bc12337d66cedbbdbfc582ed Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 22 Jan 2021 17:56:23 +0100 Subject: [PATCH 129/266] [HttpKernel] Configure the ErrorHandler even when it is overriden --- EventListener/DebugHandlersListener.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index f4781ccd8e..cfc277e330 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -33,6 +33,7 @@ */ class DebugHandlersListener implements EventSubscriberInterface { + private $earlyHandler; private $exceptionHandler; private $logger; private $levels; @@ -53,6 +54,10 @@ class DebugHandlersListener implements EventSubscriberInterface */ public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true) { + $handler = set_exception_handler('var_dump'); + $this->earlyHandler = \is_array($handler) ? $handler[0] : null; + restore_exception_handler(); + $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; $this->levels = null === $levels ? \E_ALL : $levels; @@ -79,6 +84,10 @@ public function configure(Event $event = null) $handler = \is_array($handler) ? $handler[0] : null; restore_exception_handler(); + if (!$handler instanceof ErrorHandler && !$handler instanceof LegacyErrorHandler) { + $handler = $this->earlyHandler; + } + if ($this->logger || null !== $this->throwAt) { if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { if ($this->logger) { From df632a4552f2b2fffa74b76f674a7511e919dec8 Mon Sep 17 00:00:00 2001 From: Simon Berger Date: Sun, 24 Jan 2021 23:22:56 +0100 Subject: [PATCH 130/266] Changed private static array-properties to const --- HttpCache/ResponseCacheStrategy.php | 8 ++++---- Log/Logger.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index c30fface60..1f09946846 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -27,12 +27,12 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface /** * Cache-Control headers that are sent to the final response if they appear in ANY of the responses. */ - private static $overrideDirectives = ['private', 'no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate']; + private const OVERRIDE_DIRECTIVES = ['private', 'no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate']; /** * Cache-Control headers that are sent to the final response if they appear in ALL of the responses. */ - private static $inheritDirectives = ['public', 'immutable']; + private const INHERIT_DIRECTIVES = ['public', 'immutable']; private $embeddedResponses = 0; private $isNotCacheableResponseEmbedded = false; @@ -60,13 +60,13 @@ public function add(Response $response) { ++$this->embeddedResponses; - foreach (self::$overrideDirectives as $directive) { + foreach (self::OVERRIDE_DIRECTIVES as $directive) { if ($response->headers->hasCacheControlDirective($directive)) { $this->flagDirectives[$directive] = true; } } - foreach (self::$inheritDirectives as $directive) { + foreach (self::INHERIT_DIRECTIVES as $directive) { if (false !== $this->flagDirectives[$directive]) { $this->flagDirectives[$directive] = $response->headers->hasCacheControlDirective($directive); } diff --git a/Log/Logger.php b/Log/Logger.php index 0181817bdf..3922d2fe68 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -22,7 +22,7 @@ */ class Logger extends AbstractLogger { - private static $levels = [ + private const LEVELS = [ LogLevel::DEBUG => 0, LogLevel::INFO => 1, LogLevel::NOTICE => 2, @@ -52,11 +52,11 @@ public function __construct(string $minLevel = null, $output = null, callable $f } } - if (!isset(self::$levels[$minLevel])) { + if (!isset(self::LEVELS[$minLevel])) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel)); } - $this->minLevelIndex = self::$levels[$minLevel]; + $this->minLevelIndex = self::LEVELS[$minLevel]; $this->formatter = $formatter ?: [$this, 'format']; if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); @@ -70,11 +70,11 @@ public function __construct(string $minLevel = null, $output = null, callable $f */ public function log($level, $message, array $context = []) { - if (!isset(self::$levels[$level])) { + if (!isset(self::LEVELS[$level])) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); } - if (self::$levels[$level] < $this->minLevelIndex) { + if (self::LEVELS[$level] < $this->minLevelIndex) { return; } From ba084ae291409f62b9aba826f1a2d9425e3b52d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 26 Jan 2021 19:15:20 +0100 Subject: [PATCH 131/266] Fix transient tests --- Tests/Fragment/InlineFragmentRendererTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index c25297dbe4..156e16d03b 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -23,6 +23,9 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +/** + * @group time-sensitive + */ class InlineFragmentRendererTest extends TestCase { public function testRender() @@ -253,8 +256,7 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() } /** - * Creates a Kernel expecting a request equals to $request - * Allows delta in comparison in case REQUEST_TIME changed by 1 second. + * Creates a Kernel expecting a request equals to $request. */ private function getKernelExpectingRequest(Request $request, $strict = false) { @@ -262,7 +264,7 @@ private function getKernelExpectingRequest(Request $request, $strict = false) $kernel ->expects($this->once()) ->method('handle') - ->with($this->equalTo($request, 1)) + ->with($request) ->willReturn(new Response('foo')); return $kernel; From f75654ca581fabb3e3b719f03ace7d3f59a84bc4 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 22 Jan 2021 13:09:22 +0100 Subject: [PATCH 132/266] Use createMock() and use import instead of FQCN --- Tests/CacheClearer/ChainCacheClearerTest.php | 3 +- Tests/CacheClearer/Psr6CacheClearerTest.php | 4 +- .../CacheWarmer/CacheWarmerAggregateTest.php | 16 ++------ Tests/Config/FileLocatorTest.php | 5 ++- .../NotTaggedControllerValueResolverTest.php | 9 +++-- .../ServiceValueResolverTest.php | 3 +- Tests/Controller/ArgumentResolverTest.php | 6 +-- .../ContainerControllerResolverTest.php | 6 +-- Tests/Controller/ControllerResolverTest.php | 2 +- Tests/Controller/ErrorControllerTest.php | 4 +- Tests/DataCollector/DumpDataCollectorTest.php | 2 +- .../RequestDataCollectorTest.php | 7 ++-- Tests/DataCollector/TimeDataCollectorTest.php | 3 +- Tests/Debug/TraceableEventDispatcherTest.php | 6 ++- .../LazyLoadingFragmentHandlerTest.php | 9 +++-- ...sterControllerArgumentLocatorsPassTest.php | 17 ++++---- .../ResettableServicePassTest.php | 3 +- .../AddRequestFormatsListenerTest.php | 11 ++---- .../DebugHandlersListenerTest.php | 7 ++-- Tests/EventListener/ErrorListenerTest.php | 8 ++-- Tests/EventListener/ExceptionListenerTest.php | 9 +++-- Tests/EventListener/FragmentListenerTest.php | 7 ++-- .../EventListener/LocaleAwareListenerTest.php | 4 +- Tests/EventListener/LocaleListenerTest.php | 15 ++++--- Tests/EventListener/ProfilerListenerTest.php | 26 +++++-------- Tests/EventListener/ResponseListenerTest.php | 2 +- Tests/EventListener/RouterListenerTest.php | 39 ++++++++++--------- .../EventListener/SaveSessionListenerTest.php | 6 +-- Tests/EventListener/SessionListenerTest.php | 30 +++++++------- Tests/EventListener/SurrogateListenerTest.php | 6 +-- .../EventListener/TestSessionListenerTest.php | 18 ++++----- .../EventListener/TranslatorListenerTest.php | 7 ++-- .../ValidateRequestListenerTest.php | 5 ++- Tests/Fragment/EsiFragmentRendererTest.php | 3 +- Tests/Fragment/FragmentHandlerTest.php | 9 ++--- .../Fragment/HIncludeFragmentRendererTest.php | 3 +- Tests/Fragment/InlineFragmentRendererTest.php | 15 ++++--- .../Fragment/RoutableFragmentRendererTest.php | 3 +- Tests/Fragment/SsiFragmentRendererTest.php | 3 +- Tests/HttpCache/EsiTest.php | 3 +- Tests/HttpCache/HttpCacheTest.php | 10 +++-- Tests/HttpCache/SsiTest.php | 3 +- Tests/HttpClientKernelTest.php | 4 +- Tests/HttpKernelBrowserTest.php | 3 +- Tests/HttpKernelTest.php | 10 +++-- Tests/KernelTest.php | 14 ++++--- 46 files changed, 203 insertions(+), 185 deletions(-) diff --git a/Tests/CacheClearer/ChainCacheClearerTest.php b/Tests/CacheClearer/ChainCacheClearerTest.php index a0b4bd8c41..80c1b576be 100644 --- a/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/Tests/CacheClearer/ChainCacheClearerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\CacheClearer; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface; use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer; class ChainCacheClearerTest extends TestCase @@ -41,6 +42,6 @@ public function testInjectClearersInConstructor() protected function getMockClearer() { - return $this->getMockBuilder(\Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface::class)->getMock(); + return $this->createMock(CacheClearerInterface::class); } } diff --git a/Tests/CacheClearer/Psr6CacheClearerTest.php b/Tests/CacheClearer/Psr6CacheClearerTest.php index c7c683428e..0c6f1543ac 100644 --- a/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -19,7 +19,7 @@ class Psr6CacheClearerTest extends TestCase { public function testClearPoolsInjectedInConstructor() { - $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); + $pool = $this->createMock(CacheItemPoolInterface::class); $pool ->expects($this->once()) ->method('clear'); @@ -29,7 +29,7 @@ public function testClearPoolsInjectedInConstructor() public function testClearPool() { - $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock(); + $pool = $this->createMock(CacheItemPoolInterface::class); $pool ->expects($this->once()) ->method('clear'); diff --git a/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/Tests/CacheWarmer/CacheWarmerAggregateTest.php index cf9493a295..c34cc9c400 100644 --- a/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ b/Tests/CacheWarmer/CacheWarmerAggregateTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; +use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; class CacheWarmerAggregateTest extends TestCase { @@ -30,7 +31,7 @@ public static function tearDownAfterClass(): void public function testInjectWarmersUsingConstructor() { - $warmer = $this->getCacheWarmerMock(); + $warmer = $this->createMock(CacheWarmerInterface::class); $warmer ->expects($this->once()) ->method('warmUp'); @@ -40,7 +41,7 @@ public function testInjectWarmersUsingConstructor() public function testWarmupDoesCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsEnabled() { - $warmer = $this->getCacheWarmerMock(); + $warmer = $this->createMock(CacheWarmerInterface::class); $warmer ->expects($this->never()) ->method('isOptional'); @@ -55,7 +56,7 @@ public function testWarmupDoesCallWarmupOnOptionalWarmersWhenEnableOptionalWarme public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWarmersIsNotEnabled() { - $warmer = $this->getCacheWarmerMock(); + $warmer = $this->createMock(CacheWarmerInterface::class); $warmer ->expects($this->once()) ->method('isOptional') @@ -67,13 +68,4 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa $aggregate = new CacheWarmerAggregate([$warmer]); $aggregate->warmUp(self::$cacheDir); } - - protected function getCacheWarmerMock() - { - $warmer = $this->getMockBuilder(\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - return $warmer; - } } diff --git a/Tests/Config/FileLocatorTest.php b/Tests/Config/FileLocatorTest.php index d992286752..e70e49e83c 100644 --- a/Tests/Config/FileLocatorTest.php +++ b/Tests/Config/FileLocatorTest.php @@ -13,12 +13,13 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Config\FileLocator; +use Symfony\Component\HttpKernel\KernelInterface; class FileLocatorTest extends TestCase { public function testLocate() { - $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); + $kernel = $this->createMock(KernelInterface::class); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') @@ -39,7 +40,7 @@ public function testLocate() */ public function testLocateWithGlobalResourcePath() { - $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); + $kernel = $this->createMock(KernelInterface::class); $kernel ->expects($this->atLeastOnce()) ->method('locateResource') diff --git a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php index efb7322efa..3cf2f0f185 100644 --- a/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver; use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\NotTaggedControllerValueResolver; @@ -55,7 +56,7 @@ public function testDoNotSupportEmptyController() public function testController() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -66,7 +67,7 @@ public function testController() public function testControllerWithATrailingBackSlash() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -77,7 +78,7 @@ public function testControllerWithATrailingBackSlash() public function testControllerWithMethodNameStartUppercase() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); @@ -88,7 +89,7 @@ public function testControllerWithMethodNameStartUppercase() public function testControllerNameIsAnArray() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?'); $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null); diff --git a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index 743eefa3e5..69b9511c05 100644 --- a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver; @@ -107,7 +108,7 @@ public function testControllerNameIsAnArray() public function testErrorIsTruncated() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Cannot autowire argument $dummy of "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyController::index()": it references class "Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver\DummyService" but no such service exists.'); $container = new ContainerBuilder(); $container->addCompilerPass(new RegisterControllerArgumentLocatorsPass()); diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index da521ff204..40638b4fe6 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -177,7 +177,7 @@ public function testGetArgumentWithoutArray() { $this->expectException(\InvalidArgumentException::class); $factory = new ArgumentMetadataFactory(); - $valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock(); + $valueResolver = $this->createMock(ArgumentValueResolverInterface::class); $resolver = new ArgumentResolver($factory, [$valueResolver]); $valueResolver->expects($this->any())->method('supports')->willReturn(true); @@ -241,7 +241,7 @@ public function testGetSessionArgumentsWithExtendedSession() public function testGetSessionArgumentsWithInterface() { - $session = $this->getMockBuilder(SessionInterface::class)->getMock(); + $session = $this->createMock(SessionInterface::class); $request = Request::create('/'); $request->setSession($session); $controller = [$this, 'controllerWithSessionInterface']; @@ -252,7 +252,7 @@ public function testGetSessionArgumentsWithInterface() public function testGetSessionMissMatchWithInterface() { $this->expectException(\RuntimeException::class); - $session = $this->getMockBuilder(SessionInterface::class)->getMock(); + $session = $this->createMock(SessionInterface::class); $request = Request::create('/'); $request->setSession($session); $controller = [$this, 'controllerWithExtendingSession']; diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 7f4564688c..1c239fc4c0 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -153,7 +153,7 @@ public function testExceptionWhenUsingRemovedControllerServiceWithClassNameAsNam { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); - $container = $this->getMockBuilder(Container::class)->getMock(); + $container = $this->createMock(Container::class); $container->expects($this->once()) ->method('has') ->with(ControllerTestService::class) @@ -177,7 +177,7 @@ public function testExceptionWhenUsingRemovedControllerService() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); - $container = $this->getMockBuilder(Container::class)->getMock(); + $container = $this->createMock(Container::class); $container->expects($this->once()) ->method('has') ->with('app.my_controller') @@ -232,7 +232,7 @@ protected function createControllerResolver(LoggerInterface $logger = null, Cont protected function createMockContainer() { - return $this->getMockBuilder(ContainerInterface::class)->getMock(); + return $this->createMock(ContainerInterface::class); } } diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index 834f925c43..2afcfe4b4e 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -20,7 +20,7 @@ class ControllerResolverTest extends TestCase { public function testGetControllerWithoutControllerParameter() { - $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $logger->expects($this->once())->method('warning')->with('Unable to look for the controller as the "_controller" parameter is missing.'); $resolver = $this->createControllerResolver($logger); diff --git a/Tests/Controller/ErrorControllerTest.php b/Tests/Controller/ErrorControllerTest.php index fadd820ea6..1b3a833578 100644 --- a/Tests/Controller/ErrorControllerTest.php +++ b/Tests/Controller/ErrorControllerTest.php @@ -27,7 +27,7 @@ class ErrorControllerTest extends TestCase */ public function testInvokeController(Request $request, \Exception $exception, int $statusCode, string $content) { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $errorRenderer = new HtmlErrorRenderer(); $controller = new ErrorController($kernel, null, $errorRenderer); $response = $controller($exception); @@ -67,7 +67,7 @@ public function testPreviewController() $_controller = 'error_controller'; $code = 404; - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel ->expects($this->once()) ->method('handle') diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index a40a482278..c69166bf09 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -62,7 +62,7 @@ public function testDumpWithServerConnection() $data = new Data([[123]]); // Server is up, server dumper is used - $serverDumper = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); + $serverDumper = $this->createMock(Connection::class); $serverDumper->expects($this->once())->method('write')->willReturn(true); $collector = new DumpDataCollector(null, null, null, null, $serverDumper); diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index bb29b4ba52..e81a6e5b57 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -21,6 +21,7 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; +use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; use Symfony\Component\HttpKernel\Event\ControllerEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; @@ -203,7 +204,7 @@ public function testItAddsRedirectedAttributesWhenRequestContainsSpecificCookie( 'sf_redirect' => '{}', ]); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $c = new RequestDataCollector(); $c->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $this->createResponse())); @@ -288,8 +289,8 @@ protected function createResponse() */ protected function injectController($collector, $controller, $request) { - $resolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); - $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock()); + $resolver = $this->createMock(ControllerResolverInterface::class); + $httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->createMock(ArgumentResolverInterface::class)); $event = new ControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST); $collector->onKernelController($event); } diff --git a/Tests/DataCollector/TimeDataCollectorTest.php b/Tests/DataCollector/TimeDataCollectorTest.php index ab231ac4c5..0496f1a3d1 100644 --- a/Tests/DataCollector/TimeDataCollectorTest.php +++ b/Tests/DataCollector/TimeDataCollectorTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Stopwatch\Stopwatch; /** @@ -43,7 +44,7 @@ public function testCollect() $c->collect($request, new Response()); $this->assertEquals(0, $c->getStartTime()); - $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock(); + $kernel = $this->createMock(KernelInterface::class); $kernel->expects($this->once())->method('getStartTime')->willReturn(123456.0); $c = new TimeDataCollector($kernel); diff --git a/Tests/Debug/TraceableEventDispatcherTest.php b/Tests/Debug/TraceableEventDispatcherTest.php index c4d42ec648..2fb050dafd 100644 --- a/Tests/Debug/TraceableEventDispatcherTest.php +++ b/Tests/Debug/TraceableEventDispatcherTest.php @@ -17,6 +17,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; +use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\Stopwatch\Stopwatch; @@ -110,9 +112,9 @@ public function testListenerCanRemoveItselfWhenExecuted() protected function getHttpKernel($dispatcher, $controller) { - $controllerResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); + $controllerResolver = $this->createMock(ControllerResolverInterface::class); $controllerResolver->expects($this->once())->method('getController')->willReturn($controller); - $argumentResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface::class)->getMock(); + $argumentResolver = $this->createMock(ArgumentResolverInterface::class); $argumentResolver->expects($this->once())->method('getArguments')->willReturn([]); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); diff --git a/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 493178d470..c8db5e55e9 100644 --- a/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -12,22 +12,25 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; +use Psr\Container\ContainerInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler; +use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; class LazyLoadingFragmentHandlerTest extends TestCase { public function testRender() { - $renderer = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); + $renderer = $this->createMock(FragmentRendererInterface::class); $renderer->expects($this->once())->method('getName')->willReturn('foo'); $renderer->expects($this->any())->method('render')->willReturn(new Response()); - $requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); + $requestStack = $this->createMock(RequestStack::class); $requestStack->expects($this->any())->method('getCurrentRequest')->willReturn(Request::create('/')); - $container = $this->getMockBuilder(\Psr\Container\ContainerInterface::class)->getMock(); + $container = $this->createMock(ContainerInterface::class); $container->expects($this->once())->method('has')->with('foo')->willReturn(true); $container->expects($this->once())->method('get')->willReturn($renderer); diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 8a65b4ff38..c00e1849fc 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -18,6 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\DependencyInjection\TypedReference; @@ -27,7 +28,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase { public function testInvalidClass() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Class "Symfony\Component\HttpKernel\Tests\DependencyInjection\NotFound" used for service "foo" cannot be found.'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -42,7 +43,7 @@ public function testInvalidClass() public function testNoAction() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Missing "action" attribute on tag "controller.service_arguments" {"argument":"bar"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -57,7 +58,7 @@ public function testNoAction() public function testNoArgument() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Missing "argument" attribute on tag "controller.service_arguments" {"action":"fooAction"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -72,7 +73,7 @@ public function testNoArgument() public function testNoService() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Missing "id" attribute on tag "controller.service_arguments" {"action":"fooAction","argument":"bar"} for service "foo".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -87,7 +88,7 @@ public function testNoService() public function testInvalidMethod() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "action" attribute on tag "controller.service_arguments" for service "foo": no public "barAction()" method found on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -102,7 +103,7 @@ public function testInvalidMethod() public function testInvalidArgument() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid "controller.service_arguments" tag for service "foo": method "fooAction()" has no "baz" argument on class "Symfony\Component\HttpKernel\Tests\DependencyInjection\RegisterTestController".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -197,7 +198,7 @@ public function testSkipSetContainer() public function testExceptionOnNonExistentTypeHint() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -211,7 +212,7 @@ public function testExceptionOnNonExistentTypeHint() public function testExceptionOnNonExistentTypeHintDifferentNamespace() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); diff --git a/Tests/DependencyInjection/ResettableServicePassTest.php b/Tests/DependencyInjection/ResettableServicePassTest.php index b28f90d362..4c110e3a26 100644 --- a/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/Tests/DependencyInjection/ResettableServicePassTest.php @@ -6,6 +6,7 @@ use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; @@ -57,7 +58,7 @@ public function testCompilerPass() public function testMissingMethod() { - $this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Tag "kernel.reset" requires the "method" attribute to be set.'); $container = new ContainerBuilder(); $container->register(ResettableService::class) diff --git a/Tests/EventListener/AddRequestFormatsListenerTest.php b/Tests/EventListener/AddRequestFormatsListenerTest.php index 6c4459fc2a..def3831851 100644 --- a/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; @@ -41,7 +42,7 @@ protected function tearDown(): void public function testIsAnEventSubscriber() { - $this->assertInstanceOf(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class, $this->listener); + $this->assertInstanceOf(EventSubscriberInterface::class, $this->listener); } public function testRegisteredEvent() @@ -66,16 +67,12 @@ public function testSetAdditionalFormats() protected function getRequestMock() { - return $this->getMockBuilder(Request::class)->getMock(); + return $this->createMock(Request::class); } protected function getRequestEventMock(Request $request) { - $event = $this - ->getMockBuilder(RequestEvent::class) - ->disableOriginalConstructor() - ->getMock(); - + $event = $this->createMock(RequestEvent::class); $event->expects($this->any()) ->method('getRequest') ->willReturn($request); diff --git a/Tests/EventListener/DebugHandlersListenerTest.php b/Tests/EventListener/DebugHandlersListenerTest.php index fb18d63fbe..8d74b2c0dd 100644 --- a/Tests/EventListener/DebugHandlersListenerTest.php +++ b/Tests/EventListener/DebugHandlersListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; @@ -35,7 +36,7 @@ class DebugHandlersListenerTest extends TestCase { public function testConfigure() { - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $userHandler = function () {}; $listener = new DebugHandlersListener($userHandler, $logger); $eHandler = new ErrorHandler(); @@ -67,7 +68,7 @@ public function testConfigureForHttpKernelWithNoTerminateWithException() $listener = new DebugHandlersListener(null); $eHandler = new ErrorHandler(); $event = new KernelEvent( - $this->getMockBuilder(HttpKernelInterface::class)->getMock(), + $this->createMock(HttpKernelInterface::class), Request::create('/'), HttpKernelInterface::MASTER_REQUEST ); @@ -91,7 +92,7 @@ public function testConsoleEvent() { $dispatcher = new EventDispatcher(); $listener = new DebugHandlersListener(null); - $app = $this->getMockBuilder(Application::class)->getMock(); + $app = $this->createMock(Application::class); $app->expects($this->once())->method('getHelperSet')->willReturn(new HelperSet()); $command = new Command(__FUNCTION__); $command->setApplication($app); diff --git a/Tests/EventListener/ErrorListenerTest.php b/Tests/EventListener/ErrorListenerTest.php index 4428e3d1a6..2cd1091a7f 100644 --- a/Tests/EventListener/ErrorListenerTest.php +++ b/Tests/EventListener/ErrorListenerTest.php @@ -115,9 +115,9 @@ public function provider() public function testSubRequestFormat() { - $listener = new ErrorListener('foo', $this->getMockBuilder(LoggerInterface::class)->getMock()); + $listener = new ErrorListener('foo', $this->createMock(LoggerInterface::class)); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); @@ -135,12 +135,12 @@ public function testSubRequestFormat() public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); - $listener = new ErrorListener('foo', $this->getMockBuilder(LoggerInterface::class)->getMock(), true); + $listener = new ErrorListener('foo', $this->createMock(LoggerInterface::class), true); $dispatcher->addSubscriber($listener); diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index 91ff62d906..6163f5b56e 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -112,9 +113,9 @@ public function provider() public function testSubRequestFormat() { - $listener = new ExceptionListener('foo', $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock()); + $listener = new ExceptionListener('foo', $this->createMock(LoggerInterface::class)); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); @@ -132,12 +133,12 @@ public function testSubRequestFormat() public function testCSPHeaderIsRemoved() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getRequestFormat()); }); - $listener = new ExceptionListener('foo', $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(), true); + $listener = new ExceptionListener('foo', $this->createMock(LoggerInterface::class), true); $dispatcher->addSubscriber($listener); diff --git a/Tests/EventListener/FragmentListenerTest.php b/Tests/EventListener/FragmentListenerTest.php index e0b857debd..5720420dbf 100644 --- a/Tests/EventListener/FragmentListenerTest.php +++ b/Tests/EventListener/FragmentListenerTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\FragmentListener; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\UriSigner; @@ -52,7 +53,7 @@ public function testOnlyTriggeredIfControllerWasNotDefinedYet() public function testAccessDeniedWithNonSafeMethods() { - $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); + $this->expectException(AccessDeniedHttpException::class); $request = Request::create('http://example.com/_fragment', 'POST'); $listener = new FragmentListener(new UriSigner('foo')); @@ -63,7 +64,7 @@ public function testAccessDeniedWithNonSafeMethods() public function testAccessDeniedWithWrongSignature() { - $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); + $this->expectException(AccessDeniedHttpException::class); $request = Request::create('http://example.com/_fragment', 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']); $listener = new FragmentListener(new UriSigner('foo')); @@ -113,6 +114,6 @@ public function testRemovesPathWithControllerNotDefined() private function createRequestEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST) { - return new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, $requestType); + return new RequestEvent($this->createMock(HttpKernelInterface::class), $request, $requestType); } } diff --git a/Tests/EventListener/LocaleAwareListenerTest.php b/Tests/EventListener/LocaleAwareListenerTest.php index 0d14e5a987..20c9f9d8c9 100644 --- a/Tests/EventListener/LocaleAwareListenerTest.php +++ b/Tests/EventListener/LocaleAwareListenerTest.php @@ -28,7 +28,7 @@ class LocaleAwareListenerTest extends TestCase protected function setUp(): void { - $this->localeAwareService = $this->getMockBuilder(LocaleAwareInterface::class)->getMock(); + $this->localeAwareService = $this->createMock(LocaleAwareInterface::class); $this->requestStack = new RequestStack(); $this->listener = new LocaleAwareListener(new \ArrayIterator([$this->localeAwareService]), $this->requestStack); } @@ -110,7 +110,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() private function createHttpKernel() { - return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + return $this->createMock(HttpKernelInterface::class); } private function createRequest($locale) diff --git a/Tests/EventListener/LocaleListenerTest.php b/Tests/EventListener/LocaleListenerTest.php index 705600d70e..186ce43b1d 100644 --- a/Tests/EventListener/LocaleListenerTest.php +++ b/Tests/EventListener/LocaleListenerTest.php @@ -14,11 +14,14 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\LocaleListener; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\Routing\RequestContext; +use Symfony\Component\Routing\Router; class LocaleListenerTest extends TestCase { @@ -26,7 +29,7 @@ class LocaleListenerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->disableOriginalConstructor()->getMock(); + $this->requestStack = $this->createMock(RequestStack::class); } public function testIsAnEventSubscriber() @@ -70,10 +73,10 @@ public function testLocaleFromRequestAttribute() public function testLocaleSetForRoutingContext() { // the request context is updated - $context = $this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock(); + $context = $this->createMock(RequestContext::class); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder(\Symfony\Component\Routing\Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder(Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->willReturn($context); $request = Request::create('/'); @@ -86,10 +89,10 @@ public function testLocaleSetForRoutingContext() public function testRouterResetWithParentRequestOnKernelFinishRequest() { // the request context is updated - $context = $this->getMockBuilder(\Symfony\Component\Routing\RequestContext::class)->getMock(); + $context = $this->createMock(RequestContext::class); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder(\Symfony\Component\Routing\Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder(Router::class)->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->willReturn($context); $parentRequest = Request::create('/'); @@ -116,6 +119,6 @@ public function testRequestLocaleIsNotOverridden() private function getEvent(Request $request): RequestEvent { - return new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); + return new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); } } diff --git a/Tests/EventListener/ProfilerListenerTest.php b/Tests/EventListener/ProfilerListenerTest.php index 4b076ef17d..8f7aca2a00 100644 --- a/Tests/EventListener/ProfilerListenerTest.php +++ b/Tests/EventListener/ProfilerListenerTest.php @@ -12,14 +12,18 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\Event\TerminateEvent; use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Profiler\Profile; +use Symfony\Component\HttpKernel\Profiler\Profiler; class ProfilerListenerTest extends TestCase { @@ -30,27 +34,15 @@ public function testKernelTerminate() { $profile = new Profile('token'); - $profiler = $this->getMockBuilder(\Symfony\Component\HttpKernel\Profiler\Profiler::class) - ->disableOriginalConstructor() - ->getMock(); - + $profiler = $this->createMock(Profiler::class); $profiler->expects($this->once()) ->method('collect') ->willReturn($profile); - $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); - - $masterRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class) - ->disableOriginalConstructor() - ->getMock(); - - $subRequest = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Request::class) - ->disableOriginalConstructor() - ->getMock(); - - $response = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Response::class) - ->disableOriginalConstructor() - ->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); + $masterRequest = $this->createMock(Request::class); + $subRequest = $this->createMock(Request::class); + $response = $this->createMock(Response::class); $requestStack = new RequestStack(); $requestStack->push($masterRequest); diff --git a/Tests/EventListener/ResponseListenerTest.php b/Tests/EventListener/ResponseListenerTest.php index 31cfa38477..6c5af2a6dd 100644 --- a/Tests/EventListener/ResponseListenerTest.php +++ b/Tests/EventListener/ResponseListenerTest.php @@ -32,7 +32,7 @@ protected function setUp(): void $listener = new ResponseListener('UTF-8'); $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); - $this->kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $this->kernel = $this->createMock(HttpKernelInterface::class); } protected function tearDown(): void diff --git a/Tests/EventListener/RouterListenerTest.php b/Tests/EventListener/RouterListenerTest.php index 59e63deea8..cc46fd8db5 100644 --- a/Tests/EventListener/RouterListenerTest.php +++ b/Tests/EventListener/RouterListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -22,9 +23,12 @@ use Symfony\Component\HttpKernel\EventListener\ErrorListener; use Symfony\Component\HttpKernel\EventListener\RouterListener; use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Routing\Exception\NoConfigurationException; +use Symfony\Component\Routing\Matcher\RequestMatcherInterface; +use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\RequestContext; class RouterListenerTest extends TestCase @@ -33,7 +37,7 @@ class RouterListenerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->getMock(); + $this->requestStack = $this->createMock(RequestStack::class); } /** @@ -41,9 +45,8 @@ protected function setUp(): void */ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHttpPort, $expectedHttpsPort) { - $urlMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\UrlMatcherInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $urlMatcher = $this->createMock(UrlMatcherInterface::class); + $context = new RequestContext(); $context->setHttpPort($defaultHttpPort); $context->setHttpsPort($defaultHttpsPort); @@ -72,7 +75,7 @@ public function getPortData() private function createRequestEventForUri(string $uri): RequestEvent { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create($uri); $request->attributes->set('_controller', null); // Prevents going in to routing process @@ -87,11 +90,11 @@ public function testInvalidMatcher() public function testRequestMatcher() { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://localhost/'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); + $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher->expects($this->once()) ->method('matchRequest') ->with($this->isInstanceOf(Request::class)) @@ -103,11 +106,11 @@ public function testRequestMatcher() public function testSubRequestWithDifferentMethod() { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://localhost/', 'post'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); + $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher->expects($this->any()) ->method('matchRequest') ->with($this->isInstanceOf(Request::class)) @@ -119,7 +122,7 @@ public function testSubRequestWithDifferentMethod() $listener->onKernelRequest($event); // sub-request with another HTTP method - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://localhost/', 'get'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST); @@ -133,17 +136,17 @@ public function testSubRequestWithDifferentMethod() */ public function testLoggingParameter($parameter, $log, $parameters) { - $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); + $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher->expects($this->once()) ->method('matchRequest') ->willReturn($parameter); - $logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); + $logger = $this->createMock(LoggerInterface::class); $logger->expects($this->once()) ->method('info') ->with($this->equalTo($log), $this->equalTo($parameters)); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://localhost/'); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext(), $logger); @@ -162,7 +165,7 @@ public function testWithBadRequest() { $requestStack = new RequestStack(); - $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); + $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher->expects($this->never())->method('matchRequest'); $dispatcher = new EventDispatcher(); @@ -184,7 +187,7 @@ public function testNoRoutingConfigurationResponse() { $requestStack = new RequestStack(); - $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); + $requestMatcher = $this->createMock(RequestMatcherInterface::class); $requestMatcher ->expects($this->once()) ->method('matchRequest') @@ -204,12 +207,12 @@ public function testNoRoutingConfigurationResponse() public function testRequestWithBadHost() { - $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $this->expectException(BadRequestHttpException::class); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('http://bad host %22/'); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); - $requestMatcher = $this->getMockBuilder(\Symfony\Component\Routing\Matcher\RequestMatcherInterface::class)->getMock(); + $requestMatcher = $this->createMock(RequestMatcherInterface::class); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener->onKernelRequest($event); diff --git a/Tests/EventListener/SaveSessionListenerTest.php b/Tests/EventListener/SaveSessionListenerTest.php index 6cdd7476c9..f79b73c5fe 100644 --- a/Tests/EventListener/SaveSessionListenerTest.php +++ b/Tests/EventListener/SaveSessionListenerTest.php @@ -27,7 +27,7 @@ class SaveSessionListenerTest extends TestCase public function testOnlyTriggeredOnMasterRequest() { $listener = new SaveSessionListener(); - $event = $this->getMockBuilder(ResponseEvent::class)->disableOriginalConstructor()->getMock(); + $event = $this->createMock(ResponseEvent::class); $event->expects($this->once())->method('isMasterRequest')->willReturn(false); $event->expects($this->never())->method('getRequest'); @@ -38,9 +38,9 @@ public function testOnlyTriggeredOnMasterRequest() public function testSessionSaved() { $listener = new SaveSessionListener(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); - $session = $this->getMockBuilder(SessionInterface::class)->disableOriginalConstructor()->getMock(); + $session = $this->createMock(SessionInterface::class); $session->expects($this->once())->method('isStarted')->willReturn(true); $session->expects($this->once())->method('save'); diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 8131ff2ea1..de1069606b 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -32,7 +32,7 @@ class SessionListenerTest extends TestCase public function testOnlyTriggeredOnMasterRequest() { $listener = $this->getMockForAbstractClass(AbstractSessionListener::class); - $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock(); + $event = $this->createMock(RequestEvent::class); $event->expects($this->once())->method('isMasterRequest')->willReturn(false); $event->expects($this->never())->method('getRequest'); @@ -42,12 +42,12 @@ public function testOnlyTriggeredOnMasterRequest() public function testSessionIsSet() { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session = $this->createMock(Session::class); - $requestStack = $this->getMockBuilder(RequestStack::class)->getMock(); + $requestStack = $this->createMock(RequestStack::class); $requestStack->expects($this->once())->method('getMasterRequest')->willReturn(null); - $sessionStorage = $this->getMockBuilder(NativeSessionStorage::class)->getMock(); + $sessionStorage = $this->createMock(NativeSessionStorage::class); $sessionStorage->expects($this->never())->method('setOptions')->with(['cookie_secure' => true]); $container = new Container(); @@ -58,7 +58,7 @@ public function testSessionIsSet() $request = new Request(); $listener = new SessionListener($container); - $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock(); + $event = $this->createMock(RequestEvent::class); $event->expects($this->once())->method('isMasterRequest')->willReturn(true); $event->expects($this->once())->method('getRequest')->willReturn($request); @@ -70,14 +70,14 @@ public function testSessionIsSet() public function testResponseIsPrivateIfSessionStarted() { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session = $this->createMock(Session::class); $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1)); $container = new Container(); $container->set('initialized_session', $session); $listener = new SessionListener($container); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = new Request(); $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); @@ -95,14 +95,14 @@ public function testResponseIsPrivateIfSessionStarted() public function testResponseIsStillPublicIfSessionStartedAndHeaderPresent() { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session = $this->createMock(Session::class); $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1)); $container = new Container(); $container->set('initialized_session', $session); $listener = new SessionListener($container); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = new Request(); $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); @@ -122,7 +122,7 @@ public function testResponseIsStillPublicIfSessionStartedAndHeaderPresent() public function testUninitializedSession() { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $response = new Response(); $response->setSharedMaxAge(60); $response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 'true'); @@ -143,7 +143,7 @@ public function testUninitializedSession() public function testSurrogateMasterRequestIsPublic() { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session = $this->createMock(Session::class); $session->expects($this->exactly(4))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1, 1, 1)); $container = new Container(); @@ -151,7 +151,7 @@ public function testSurrogateMasterRequestIsPublic() $container->set('session', $session); $listener = new SessionListener($container); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = new Request(); $response = new Response(); @@ -182,9 +182,9 @@ public function testSurrogateMasterRequestIsPublic() public function testGetSessionIsCalledOnce() { - $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); - $sessionStorage = $this->getMockBuilder(NativeSessionStorage::class)->getMock(); - $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); + $session = $this->createMock(Session::class); + $sessionStorage = $this->createMock(NativeSessionStorage::class); + $kernel = $this->createMock(KernelInterface::class); $sessionStorage->expects($this->once()) ->method('setOptions') diff --git a/Tests/EventListener/SurrogateListenerTest.php b/Tests/EventListener/SurrogateListenerTest.php index e4b8b2d558..fc7e4d83ac 100644 --- a/Tests/EventListener/SurrogateListenerTest.php +++ b/Tests/EventListener/SurrogateListenerTest.php @@ -26,7 +26,7 @@ class SurrogateListenerTest extends TestCase public function testFilterDoesNothingForSubRequests() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -40,7 +40,7 @@ public function testFilterDoesNothingForSubRequests() public function testFilterWhenThereIsSomeEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); @@ -54,7 +54,7 @@ public function testFilterWhenThereIsSomeEsiIncludes() public function testFilterWhenThereIsNoEsiIncludes() { $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $response = new Response('foo'); $listener = new SurrogateListener(new Esi()); diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index e0a5cc69da..2ec6581694 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -14,9 +14,11 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; +use Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener; use Symfony\Component\HttpKernel\EventListener\SessionListener; use Symfony\Component\HttpKernel\EventListener\TestSessionListener; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -42,7 +44,7 @@ class TestSessionListenerTest extends TestCase protected function setUp(): void { - $this->listener = $this->getMockForAbstractClass(\Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener::class); + $this->listener = $this->getMockForAbstractClass(AbstractTestSessionListener::class); $this->session = $this->getSession(); $this->listener->expects($this->any()) ->method('getSession') @@ -95,7 +97,7 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie() $this->sessionIsEmpty(); $this->fixSessionId('456'); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -114,7 +116,7 @@ public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie( $this->sessionIsEmpty(); $this->fixSessionId('456'); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -145,7 +147,7 @@ public function testUnstartedSessionIsNotSave() public function testDoesNotThrowIfRequestDoesNotHaveASession() { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, new Response()); $this->listener->onKernelResponse($event); @@ -157,7 +159,7 @@ private function filterResponse(Request $request, $type = HttpKernelInterface::M { $request->setSession($this->session); $response = $response ?: new Response(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $event = new ResponseEvent($kernel, $request, $type, $response); $this->listener->onKernelResponse($event); @@ -209,11 +211,7 @@ private function fixSessionId($sessionId) private function getSession() { - $mock = $this->getMockBuilder(\Symfony\Component\HttpFoundation\Session\Session::class) - ->disableOriginalConstructor() - ->getMock(); - - // set return value for getName() + $mock = $this->createMock(Session::class); $mock->expects($this->any())->method('getName')->willReturn('MOCKSESSID'); return $mock; diff --git a/Tests/EventListener/TranslatorListenerTest.php b/Tests/EventListener/TranslatorListenerTest.php index 1fe4d1f2fa..26097696dd 100644 --- a/Tests/EventListener/TranslatorListenerTest.php +++ b/Tests/EventListener/TranslatorListenerTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\TranslatorListener; @@ -30,8 +31,8 @@ class TranslatorListenerTest extends TestCase protected function setUp(): void { - $this->translator = $this->getMockBuilder(LocaleAwareInterface::class)->getMock(); - $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class)->getMock(); + $this->translator = $this->createMock(LocaleAwareInterface::class); + $this->requestStack = $this->createMock(RequestStack::class); $this->listener = new TranslatorListener($this->translator, $this->requestStack); } @@ -105,7 +106,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() private function createHttpKernel() { - return $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + return $this->createMock(HttpKernelInterface::class); } private function createRequest($locale) diff --git a/Tests/EventListener/ValidateRequestListenerTest.php b/Tests/EventListener/ValidateRequestListenerTest.php index 96b686d91b..d23832d80a 100644 --- a/Tests/EventListener/ValidateRequestListenerTest.php +++ b/Tests/EventListener/ValidateRequestListenerTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; @@ -28,9 +29,9 @@ protected function tearDown(): void public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() { - $this->expectException(\Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException::class); + $this->expectException(ConflictingHeadersException::class); $dispatcher = new EventDispatcher(); - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $request = new Request(); $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); diff --git a/Tests/Fragment/EsiFragmentRendererTest.php b/Tests/Fragment/EsiFragmentRendererTest.php index c9af77149c..3817f4897e 100644 --- a/Tests/Fragment/EsiFragmentRendererTest.php +++ b/Tests/Fragment/EsiFragmentRendererTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; +use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\UriSigner; @@ -91,7 +92,7 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException() private function getInlineStrategy($called = false) { - $inline = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::class)->disableOriginalConstructor()->getMock(); + $inline = $this->createMock(InlineFragmentRenderer::class); if ($called) { $inline->expects($this->once())->method('render'); diff --git a/Tests/Fragment/FragmentHandlerTest.php b/Tests/Fragment/FragmentHandlerTest.php index fa011c8f29..7ad4f3e704 100644 --- a/Tests/Fragment/FragmentHandlerTest.php +++ b/Tests/Fragment/FragmentHandlerTest.php @@ -13,8 +13,10 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; +use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface; /** * @group time-sensitive @@ -25,10 +27,7 @@ class FragmentHandlerTest extends TestCase protected function setUp(): void { - $this->requestStack = $this->getMockBuilder(\Symfony\Component\HttpFoundation\RequestStack::class) - ->disableOriginalConstructor() - ->getMock() - ; + $this->requestStack = $this->createMock(RequestStack::class); $this->requestStack ->expects($this->any()) ->method('getCurrentRequest') @@ -69,7 +68,7 @@ public function testRender() protected function getHandler($returnValue, $arguments = []) { - $renderer = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface::class)->getMock(); + $renderer = $this->createMock(FragmentRendererInterface::class); $renderer ->expects($this->any()) ->method('getName') diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index ae1cb15516..665c1d458a 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; use Symfony\Component\HttpKernel\UriSigner; +use Symfony\Component\Templating\EngineInterface; use Twig\Environment; use Twig\Loader\ArrayLoader; @@ -86,7 +87,7 @@ public function testRenderWithTwigAndDefaultText() */ public function testRenderWithDefaultTextLegacy() { - $engine = $this->getMockBuilder(\Symfony\Component\Templating\EngineInterface::class)->getMock(); + $engine = $this->createMock(EngineInterface::class); $engine->expects($this->once()) ->method('exists') ->with('default') diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index c25297dbe4..c70a1ae6f0 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -16,10 +16,13 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; use Symfony\Component\HttpKernel\Controller\ControllerReference; +use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -72,7 +75,7 @@ public function testRenderWithTrustedHeaderDisabled() public function testRenderExceptionNoIgnoreErrors() { $this->expectException(\RuntimeException::class); - $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); + $dispatcher = $this->createMock(EventDispatcherInterface::class); $dispatcher->expects($this->never())->method('dispatch'); $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); @@ -86,7 +89,7 @@ public function testRenderExceptionIgnoreErrors() $kernel = $this->getKernel($this->throwException($exception)); $request = Request::create('/'); $expectedEvent = new ExceptionEvent($kernel, $request, $kernel::SUB_REQUEST, $exception); - $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); + $dispatcher = $this->createMock(EventDispatcherInterface::class); $dispatcher->expects($this->once())->method('dispatch')->with($expectedEvent, KernelEvents::EXCEPTION); $strategy = new InlineFragmentRenderer($kernel, $dispatcher); @@ -106,7 +109,7 @@ public function testRenderExceptionIgnoreErrorsWithAlt() private function getKernel($returnValue) { - $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel ->expects($this->any()) ->method('handle') @@ -118,7 +121,7 @@ private function getKernel($returnValue) public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() { - $controllerResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ControllerResolverInterface::class)->getMock(); + $controllerResolver = $this->createMock(ControllerResolverInterface::class); $controllerResolver ->expects($this->once()) ->method('getController') @@ -129,7 +132,7 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() }) ; - $argumentResolver = $this->getMockBuilder(\Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface::class)->getMock(); + $argumentResolver = $this->createMock(ArgumentResolverInterface::class); $argumentResolver ->expects($this->once()) ->method('getArguments') @@ -258,7 +261,7 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() */ private function getKernelExpectingRequest(Request $request, $strict = false) { - $kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernelInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); $kernel ->expects($this->once()) ->method('handle') diff --git a/Tests/Fragment/RoutableFragmentRendererTest.php b/Tests/Fragment/RoutableFragmentRendererTest.php index 5980284afe..d17643c186 100644 --- a/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/Tests/Fragment/RoutableFragmentRendererTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; +use Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer; class RoutableFragmentRendererTest extends TestCase { @@ -74,7 +75,7 @@ public function getGenerateFragmentUriDataWithNonScalar() private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) { - $renderer = $this->getMockForAbstractClass(\Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer::class); + $renderer = $this->getMockForAbstractClass(RoutableFragmentRenderer::class); $r = new \ReflectionObject($renderer); $m = $r->getMethod('generateFragmentUri'); $m->setAccessible(true); diff --git a/Tests/Fragment/SsiFragmentRendererTest.php b/Tests/Fragment/SsiFragmentRendererTest.php index db203f91de..63a92028f4 100644 --- a/Tests/Fragment/SsiFragmentRendererTest.php +++ b/Tests/Fragment/SsiFragmentRendererTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; +use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; use Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Ssi; use Symfony\Component\HttpKernel\UriSigner; @@ -82,7 +83,7 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException() private function getInlineStrategy($called = false) { - $inline = $this->getMockBuilder(\Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::class)->disableOriginalConstructor()->getMock(); + $inline = $this->createMock(InlineFragmentRenderer::class); if ($called) { $inline->expects($this->once())->method('render'); diff --git a/Tests/HttpCache/EsiTest.php b/Tests/HttpCache/EsiTest.php index 5246721a64..e708c2ae5f 100644 --- a/Tests/HttpCache/EsiTest.php +++ b/Tests/HttpCache/EsiTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpCache\Esi; +use Symfony\Component\HttpKernel\HttpCache\HttpCache; class EsiTest extends TestCase { @@ -222,7 +223,7 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() protected function getCache($request, $response) { - $cache = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->willReturn($request) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 932f46c6ef..d9dd572bf1 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -16,7 +16,9 @@ use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpKernel\HttpCache\Store; +use Symfony\Component\HttpKernel\HttpCache\StoreInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Kernel; /** * @group time-sensitive @@ -25,7 +27,7 @@ class HttpCacheTest extends HttpCacheTestCase { public function testTerminateDelegatesTerminationOnlyForTerminableInterface() { - $storeMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\StoreInterface::class) + $storeMock = $this->getMockBuilder(StoreInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -37,7 +39,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $this->assertFalse($kernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); // implements TerminableInterface - $kernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\Kernel::class) + $kernelMock = $this->getMockBuilder(Kernel::class) ->disableOriginalConstructor() ->setMethods(['terminate', 'registerBundles', 'registerContainerConfiguration']) ->getMock(); @@ -1488,8 +1490,8 @@ public function testDoesNotCacheOptionsRequest() public function testUsesOriginalRequestForSurrogate() { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); - $store = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\StoreInterface::class)->getMock(); + $kernel = $this->createMock(HttpKernelInterface::class); + $store = $this->createMock(StoreInterface::class); $kernel ->expects($this->exactly(2)) diff --git a/Tests/HttpCache/SsiTest.php b/Tests/HttpCache/SsiTest.php index 23c7410a28..157c4d7455 100644 --- a/Tests/HttpCache/SsiTest.php +++ b/Tests/HttpCache/SsiTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpKernel\HttpCache\Ssi; class SsiTest extends TestCase @@ -189,7 +190,7 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() protected function getCache($request, $response) { - $cache = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpCache\HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(HttpCache::class)->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->willReturn($request) diff --git a/Tests/HttpClientKernelTest.php b/Tests/HttpClientKernelTest.php index 2b904bf9a2..27b3a82e03 100644 --- a/Tests/HttpClientKernelTest.php +++ b/Tests/HttpClientKernelTest.php @@ -24,10 +24,10 @@ public function testHandlePassesMaxRedirectsHttpClientOption() $request = new Request(); $request->attributes->set('http_client_options', ['max_redirects' => 50]); - $response = $this->getMockBuilder(ResponseInterface::class)->getMock(); + $response = $this->createMock(ResponseInterface::class); $response->expects($this->once())->method('getStatusCode')->willReturn(200); - $client = $this->getMockBuilder(HttpClientInterface::class)->getMock(); + $client = $this->createMock(HttpClientInterface::class); $client ->expects($this->once()) ->method('request') diff --git a/Tests/HttpKernelBrowserTest.php b/Tests/HttpKernelBrowserTest.php index eab6c5221c..7cd4d52d39 100644 --- a/Tests/HttpKernelBrowserTest.php +++ b/Tests/HttpKernelBrowserTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\HttpKernelBrowser; @@ -31,7 +32,7 @@ public function testDoRequest() $client->request('GET', '/'); $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); $this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class, $client->getInternalRequest()); - $this->assertInstanceOf(\Symfony\Component\HttpFoundation\Request::class, $client->getRequest()); + $this->assertInstanceOf(Request::class, $client->getRequest()); $this->assertInstanceOf(\Symfony\Component\BrowserKit\Response::class, $client->getInternalResponse()); $this->assertInstanceOf(Response::class, $client->getResponse()); diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 5c954261b6..014dc752c3 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -21,8 +21,10 @@ use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -156,7 +158,7 @@ public function testHandleWhenAListenerReturnsAResponse() public function testHandleWhenNoControllerIsFound() { - $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); + $this->expectException(NotFoundHttpException::class); $dispatcher = new EventDispatcher(); $kernel = $this->getHttpKernel($dispatcher, false); @@ -315,7 +317,7 @@ public function testVerifyRequestStackPushPopDuringHandle() public function testInconsistentClientIpsOnMasterRequests() { - $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); + $this->expectException(BadRequestHttpException::class); $request = new Request(); $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); $request->server->set('REMOTE_ADDR', '1.1.1.1'); @@ -339,13 +341,13 @@ private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $contr $controller = function () { return new Response('Hello'); }; } - $controllerResolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock(); + $controllerResolver = $this->createMock(ControllerResolverInterface::class); $controllerResolver ->expects($this->any()) ->method('getController') ->willReturn($controller); - $argumentResolver = $this->getMockBuilder(ArgumentResolverInterface::class)->getMock(); + $argumentResolver = $this->createMock(ArgumentResolverInterface::class); $argumentResolver ->expects($this->any()) ->method('getArguments') diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 570e6f0298..9e48e4274e 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -19,9 +19,11 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; +use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; @@ -125,7 +127,7 @@ public function testBootInitializesBundlesAndContainer() public function testBootSetsTheContainerToTheBundles() { - $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); + $bundle = $this->createMock(Bundle::class); $bundle->expects($this->once()) ->method('setContainer'); @@ -167,7 +169,7 @@ public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() public function testShutdownCallsShutdownOnAllBundles() { - $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); + $bundle = $this->createMock(Bundle::class); $bundle->expects($this->once()) ->method('shutdown'); @@ -179,7 +181,7 @@ public function testShutdownCallsShutdownOnAllBundles() public function testShutdownGivesNullContainerToAllBundles() { - $bundle = $this->getMockBuilder(\Symfony\Component\HttpKernel\Bundle\Bundle::class)->getMock(); + $bundle = $this->createMock(Bundle::class); $bundle->expects($this->exactly(2)) ->method('setContainer') ->withConsecutive( @@ -202,7 +204,7 @@ public function testHandleCallsHandleOnHttpKernel() $catch = true; $request = new Request(); - $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) + $httpKernelMock = $this->getMockBuilder(HttpKernel::class) ->disableOriginalConstructor() ->getMock(); $httpKernelMock @@ -224,7 +226,7 @@ public function testHandleBootsTheKernel() $catch = true; $request = new Request(); - $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) + $httpKernelMock = $this->getMockBuilder(HttpKernel::class) ->disableOriginalConstructor() ->getMock(); @@ -547,7 +549,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $this->assertFalse($httpKernel->terminateCalled, 'terminate() is never called if the kernel class does not implement TerminableInterface'); // implements TerminableInterface - $httpKernelMock = $this->getMockBuilder(\Symfony\Component\HttpKernel\HttpKernel::class) + $httpKernelMock = $this->getMockBuilder(HttpKernel::class) ->disableOriginalConstructor() ->setMethods(['terminate']) ->getMock(); From 07ea794a327d7c8c5d76e3058fde9fec6a711cb4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 14:50:53 +0100 Subject: [PATCH 133/266] Update VERSION for 4.4.19 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c9317c81ca..19fead0808 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.19-DEV'; + public const VERSION = '4.4.19'; public const VERSION_ID = 40419; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 19; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 55ad860f5f8467cb4a2e0bc08f58e9959134b023 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2021 14:59:11 +0100 Subject: [PATCH 134/266] Bump Symfony version to 4.4.20 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 19fead0808..f2b1966ea5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.19'; - public const VERSION_ID = 40419; + public const VERSION = '4.4.20-DEV'; + public const VERSION_ID = 40420; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 19; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 20; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 48df45950657aaaf94ad4b7db1bd4574eccc47a3 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 27 Jan 2021 14:04:45 +0100 Subject: [PATCH 135/266] Use createMock() instead of a getter --- Tests/CacheClearer/ChainCacheClearerTest.php | 7 +------ .../AddRequestFormatsListenerTest.php | 11 ++--------- Tests/EventListener/LocaleAwareListenerTest.php | 15 +++++---------- Tests/EventListener/TranslatorListenerTest.php | 15 +++++---------- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/Tests/CacheClearer/ChainCacheClearerTest.php b/Tests/CacheClearer/ChainCacheClearerTest.php index 80c1b576be..80d9796070 100644 --- a/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/Tests/CacheClearer/ChainCacheClearerTest.php @@ -31,7 +31,7 @@ public static function tearDownAfterClass(): void public function testInjectClearersInConstructor() { - $clearer = $this->getMockClearer(); + $clearer = $this->createMock(CacheClearerInterface::class); $clearer ->expects($this->once()) ->method('clear'); @@ -39,9 +39,4 @@ public function testInjectClearersInConstructor() $chainClearer = new ChainCacheClearer([$clearer]); $chainClearer->clear(self::$cacheDir); } - - protected function getMockClearer() - { - return $this->createMock(CacheClearerInterface::class); - } } diff --git a/Tests/EventListener/AddRequestFormatsListenerTest.php b/Tests/EventListener/AddRequestFormatsListenerTest.php index def3831851..fab9a8a38f 100644 --- a/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -19,8 +19,6 @@ use Symfony\Component\HttpKernel\KernelEvents; /** - * Test AddRequestFormatsListener class. - * * @author Gildas Quemener */ class AddRequestFormatsListenerTest extends TestCase @@ -47,7 +45,7 @@ public function testIsAnEventSubscriber() public function testRegisteredEvent() { - $this->assertEquals( + $this->assertSame( [KernelEvents::REQUEST => ['onKernelRequest', 100]], AddRequestFormatsListener::getSubscribedEvents() ); @@ -55,7 +53,7 @@ public function testRegisteredEvent() public function testSetAdditionalFormats() { - $request = $this->getRequestMock(); + $request = $this->createMock(Request::class); $event = $this->getRequestEventMock($request); $request->expects($this->once()) @@ -65,11 +63,6 @@ public function testSetAdditionalFormats() $this->listener->onKernelRequest($event); } - protected function getRequestMock() - { - return $this->createMock(Request::class); - } - protected function getRequestEventMock(Request $request) { $event = $this->createMock(RequestEvent::class); diff --git a/Tests/EventListener/LocaleAwareListenerTest.php b/Tests/EventListener/LocaleAwareListenerTest.php index 20c9f9d8c9..ab92a79168 100644 --- a/Tests/EventListener/LocaleAwareListenerTest.php +++ b/Tests/EventListener/LocaleAwareListenerTest.php @@ -40,7 +40,7 @@ public function testLocaleIsSetInOnKernelRequest() ->method('setLocale') ->with($this->equalTo('fr')); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -57,7 +57,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() $this->throwException(new \InvalidArgumentException()) ); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -71,7 +71,7 @@ public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists() $this->requestStack->push($this->createRequest('fr')); $this->requestStack->push($subRequest = $this->createRequest('de')); - $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -84,7 +84,7 @@ public function testLocaleIsSetToDefaultOnKernelFinishRequestWhenParentRequestDo $this->requestStack->push($subRequest = $this->createRequest('de')); - $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -104,15 +104,10 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() $this->requestStack->push($this->createRequest('fr')); $this->requestStack->push($subRequest = $this->createRequest('de')); - $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $subRequest, HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } - private function createHttpKernel() - { - return $this->createMock(HttpKernelInterface::class); - } - private function createRequest($locale) { $request = new Request(); diff --git a/Tests/EventListener/TranslatorListenerTest.php b/Tests/EventListener/TranslatorListenerTest.php index 26097696dd..1eb86b7fb9 100644 --- a/Tests/EventListener/TranslatorListenerTest.php +++ b/Tests/EventListener/TranslatorListenerTest.php @@ -43,7 +43,7 @@ public function testLocaleIsSetInOnKernelRequest() ->method('setLocale') ->with($this->equalTo('fr')); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -60,7 +60,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() $this->throwException(new \InvalidArgumentException()) ); - $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); } @@ -72,7 +72,7 @@ public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists() ->with($this->equalTo('fr')); $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -82,7 +82,7 @@ public function testLocaleIsNotSetInOnKernelFinishRequestWhenParentRequestDoesNo ->expects($this->never()) ->method('setLocale'); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } @@ -100,15 +100,10 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() ); $this->setMasterRequest($this->createRequest('fr')); - $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); + $event = new FinishRequestEvent($this->createMock(HttpKernelInterface::class), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); $this->listener->onKernelFinishRequest($event); } - private function createHttpKernel() - { - return $this->createMock(HttpKernelInterface::class); - } - private function createRequest($locale) { $request = new Request(); From 1c4e23bda397f4d69fc676500bc570517d0256b9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 4 Feb 2021 18:25:29 +0100 Subject: [PATCH 136/266] Allow psr/cache v2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0094dc575f..61325cb0a0 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "symfony/templating": "^3.4|^4.0|^5.0", "symfony/translation": "^4.2|^5.0", "symfony/translation-contracts": "^1.1|^2", - "psr/cache": "~1.0", + "psr/cache": "^1.0|^2.0", "twig/twig": "^1.43|^2.13|^3.0.4" }, "provide": { From cde9ee85487932a1c8064ae685e5d0488c3ae12b Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 5 Feb 2021 14:33:05 +0100 Subject: [PATCH 137/266] [HttpKernel] [Kernel] Silence deprecations logs writes --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f2b1966ea5..15a37cf58b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -598,8 +598,8 @@ protected function initializeContainer() if ($collectDeprecations) { restore_error_handler(); - file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs))); - file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : ''); + @file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs))); + @file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : ''); } } From ed97eefaf3d3788be639e083c5e2a1713cb02106 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 5 Feb 2021 16:46:45 +0100 Subject: [PATCH 138/266] Allow psr/cache v3 but on symfony/cache --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 61325cb0a0..a2fa2a0eca 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "symfony/templating": "^3.4|^4.0|^5.0", "symfony/translation": "^4.2|^5.0", "symfony/translation-contracts": "^1.1|^2", - "psr/cache": "^1.0|^2.0", + "psr/cache": "^1.0|^2.0|^3.0", "twig/twig": "^1.43|^2.13|^3.0.4" }, "provide": { From c00454822f17aab61237231a953149f6ae3213c5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 10 Feb 2021 18:16:49 +0100 Subject: [PATCH 139/266] [HttpKernel] fix transient test --- Tests/KernelTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 9e48e4274e..63fb4973f6 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -35,8 +36,10 @@ class KernelTest extends TestCase { protected function tearDown(): void { - $fs = new Filesystem(); - $fs->remove(__DIR__.'/Fixtures/var'); + try { + (new Filesystem())->remove(__DIR__.'/Fixtures/var'); + } catch (IOException $e) { + } } public function testConstructor() @@ -586,7 +589,7 @@ public function testProjectDirExtension() public function testKernelReset() { - (new Filesystem())->remove(__DIR__.'/Fixtures/var/cache'); + $this->tearDown(); $kernel = new CustomProjectDirKernel(); $kernel->boot(); From a3050e057bf581a50f5af755b5cb841ff1feb9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sun, 14 Feb 2021 12:49:34 +0100 Subject: [PATCH 140/266] Fix: Article --- Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index 15a37cf58b..b335a4f207 100644 --- a/Kernel.php +++ b/Kernel.php @@ -205,7 +205,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ } /** - * Gets a HTTP kernel from the container. + * Gets an HTTP kernel from the container. * * @return HttpKernelInterface */ From 64dd49d38f60015e84f97c636f77bc80960718e9 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 21 Feb 2021 20:10:16 +0100 Subject: [PATCH 141/266] Switched to non-null defaults in exception constructors --- Exception/AccessDeniedHttpException.php | 8 ++++---- Exception/BadRequestHttpException.php | 8 ++++---- Exception/ConflictHttpException.php | 8 ++++---- Exception/GoneHttpException.php | 8 ++++---- Exception/HttpException.php | 2 +- Exception/LengthRequiredHttpException.php | 8 ++++---- Exception/MethodNotAllowedHttpException.php | 10 +++++----- Exception/NotAcceptableHttpException.php | 8 ++++---- Exception/NotFoundHttpException.php | 8 ++++---- Exception/PreconditionFailedHttpException.php | 8 ++++---- Exception/PreconditionRequiredHttpException.php | 8 ++++---- Exception/ServiceUnavailableHttpException.php | 10 +++++----- Exception/TooManyRequestsHttpException.php | 10 +++++----- Exception/UnauthorizedHttpException.php | 10 +++++----- Exception/UnprocessableEntityHttpException.php | 8 ++++---- Exception/UnsupportedMediaTypeHttpException.php | 8 ++++---- Tests/Exception/AccessDeniedHttpExceptionTest.php | 3 ++- Tests/Exception/BadRequestHttpExceptionTest.php | 3 ++- Tests/Exception/ConflictHttpExceptionTest.php | 3 ++- Tests/Exception/GoneHttpExceptionTest.php | 3 ++- Tests/Exception/HttpExceptionTest.php | 6 +++--- Tests/Exception/LengthRequiredHttpExceptionTest.php | 3 ++- Tests/Exception/MethodNotAllowedHttpExceptionTest.php | 5 +++-- Tests/Exception/NotAcceptableHttpExceptionTest.php | 3 ++- Tests/Exception/NotFoundHttpExceptionTest.php | 3 ++- .../Exception/PreconditionFailedHttpExceptionTest.php | 3 ++- .../PreconditionRequiredHttpExceptionTest.php | 3 ++- .../Exception/ServiceUnavailableHttpExceptionTest.php | 5 +++-- Tests/Exception/TooManyRequestsHttpExceptionTest.php | 5 +++-- Tests/Exception/UnauthorizedHttpExceptionTest.php | 5 +++-- .../Exception/UnprocessableEntityHttpExceptionTest.php | 3 ++- .../UnsupportedMediaTypeHttpExceptionTest.php | 3 ++- 32 files changed, 102 insertions(+), 87 deletions(-) diff --git a/Exception/AccessDeniedHttpException.php b/Exception/AccessDeniedHttpException.php index 65e5f8c786..f0c81111db 100644 --- a/Exception/AccessDeniedHttpException.php +++ b/Exception/AccessDeniedHttpException.php @@ -18,11 +18,11 @@ class AccessDeniedHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(403, $message, $previous, $headers, $code); } diff --git a/Exception/BadRequestHttpException.php b/Exception/BadRequestHttpException.php index 7de91054b4..8eccce1e16 100644 --- a/Exception/BadRequestHttpException.php +++ b/Exception/BadRequestHttpException.php @@ -17,11 +17,11 @@ class BadRequestHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(400, $message, $previous, $headers, $code); } diff --git a/Exception/ConflictHttpException.php b/Exception/ConflictHttpException.php index ebb86ba6e9..72b8aa1274 100644 --- a/Exception/ConflictHttpException.php +++ b/Exception/ConflictHttpException.php @@ -17,11 +17,11 @@ class ConflictHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(409, $message, $previous, $headers, $code); } diff --git a/Exception/GoneHttpException.php b/Exception/GoneHttpException.php index aea283a961..6bba8159a2 100644 --- a/Exception/GoneHttpException.php +++ b/Exception/GoneHttpException.php @@ -17,11 +17,11 @@ class GoneHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(410, $message, $previous, $headers, $code); } diff --git a/Exception/HttpException.php b/Exception/HttpException.php index d822cd5d49..f3c0c3362f 100644 --- a/Exception/HttpException.php +++ b/Exception/HttpException.php @@ -21,7 +21,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface private $statusCode; private $headers; - public function __construct(int $statusCode, string $message = null, \Throwable $previous = null, array $headers = [], ?int $code = 0) + public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0) { $this->statusCode = $statusCode; $this->headers = $headers; diff --git a/Exception/LengthRequiredHttpException.php b/Exception/LengthRequiredHttpException.php index 44fb770b60..92f9c74daf 100644 --- a/Exception/LengthRequiredHttpException.php +++ b/Exception/LengthRequiredHttpException.php @@ -17,11 +17,11 @@ class LengthRequiredHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(411, $message, $previous, $headers, $code); } diff --git a/Exception/MethodNotAllowedHttpException.php b/Exception/MethodNotAllowedHttpException.php index c15e46ffc3..665ae355b4 100644 --- a/Exception/MethodNotAllowedHttpException.php +++ b/Exception/MethodNotAllowedHttpException.php @@ -17,12 +17,12 @@ class MethodNotAllowedHttpException extends HttpException { /** - * @param array $allow An array of allowed methods - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string[] $allow An array of allowed methods + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct(array $allow, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct(array $allow, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { $headers['Allow'] = strtoupper(implode(', ', $allow)); diff --git a/Exception/NotAcceptableHttpException.php b/Exception/NotAcceptableHttpException.php index c5f5324b1a..a985e86b9b 100644 --- a/Exception/NotAcceptableHttpException.php +++ b/Exception/NotAcceptableHttpException.php @@ -17,11 +17,11 @@ class NotAcceptableHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(406, $message, $previous, $headers, $code); } diff --git a/Exception/NotFoundHttpException.php b/Exception/NotFoundHttpException.php index 146b908a1e..3be305ee9e 100644 --- a/Exception/NotFoundHttpException.php +++ b/Exception/NotFoundHttpException.php @@ -17,11 +17,11 @@ class NotFoundHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(404, $message, $previous, $headers, $code); } diff --git a/Exception/PreconditionFailedHttpException.php b/Exception/PreconditionFailedHttpException.php index e878b10ad3..bdedea143d 100644 --- a/Exception/PreconditionFailedHttpException.php +++ b/Exception/PreconditionFailedHttpException.php @@ -17,11 +17,11 @@ class PreconditionFailedHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(412, $message, $previous, $headers, $code); } diff --git a/Exception/PreconditionRequiredHttpException.php b/Exception/PreconditionRequiredHttpException.php index a6cb2f09a7..bc26804830 100644 --- a/Exception/PreconditionRequiredHttpException.php +++ b/Exception/PreconditionRequiredHttpException.php @@ -19,11 +19,11 @@ class PreconditionRequiredHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(428, $message, $previous, $headers, $code); } diff --git a/Exception/ServiceUnavailableHttpException.php b/Exception/ServiceUnavailableHttpException.php index c786ccf5f7..1fb793dbf0 100644 --- a/Exception/ServiceUnavailableHttpException.php +++ b/Exception/ServiceUnavailableHttpException.php @@ -17,12 +17,12 @@ class ServiceUnavailableHttpException extends HttpException { /** - * @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param int|string|null $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { if ($retryAfter) { $headers['Retry-After'] = $retryAfter; diff --git a/Exception/TooManyRequestsHttpException.php b/Exception/TooManyRequestsHttpException.php index b709f1a2f1..e1e47d048b 100644 --- a/Exception/TooManyRequestsHttpException.php +++ b/Exception/TooManyRequestsHttpException.php @@ -19,12 +19,12 @@ class TooManyRequestsHttpException extends HttpException { /** - * @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param int|string|null $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { if ($retryAfter) { $headers['Retry-After'] = $retryAfter; diff --git a/Exception/UnauthorizedHttpException.php b/Exception/UnauthorizedHttpException.php index fb86c1ea95..ddb48f116f 100644 --- a/Exception/UnauthorizedHttpException.php +++ b/Exception/UnauthorizedHttpException.php @@ -17,12 +17,12 @@ class UnauthorizedHttpException extends HttpException { /** - * @param string $challenge WWW-Authenticate challenge string - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string $challenge WWW-Authenticate challenge string + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct(string $challenge, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct(string $challenge, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { $headers['WWW-Authenticate'] = $challenge; diff --git a/Exception/UnprocessableEntityHttpException.php b/Exception/UnprocessableEntityHttpException.php index 93d4bcef69..237340a574 100644 --- a/Exception/UnprocessableEntityHttpException.php +++ b/Exception/UnprocessableEntityHttpException.php @@ -17,11 +17,11 @@ class UnprocessableEntityHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(422, $message, $previous, $headers, $code); } diff --git a/Exception/UnsupportedMediaTypeHttpException.php b/Exception/UnsupportedMediaTypeHttpException.php index 7cda3a6202..74ddbfccbc 100644 --- a/Exception/UnsupportedMediaTypeHttpException.php +++ b/Exception/UnsupportedMediaTypeHttpException.php @@ -17,11 +17,11 @@ class UnsupportedMediaTypeHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(415, $message, $previous, $headers, $code); } diff --git a/Tests/Exception/AccessDeniedHttpExceptionTest.php b/Tests/Exception/AccessDeniedHttpExceptionTest.php index 3a34cc47bc..6fa356e70d 100644 --- a/Tests/Exception/AccessDeniedHttpExceptionTest.php +++ b/Tests/Exception/AccessDeniedHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class AccessDeniedHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new AccessDeniedHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/BadRequestHttpExceptionTest.php b/Tests/Exception/BadRequestHttpExceptionTest.php index 462fd9cb1d..231b406a9d 100644 --- a/Tests/Exception/BadRequestHttpExceptionTest.php +++ b/Tests/Exception/BadRequestHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class BadRequestHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new BadRequestHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/ConflictHttpExceptionTest.php b/Tests/Exception/ConflictHttpExceptionTest.php index 760600a10f..c923df2ce9 100644 --- a/Tests/Exception/ConflictHttpExceptionTest.php +++ b/Tests/Exception/ConflictHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\ConflictHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class ConflictHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new ConflictHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/GoneHttpExceptionTest.php b/Tests/Exception/GoneHttpExceptionTest.php index 30dafe4922..dd84acac36 100644 --- a/Tests/Exception/GoneHttpExceptionTest.php +++ b/Tests/Exception/GoneHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\GoneHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class GoneHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new GoneHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/HttpExceptionTest.php b/Tests/Exception/HttpExceptionTest.php index a9431f4b5a..827f0fce3c 100644 --- a/Tests/Exception/HttpExceptionTest.php +++ b/Tests/Exception/HttpExceptionTest.php @@ -32,7 +32,7 @@ public function testHeadersDefault() */ public function testHeadersConstructor($headers) { - $exception = new HttpException(200, null, null, $headers); + $exception = new HttpException(200, '', null, $headers); $this->assertSame($headers, $exception->getHeaders()); } @@ -50,11 +50,11 @@ public function testThrowableIsAllowedForPrevious() { $previous = new class('Error of PHP 7+') extends \Error { }; - $exception = $this->createException(null, $previous); + $exception = $this->createException('', $previous); $this->assertSame($previous, $exception->getPrevious()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new HttpException(200, $message, $previous, $headers, $code); } diff --git a/Tests/Exception/LengthRequiredHttpExceptionTest.php b/Tests/Exception/LengthRequiredHttpExceptionTest.php index 8676d67238..dd74c81aaf 100644 --- a/Tests/Exception/LengthRequiredHttpExceptionTest.php +++ b/Tests/Exception/LengthRequiredHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException; class LengthRequiredHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new LengthRequiredHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/Tests/Exception/MethodNotAllowedHttpExceptionTest.php index efb0b50caf..8f657420ea 100644 --- a/Tests/Exception/MethodNotAllowedHttpExceptionTest.php +++ b/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ public function testWithHeaderConstruct() 'Cache-Control' => 'public, s-maxage=1200', ]; - $exception = new MethodNotAllowedHttpException(['get'], null, null, null, $headers); + $exception = new MethodNotAllowedHttpException(['get'], '', null, 0, $headers); $headers['Allow'] = 'GET'; @@ -35,7 +36,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers); } diff --git a/Tests/Exception/NotAcceptableHttpExceptionTest.php b/Tests/Exception/NotAcceptableHttpExceptionTest.php index 021c69e289..6d163faa47 100644 --- a/Tests/Exception/NotAcceptableHttpExceptionTest.php +++ b/Tests/Exception/NotAcceptableHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; class NotAcceptableHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new NotAcceptableHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/NotFoundHttpExceptionTest.php b/Tests/Exception/NotFoundHttpExceptionTest.php index 0bf369b1a0..cce9f697dd 100644 --- a/Tests/Exception/NotFoundHttpExceptionTest.php +++ b/Tests/Exception/NotFoundHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class NotFoundHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new NotFoundHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/PreconditionFailedHttpExceptionTest.php b/Tests/Exception/PreconditionFailedHttpExceptionTest.php index 04d79c499d..b75c560d9b 100644 --- a/Tests/Exception/PreconditionFailedHttpExceptionTest.php +++ b/Tests/Exception/PreconditionFailedHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException; class PreconditionFailedHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new PreconditionFailedHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/PreconditionRequiredHttpExceptionTest.php b/Tests/Exception/PreconditionRequiredHttpExceptionTest.php index 82076617a8..2b9c6777ba 100644 --- a/Tests/Exception/PreconditionRequiredHttpExceptionTest.php +++ b/Tests/Exception/PreconditionRequiredHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\PreconditionRequiredHttpException; class PreconditionRequiredHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new PreconditionRequiredHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/Tests/Exception/ServiceUnavailableHttpExceptionTest.php index fac197c852..771e9492d0 100644 --- a/Tests/Exception/ServiceUnavailableHttpExceptionTest.php +++ b/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ public function testWithHeaderConstruct() 'Cache-Control' => 'public, s-maxage=1337', ]; - $exception = new ServiceUnavailableHttpException(1337, null, null, null, $headers); + $exception = new ServiceUnavailableHttpException(1337, '', null, 0, $headers); $headers['Retry-After'] = 1337; @@ -35,7 +36,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new ServiceUnavailableHttpException(null, $message, $previous, $code, $headers); } diff --git a/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/Tests/Exception/TooManyRequestsHttpExceptionTest.php index 8b59e9894a..7c2490b22e 100644 --- a/Tests/Exception/TooManyRequestsHttpExceptionTest.php +++ b/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; class TooManyRequestsHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ public function testWithHeaderConstruct() 'Cache-Control' => 'public, s-maxage=69', ]; - $exception = new TooManyRequestsHttpException(69, null, null, null, $headers); + $exception = new TooManyRequestsHttpException(69, '', null, 0, $headers); $headers['Retry-After'] = 69; @@ -35,7 +36,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new TooManyRequestsHttpException(null, $message, $previous, $code, $headers); } diff --git a/Tests/Exception/UnauthorizedHttpExceptionTest.php b/Tests/Exception/UnauthorizedHttpExceptionTest.php index 92d427b6e4..bd01079798 100644 --- a/Tests/Exception/UnauthorizedHttpExceptionTest.php +++ b/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class UnauthorizedHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ public function testWithHeaderConstruct() 'Cache-Control' => 'public, s-maxage=1200', ]; - $exception = new UnauthorizedHttpException('Challenge', null, null, null, $headers); + $exception = new UnauthorizedHttpException('Challenge', '', null, 0, $headers); $headers['WWW-Authenticate'] = 'Challenge'; @@ -35,7 +36,7 @@ public function testHeadersSetter($headers) $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnauthorizedHttpException('Challenge', $message, $previous, $code, $headers); } diff --git a/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/Tests/Exception/UnprocessableEntityHttpExceptionTest.php index ffa4e177ee..b538a041dd 100644 --- a/Tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ b/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnprocessableEntityHttpException($message, $previous, $code, $headers); } diff --git a/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php index fa28bbd19b..4eeb3fa144 100644 --- a/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php +++ b/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException; class UnsupportedMediaTypeHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnsupportedMediaTypeHttpException($message, $previous, $code, $headers); } From 6dc93436a658ff608ec22cf3e7b3102b12df7403 Mon Sep 17 00:00:00 2001 From: tamcy Date: Fri, 19 Feb 2021 12:13:03 +0800 Subject: [PATCH 142/266] [HttpKernel] Configure `session.cookie_secure` earlier --- EventListener/SessionListener.php | 16 +++++++++++++--- Tests/EventListener/SessionListenerTest.php | 8 ++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/EventListener/SessionListener.php b/EventListener/SessionListener.php index a53ade797c..6cff47b88d 100644 --- a/EventListener/SessionListener.php +++ b/EventListener/SessionListener.php @@ -14,6 +14,7 @@ use Psr\Container\ContainerInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** * Sets the session in the request. @@ -33,10 +34,12 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - protected function getSession(): ?SessionInterface + public function onKernelRequest(GetResponseEvent $event) { - if (!$this->container->has('session')) { - return null; + parent::onKernelRequest($event); + + if (!$event->isMasterRequest() || !$this->container->has('session')) { + return; } if ($this->container->has('session_storage') @@ -46,6 +49,13 @@ protected function getSession(): ?SessionInterface ) { $storage->setOptions(['cookie_secure' => true]); } + } + + protected function getSession(): ?SessionInterface + { + if (!$this->container->has('session')) { + return null; + } return $this->container->get('session'); } diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index de1069606b..e0dba81683 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -59,7 +59,7 @@ public function testSessionIsSet() $listener = new SessionListener($container); $event = $this->createMock(RequestEvent::class); - $event->expects($this->once())->method('isMasterRequest')->willReturn(true); + $event->expects($this->exactly(2))->method('isMasterRequest')->willReturn(true); $event->expects($this->once())->method('getRequest')->willReturn($request); $listener->onKernelRequest($event); @@ -203,12 +203,16 @@ public function testGetSessionIsCalledOnce() $listener = new SessionListener($container); $listener->onKernelRequest($event); + // storage->setOptions() should have been called already + $container->set('session_storage', null); + $sessionStorage = null; + $subRequest = $masterRequest->duplicate(); // at this point both master and subrequest have a closure to build the session $masterRequest->getSession(); - // calling the factory on the subRequest should not trigger a second call to storage->sesOptions() + // calling the factory on the subRequest should not trigger a second call to storage->setOptions() $subRequest->getSession(); } } From 4f36548465489f293b05406f1770492f6efb8adb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 4 Mar 2021 19:00:27 +0100 Subject: [PATCH 143/266] Update VERSION for 4.4.20 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b335a4f207..18ac83f6a8 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.20-DEV'; + public const VERSION = '4.4.20'; public const VERSION_ID = 40420; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 20; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 03a971b1839bed9df4ede014553396b25289909d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 4 Mar 2021 19:04:32 +0100 Subject: [PATCH 144/266] Bump Symfony version to 4.4.21 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 18ac83f6a8..cd185b1441 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.20'; - public const VERSION_ID = 40420; + public const VERSION = '4.4.21-DEV'; + public const VERSION_ID = 40421; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 20; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 21; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 835cfc20a6264f24582c285e452f43c6c448bec3 Mon Sep 17 00:00:00 2001 From: Bernd Stellwag Date: Fri, 19 Mar 2021 08:57:35 +0100 Subject: [PATCH 145/266] [HttpKernel] do is_file check before include Trying to include a file that doesn't exist issues a warning. Doing an is_file check beforehand should prevent those warnings. --- Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index cd185b1441..b8c93dbd8c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -533,7 +533,7 @@ protected function initializeContainer() if (!flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) { fclose($lock); $lock = null; - } elseif (!\is_object($this->container = include $cachePath)) { + } elseif (!is_file($cachePath) || !\is_object($this->container = include $cachePath)) { $this->container = null; } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { flock($lock, \LOCK_UN); From 021c2199563042e1a510d070131b64b08504e0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Mon, 22 Mar 2021 20:15:23 +0100 Subject: [PATCH 146/266] Hardening Security - Unserialize DumpDataCollector --- DataCollector/DumpDataCollector.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index ae751c4f2e..a3cf2147cb 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -183,6 +183,11 @@ public function __wakeup() $charset = array_pop($this->data); $fileLinkFormat = array_pop($this->data); $this->dataCount = \count($this->data); + foreach ($this->data as $dump) { + if (!\is_string($dump['name']) || !\is_string($dump['file']) || !\is_int($dump['line'])) { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } + } self::__construct($this->stopwatch, \is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \is_string($charset) ? $charset : null); } @@ -257,7 +262,7 @@ public function __destruct() } } - private function doDump(DataDumperInterface $dumper, $data, string $name, string $file, int $line) + private function doDump(DataDumperInterface $dumper, Data $data, string $name, string $file, int $line) { if ($dumper instanceof CliDumper) { $contextDumper = function ($name, $file, $line, $fmt) { From 59ea1e00809b6496ac2419fa8424539d755e62c6 Mon Sep 17 00:00:00 2001 From: Roberto Nygaard Date: Sun, 21 Mar 2021 22:12:55 +0000 Subject: [PATCH 147/266] [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel --- DataCollector/ConfigDataCollector.php | 17 +++++---- .../DataCollector/ConfigDataCollectorTest.php | 35 +++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index d4b298c594..c32c71b747 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -59,12 +59,19 @@ public function setKernel(KernelInterface $kernel = null) */ public function collect(Request $request, Response $response/*, \Throwable $exception = null*/) { + $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE); + $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE); + $this->data = [ 'app_name' => $this->name, 'app_version' => $this->version, 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, - 'symfony_state' => 'unknown', + 'symfony_minor_version' => sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), + 'symfony_lts' => 4 === Kernel::MINOR_VERSION, + 'symfony_state' => $this->determineSymfonyState(), + 'symfony_eom' => $eom->format('F Y'), + 'symfony_eol' => $eol->format('F Y'), 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => \PHP_VERSION, @@ -82,14 +89,6 @@ public function collect(Request $request, Response $response/*, \Throwable $exce foreach ($this->kernel->getBundles() as $name => $bundle) { $this->data['bundles'][$name] = new ClassStub(\get_class($bundle)); } - - $this->data['symfony_state'] = $this->determineSymfonyState(); - $this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION); - $this->data['symfony_lts'] = 4 === Kernel::MINOR_VERSION; - $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE); - $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE); - $this->data['symfony_eom'] = $eom->format('F Y'); - $this->data['symfony_eol'] = $eol->format('F Y'); } if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) { diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index df6af954f3..86bd394f56 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -41,6 +41,13 @@ public function testCollect() $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); + $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); + + $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); + $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->format('F Y'); + $this->assertSame($eom, $c->getSymfonyEom()); + $this->assertSame($eol, $c->getSymfonyEol()); } /** @@ -58,6 +65,34 @@ public function testLegacy() $this->assertSame('name', $c->getApplicationName()); $this->assertNull($c->getApplicationVersion()); } + + public function testCollectWithoutKernel() + { + $c = new ConfigDataCollector(); + $c->collect(new Request(), new Response()); + + $this->assertSame('n/a', $c->getEnv()); + $this->assertSame('n/a', $c->isDebug()); + $this->assertSame('config', $c->getName()); + $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION); + $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', \PHP_VERSION); + $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); + $this->assertSame(class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); + $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); + $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); + $this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts()); + $this->assertNull($c->getToken()); + $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug()); + $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); + $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); + $this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion()); + $this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']); + + $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y'); + $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->format('F Y'); + $this->assertSame($eom, $c->getSymfonyEom()); + $this->assertSame($eol, $c->getSymfonyEol()); + } } class KernelForTest extends Kernel From 0248214120d00c5f44f1cd5d9ad65f0b38459333 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Mar 2021 07:11:04 +0200 Subject: [PATCH 148/266] Update VERSION for 4.4.21 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b8c93dbd8c..f0ec789e82 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.21-DEV'; + public const VERSION = '4.4.21'; public const VERSION_ID = 40421; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 21; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 39c6e76f7ec8955f98630ba8a3177bee198e0b0e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Mar 2021 07:15:29 +0200 Subject: [PATCH 149/266] Bump Symfony version to 4.4.22 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f0ec789e82..447c9936eb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.21'; - public const VERSION_ID = 40421; + public const VERSION = '4.4.22-DEV'; + public const VERSION_ID = 40422; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 21; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 22; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From f70a9aadd38a8f9bf8fbdd907335fefd7490b5d7 Mon Sep 17 00:00:00 2001 From: Roman Martinuk Date: Fri, 2 Apr 2021 16:17:10 +0300 Subject: [PATCH 150/266] remove references to "Silex" --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index abdaf513f9..0136784a72 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ HttpKernel Component The HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatcher component. It's flexible -enough to create a full-stack framework (Symfony), a micro-framework (Silex) or -an advanced CMS system (Drupal). +enough to create full-stack frameworks, micro-frameworks or advanced CMS systems like Drupal. Resources --------- From 31f3944239321b24aec193109c3999493e86257b Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 7 Apr 2021 17:14:41 +0200 Subject: [PATCH 151/266] [CS] Replace easy occurences of ?: with ?? --- Controller/ArgumentResolver.php | 2 +- HttpKernel.php | 2 +- Tests/EventListener/TestSessionListenerTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 3504ae614f..421d10f120 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -36,7 +36,7 @@ final class ArgumentResolver implements ArgumentResolverInterface public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, iterable $argumentValueResolvers = []) { - $this->argumentMetadataFactory = $argumentMetadataFactory ?: new ArgumentMetadataFactory(); + $this->argumentMetadataFactory = $argumentMetadataFactory ?? new ArgumentMetadataFactory(); $this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers(); } diff --git a/HttpKernel.php b/HttpKernel.php index 681e96321d..0ed82d777b 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -61,7 +61,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ControllerReso { $this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher); $this->resolver = $resolver; - $this->requestStack = $requestStack ?: new RequestStack(); + $this->requestStack = $requestStack ?? new RequestStack(); $this->argumentResolver = $argumentResolver; if (null === $this->argumentResolver) { diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index 2ec6581694..70629a8fb8 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -158,7 +158,7 @@ public function testDoesNotThrowIfRequestDoesNotHaveASession() private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, Response $response = null) { $request->setSession($this->session); - $response = $response ?: new Response(); + $response = $response ?? new Response(); $kernel = $this->createMock(HttpKernelInterface::class); $event = new ResponseEvent($kernel, $request, $type, $response); From b99b8ce04a8a43b121fb9b6cf699326509dfe375 Mon Sep 17 00:00:00 2001 From: StefanoCappellini Date: Sat, 10 Apr 2021 16:16:03 +0200 Subject: [PATCH 152/266] Simplified condition and removed unused code from AbstractSessionListener::onKernelRequest --- EventListener/AbstractSessionListener.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 0e99ee55c2..76c2064d18 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -53,14 +53,13 @@ public function onKernelRequest(GetResponseEvent $event) return; } - $session = null; $request = $event->getRequest(); if (!$request->hasSession()) { $sess = null; $request->setSessionFactory(function () use (&$sess) { return $sess ?? $sess = $this->getSession(); }); } - $session = $session ?? ($this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : null); + $session = $this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : null; $this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0; } From aa4d9d23491bb37d4c1164ce516768bbd8740d4f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 12 Apr 2021 09:43:03 +0200 Subject: [PATCH 153/266] [HttpKernel] Minor fixes and tweaks in the Symfony Welcome Page --- Resources/welcome.html.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Resources/welcome.html.php b/Resources/welcome.html.php index b8337dc737..b25f99b3d0 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -19,8 +19,9 @@ .wrapper { text-align: center; width: 100%; } .container { position: relative; background: radial-gradient(ellipse at bottom, 0%, hsl(, 20%, 13%) 100%); background-attachment: fixed; color: ; } .container:after { content: ""; position: absolute; height: 2px; width: 2px; top: -2px; left: 0; background: white; box-shadow: 778px 1019px 0 0 rgba(255, 255, 255, 0.826) , 1075px 1688px 0 0 rgba(255,255,255, 0.275) , 388px 1021px 0 0 rgba(255,255,255, 0.259) , 1238px 626px 0 0 rgba(255,255,255, 0.469) , 997px 904px 0 0 rgba(255,255,255, 0.925) , 921px 1345px 0 0 rgba(255,255,255, 0.698) , 337px 1236px 0 0 rgba(255,255,255, 0.838) , 460px 569px 0 0 rgba(255,255,255, 0.01) , 690px 1488px 0 0 rgba(255,255,255, 0.154) , 859px 926px 0 0 rgba(255,255,255, 0.515) , 1272px 791px 0 0 rgba(255,255,255, 1) , 238px 1256px 0 0 rgba(255,255,255, 0.633) , 1486px 897px 0 0 rgba(255,255,255, 0.88) , 667px 6px 0 0 rgba(255,255,255, 0.508) , 853px 504px 0 0 rgba(255,255,255, 0.248) , 1329px 1778px 0 0 rgba(255,255,255, 0.217) , 768px 1340px 0 0 rgba(255,255,255, 0.792) , 631px 1383px 0 0 rgba(255,255,255, 0.698) , 991px 1603px 0 0 rgba(255,255,255, 0.939) , 1778px 1767px 0 0 rgba(255,255,255, 0.784) , 285px 546px 0 0 rgba(255,255,255, 0.8) , 1224px 1333px 0 0 rgba(255,255,255, 0.676) , 1154px 397px 0 0 rgba(255,255,255, 0.974) , 1210px 1004px 0 0 rgba(255,255,255, 0.894) , 1632px 953px 0 0 rgba(255,255,255, 0.281) , 449px 1144px 0 0 rgba(255,255,255, 0.706) , 1426px 771px 0 0 rgba(255,255,255, 0.737) , 1438px 1634px 0 0 rgba(255,255,255, 0.984) , 806px 168px 0 0 rgba(255,255,255, 0.807) , 731px 1067px 0 0 rgba(255,255,255, 0.734) , 1731px 1785px 0 0 rgba(255,255,255, 0.528) , 23px 975px 0 0 rgba(255,255,255, 0.068) , 575px 1088px 0 0 rgba(255,255,255, 0.876) , 1205px 1668px 0 0 rgba(255,255,255, 0.601) , 18px 1457px 0 0 rgba(255,255,255, 0.176) , 252px 1163px 0 0 rgba(255,255,255, 0.416) , 1752px 1px 0 0 rgba(255,255,255, 0.374) , 382px 767px 0 0 rgba(255,255,255, 0.073) , 133px 1462px 0 0 rgba(255,255,255, 0.706) , 851px 1166px 0 0 rgba(255,255,255, 0.535) , 374px 921px 0 0 rgba(255,255,255, 0.548) , 554px 1598px 0 0 rgba(255,255,255, 0.062) , 314px 685px 0 0 rgba(255,255,255, 0.187) , 1443px 209px 0 0 rgba(255,255,255, 0.097) , 1774px 1625px 0 0 rgba(255,255,255, 0.32) , 58px 278px 0 0 rgba(255,255,255, 0.684) , 986px 338px 0 0 rgba(255,255,255, 0.272) , 718px 1357px 0 0 rgba(255,255,255, 0.317) , 722px 983px 0 0 rgba(255,255,255, 0.568) , 1124px 992px 0 0 rgba(255,255,255, 0.199) , 581px 619px 0 0 rgba(255,255,255, 0.44) , 1120px 285px 0 0 rgba(255,255,255, 0.425) , 702px 138px 0 0 rgba(255,255,255, 0.816) , 262px 767px 0 0 rgba(255,255,255, 0.92) , 1204px 38px 0 0 rgba(255,255,255, 0.197) , 1196px 410px 0 0 rgba(255,255,255, 0.453) , 707px 699px 0 0 rgba(255,255,255, 0.481) , 1590px 1488px 0 0 rgba(255,255,255, 0.559) , 879px 1763px 0 0 rgba(255,255,255, 0.241) , 106px 686px 0 0 rgba(255,255,255, 0.175) , 158px 569px 0 0 rgba(255,255,255, 0.549) , 711px 1219px 0 0 rgba(255,255,255, 0.476) , 1339px 53px 0 0 rgba(255,255,255, 0.275) , 1410px 172px 0 0 rgba(255,255,255, 0.449) , 1601px 1484px 0 0 rgba(255,255,255, 0.988) , 1328px 1752px 0 0 rgba(255,255,255, 0.827) , 1733px 1475px 0 0 rgba(255,255,255, 0.567) , 559px 742px 0 0 rgba(255,255,255, 0.423) , 772px 844px 0 0 rgba(255,255,255, 0.039) , 602px 520px 0 0 rgba(255,255,255, 0.284) , 1158px 1067px 0 0 rgba(255,255,255, 0.066) , 1562px 730px 0 0 rgba(255,255,255, 0.086) , 1792px 615px 0 0 rgba(255,255,255, 0.438) , 1085px 1191px 0 0 rgba(255,255,255, 0.157) , 1402px 1087px 0 0 rgba(255,255,255, 0.797) , 569px 1685px 0 0 rgba(255,255,255, 0.992) , 1608px 52px 0 0 rgba(255,255,255, 0.302) , 1697px 1246px 0 0 rgba(255,255,255, 0.295) , 899px 1490px 0 0 rgba(255,255,255, 0.73) , 993px 901px 0 0 rgba(255,255,255, 0.961) , 1193px 1023px 0 0 rgba(255,255,255, 0.671) , 1224px 176px 0 0 rgba(255,255,255, 0.786) , 721px 1308px 0 0 rgba(255,255,255, 0.691) , 1702px 730px 0 0 rgba(255,255,255, 0.841) , 1480px 1498px 0 0 rgba(255,255,255, 0.655) , 181px 1612px 0 0 rgba(255,255,255, 0.588) , 1776px 679px 0 0 rgba(255,255,255, 0.821) , 892px 706px 0 0 rgba(255,255,255, 0.056) , 859px 267px 0 0 rgba(255,255,255, 0.565) , 784px 1285px 0 0 rgba(255,255,255, 0.029) , 1561px 1198px 0 0 rgba(255,255,255, 0.315) , 205px 421px 0 0 rgba(255,255,255, 0.584) , 236px 406px 0 0 rgba(255,255,255, 0.166) , 1259px 689px 0 0 rgba(255,255,255, 0.321) , 448px 317px 0 0 rgba(255,255,255, 0.495) , 1318px 466px 0 0 rgba(255,255,255, 0.275) , 1053px 297px 0 0 rgba(255,255,255, 0.035) , 716px 538px 0 0 rgba(255,255,255, 0.764) , 381px 207px 0 0 rgba(255,255,255, 0.692) , 871px 1140px 0 0 rgba(255,255,255, 0.342) , 361px 53px 0 0 rgba(255,255,255, 0.984) , 1565px 1593px 0 0 rgba(255,255,255, 0.102) , 145px 277px 0 0 rgba(255,255,255, 0.866) , 220px 1503px 0 0 rgba(255,255,255, 0.936) , 1068px 1475px 0 0 rgba(255,255,255, 0.156) , 1548px 483px 0 0 rgba(255,255,255, 0.768) , 710px 103px 0 0 rgba(255,255,255, 0.809) , 1660px 921px 0 0 rgba(255,255,255, 0.952) , 462px 1252px 0 0 rgba(255,255,255, 0.825) , 1123px 1628px 0 0 rgba(255,255,255, 0.409) , 1274px 729px 0 0 rgba(255,255,255, 0.26) , 1739px 679px 0 0 rgba(255,255,255, 0.83) , 1550px 1518px 0 0 rgba(255,255,255, 0.25) , 1624px 346px 0 0 rgba(255,255,255, 0.557) , 1023px 579px 0 0 rgba(255,255,255, 0.854) , 217px 661px 0 0 rgba(255,255,255, 0.731) , 1504px 549px 0 0 rgba(255,255,255, 0.705) , 939px 5px 0 0 rgba(255,255,255, 0.389) , 284px 735px 0 0 rgba(255,255,255, 0.355) , 13px 1679px 0 0 rgba(255,255,255, 0.712) , 137px 1592px 0 0 rgba(255,255,255, 0.619) , 1113px 505px 0 0 rgba(255,255,255, 0.651) , 1584px 510px 0 0 rgba(255,255,255, 0.41) , 346px 913px 0 0 rgba(255,255,255, 0.09) , 198px 1490px 0 0 rgba(255,255,255, 0.103) , 447px 1128px 0 0 rgba(255,255,255, 0.314) , 1356px 324px 0 0 rgba(255,255,255, 0.324) , 648px 667px 0 0 rgba(255,255,255, 0.155) , 442px 260px 0 0 rgba(255,255,255, 0.22) , 210px 401px 0 0 rgba(255,255,255, 0.682) , 422px 1772px 0 0 rgba(255,255,255, 0.671) , 276px 349px 0 0 rgba(255,255,255, 0.683) , 131px 539px 0 0 rgba(255,255,255, 0.977) , 892px 94px 0 0 rgba(255,255,255, 0.081) , 1295px 222px 0 0 rgba(255,255,255, 0.961) , 5px 1727px 0 0 rgba(255,255,255, 0.311) , 714px 1148px 0 0 rgba(255,255,255, 0.846) , 1455px 1182px 0 0 rgba(255,255,255, 0.313) , 1370px 708px 0 0 rgba(255,255,255, 0.824) , 812px 433px 0 0 rgba(255,255,255, 0.75) , 1110px 558px 0 0 rgba(255,255,255, 0.709) , 1132px 1543px 0 0 rgba(255,255,255, 0.868) , 644px 610px 0 0 rgba(255,255,255, 0.166) , 269px 1481px 0 0 rgba(255,255,255, 0.889) , 1712px 590px 0 0 rgba(255,255,255, 0.139) , 1159px 599px 0 0 rgba(255,255,255, 0.992) , 1551px 209px 0 0 rgba(255,255,255, 0.033) , 1020px 1721px 0 0 rgba(255,255,255, 0.028) , 216px 373px 0 0 rgba(255,255,255, 0.665) , 877px 532px 0 0 rgba(255,255,255, 0.686) , 1326px 885px 0 0 rgba(255,255,255, 0.517) , 972px 1704px 0 0 rgba(255,255,255, 0.499) , 749px 181px 0 0 rgba(255,255,255, 0.712) , 1511px 1650px 0 0 rgba(255,255,255, 0.101) , 1432px 183px 0 0 rgba(255,255,255, 0.545) , 1541px 1338px 0 0 rgba(255,255,255, 0.71) , 513px 1406px 0 0 rgba(255,255,255, 0.17) , 1314px 1197px 0 0 rgba(255,255,255, 0.789) , 824px 1659px 0 0 rgba(255,255,255, 0.597) , 308px 298px 0 0 rgba(255,255,255, 0.917) , 1225px 659px 0 0 rgba(255,255,255, 0.229) , 1253px 257px 0 0 rgba(255,255,255, 0.631) , 1653px 185px 0 0 rgba(255,255,255, 0.113) , 336px 614px 0 0 rgba(255,255,255, 0.045) , 1093px 898px 0 0 rgba(255,255,255, 0.617) , 730px 5px 0 0 rgba(255,255,255, 0.11) , 785px 645px 0 0 rgba(255,255,255, 0.516) , 989px 678px 0 0 rgba(255,255,255, 0.917) , 1511px 1614px 0 0 rgba(255,255,255, 0.938) , 584px 1117px 0 0 rgba(255,255,255, 0.631) , 534px 1012px 0 0 rgba(255,255,255, 0.668) , 1325px 1778px 0 0 rgba(255,255,255, 0.293) , 1632px 754px 0 0 rgba(255,255,255, 0.26) , 78px 1258px 0 0 rgba(255,255,255, 0.52) , 779px 1691px 0 0 rgba(255,255,255, 0.878) , 253px 1706px 0 0 rgba(255,255,255, 0.75) , 1358px 245px 0 0 rgba(255,255,255, 0.027) , 361px 1629px 0 0 rgba(255,255,255, 0.238) , 1134px 232px 0 0 rgba(255,255,255, 0.387) , 1685px 777px 0 0 rgba(255,255,255, 0.156) , 515px 724px 0 0 rgba(255,255,255, 0.863) , 588px 1728px 0 0 rgba(255,255,255, 0.159) , 1132px 47px 0 0 rgba(255,255,255, 0.691) , 315px 1446px 0 0 rgba(255,255,255, 0.782) , 79px 233px 0 0 rgba(255,255,255, 0.317) , 1498px 1050px 0 0 rgba(255,255,255, 0.358) , 30px 1073px 0 0 rgba(255,255,255, 0.939) , 1637px 620px 0 0 rgba(255,255,255, 0.141) , 1736px 1683px 0 0 rgba(255,255,255, 0.682) , 1298px 1505px 0 0 rgba(255,255,255, 0.863) , 972px 85px 0 0 rgba(255,255,255, 0.941) , 349px 1356px 0 0 rgba(255,255,255, 0.672) , 1545px 1429px 0 0 rgba(255,255,255, 0.859) , 1076px 467px 0 0 rgba(255,255,255, 0.024) , 189px 1647px 0 0 rgba(255,255,255, 0.838) , 423px 1722px 0 0 rgba(255,255,255, 0.771) , 1691px 1719px 0 0 rgba(255,255,255, 0.676) , 1747px 658px 0 0 rgba(255,255,255, 0.255) , 149px 1492px 0 0 rgba(255,255,255, 0.911) , 1203px 1138px 0 0 rgba(255,255,255, 0.964) , 781px 1584px 0 0 rgba(255,255,255, 0.465) , 1609px 1595px 0 0 rgba(255,255,255, 0.688) , 447px 1655px 0 0 rgba(255,255,255, 0.166) , 914px 1153px 0 0 rgba(255,255,255, 0.085) , 600px 1058px 0 0 rgba(255,255,255, 0.821) , 804px 505px 0 0 rgba(255,255,255, 0.608) , 1506px 584px 0 0 rgba(255,255,255, 0.618) , 587px 1290px 0 0 rgba(255,255,255, 0.071) , 258px 600px 0 0 rgba(255,255,255, 0.243) , 328px 395px 0 0 rgba(255,255,255, 0.065) , 846px 783px 0 0 rgba(255,255,255, 0.995) , 1138px 1294px 0 0 rgba(255,255,255, 0.703) , 1668px 633px 0 0 rgba(255,255,255, 0.27) , 337px 103px 0 0 rgba(255,255,255, 0.202) , 132px 986px 0 0 rgba(255,255,255, 0.726) , 414px 757px 0 0 rgba(255,255,255, 0.752) , 8px 1311px 0 0 rgba(255,255,255, 0.307) , 1791px 910px 0 0 rgba(255,255,255, 0.346) , 844px 216px 0 0 rgba(255,255,255, 0.156) , 1547px 1723px 0 0 rgba(255,255,255, 0.73) , 1187px 398px 0 0 rgba(255,255,255, 0.698) , 1550px 1520px 0 0 rgba(255,255,255, 0.462) , 1346px 655px 0 0 rgba(255,255,255, 0.58) , 668px 770px 0 0 rgba(255,255,255, 0.422) , 1774px 1435px 0 0 rgba(255,255,255, 0.089) , 693px 1061px 0 0 rgba(255,255,255, 0.893) , 132px 1689px 0 0 rgba(255,255,255, 0.937) , 894px 1561px 0 0 rgba(255,255,255, 0.88) , 906px 1706px 0 0 rgba(255,255,255, 0.567) , 1140px 297px 0 0 rgba(255,255,255, 0.358) , 13px 1288px 0 0 rgba(255,255,255, 0.464) , 1744px 423px 0 0 rgba(255,255,255, 0.845) , 119px 1548px 0 0 rgba(255,255,255, 0.769) , 1249px 1321px 0 0 rgba(255,255,255, 0.29) , 123px 795px 0 0 rgba(255,255,255, 0.597) , 390px 1542px 0 0 rgba(255,255,255, 0.47) , 825px 667px 0 0 rgba(255,255,255, 0.049) , 1071px 875px 0 0 rgba(255,255,255, 0.06) , 1428px 1786px 0 0 rgba(255,255,255, 0.222) , 993px 696px 0 0 rgba(255,255,255, 0.399) , 1585px 247px 0 0 rgba(255,255,255, 0.094) , 1340px 1312px 0 0 rgba(255,255,255, 0.603) , 1640px 725px 0 0 rgba(255,255,255, 0.026) , 1161px 1397px 0 0 rgba(255,255,255, 0.222) , 966px 1132px 0 0 rgba(255,255,255, 0.69) , 1782px 1275px 0 0 rgba(255,255,255, 0.606) , 1117px 1533px 0 0 rgba(255,255,255, 0.248) , 1027px 959px 0 0 rgba(255,255,255, 0.46) , 459px 839px 0 0 rgba(255,255,255, 0.98) , 1192px 265px 0 0 rgba(255,255,255, 0.523) , 175px 501px 0 0 rgba(255,255,255, 0.371) , 626px 19px 0 0 rgba(255,255,255, 0.246) , 46px 1173px 0 0 rgba(255,255,255, 0.124) , 573px 925px 0 0 rgba(255,255,255, 0.621) , 1px 283px 0 0 rgba(255,255,255, 0.943) , 778px 1213px 0 0 rgba(255,255,255, 0.128) , 435px 593px 0 0 rgba(255,255,255, 0.378) , 32px 394px 0 0 rgba(255,255,255, 0.451) , 1019px 1055px 0 0 rgba(255,255,255, 0.685) , 1423px 1233px 0 0 rgba(255,255,255, 0.354) , 494px 841px 0 0 rgba(255,255,255, 0.322) , 667px 194px 0 0 rgba(255,255,255, 0.655) , 1671px 195px 0 0 rgba(255,255,255, 0.502) , 403px 1710px 0 0 rgba(255,255,255, 0.623) , 665px 1597px 0 0 rgba(255,255,255, 0.839) , 61px 1742px 0 0 rgba(255,255,255, 0.566) , 1490px 1654px 0 0 rgba(255,255,255, 0.646) , 1361px 1604px 0 0 rgba(255,255,255, 0.101) , 1191px 1023px 0 0 rgba(255,255,255, 0.881) , 550px 378px 0 0 rgba(255,255,255, 0.573) , 1332px 1234px 0 0 rgba(255,255,255, 0.922) , 760px 1205px 0 0 rgba(255,255,255, 0.992) , 1506px 1328px 0 0 rgba(255,255,255, 0.723) , 1126px 813px 0 0 rgba(255,255,255, 0.549) , 67px 240px 0 0 rgba(255,255,255, 0.901) , 125px 1301px 0 0 rgba(255,255,255, 0.464) , 643px 391px 0 0 rgba(255,255,255, 0.589) , 1114px 1756px 0 0 rgba(255,255,255, 0.321) , 1602px 699px 0 0 rgba(255,255,255, 0.274) , 510px 393px 0 0 rgba(255,255,255, 0.185) , 171px 1217px 0 0 rgba(255,255,255, 0.932) , 1202px 1362px 0 0 rgba(255,255,255, 0.726) , 1160px 1324px 0 0 rgba(255,255,255, 0.867) , 121px 319px 0 0 rgba(255,255,255, 0.992) , 1474px 835px 0 0 rgba(255,255,255, 0.89) , 357px 1213px 0 0 rgba(255,255,255, 0.91) , 783px 976px 0 0 rgba(255,255,255, 0.941) , 750px 1599px 0 0 rgba(255,255,255, 0.515) , 323px 450px 0 0 rgba(255,255,255, 0.966) , 1078px 282px 0 0 rgba(255,255,255, 0.947) , 1164px 46px 0 0 rgba(255,255,255, 0.296) , 1792px 705px 0 0 rgba(255,255,255, 0.485) , 880px 1287px 0 0 rgba(255,255,255, 0.894) , 60px 1402px 0 0 rgba(255,255,255, 0.816) , 752px 894px 0 0 rgba(255,255,255, 0.803) , 285px 1535px 0 0 rgba(255,255,255, 0.93) , 1528px 401px 0 0 rgba(255,255,255, 0.727) , 651px 1767px 0 0 rgba(255,255,255, 0.146) , 1498px 1190px 0 0 rgba(255,255,255, 0.042) , 394px 1786px 0 0 rgba(255,255,255, 0.159) , 1318px 9px 0 0 rgba(255,255,255, 0.575) , 1699px 1675px 0 0 rgba(255,255,255, 0.511) , 82px 986px 0 0 rgba(255,255,255, 0.906) , 940px 970px 0 0 rgba(255,255,255, 0.562) , 1624px 259px 0 0 rgba(255,255,255, 0.537) , 1782px 222px 0 0 rgba(255,255,255, 0.259) , 1572px 1725px 0 0 rgba(255,255,255, 0.716) , 1080px 1557px 0 0 rgba(255,255,255, 0.245) , 1727px 648px 0 0 rgba(255,255,255, 0.471) , 899px 231px 0 0 rgba(255,255,255, 0.445) , 1061px 1074px 0 0 rgba(255,255,255, 0.079) , 556px 478px 0 0 rgba(255,255,255, 0.524) , 343px 359px 0 0 rgba(255,255,255, 0.162) , 711px 1254px 0 0 rgba(255,255,255, 0.323) , 1335px 242px 0 0 rgba(255,255,255, 0.936) , 933px 39px 0 0 rgba(255,255,255, 0.784) , 1629px 908px 0 0 rgba(255,255,255, 0.289) , 1800px 229px 0 0 rgba(255,255,255, 0.399) , 1589px 926px 0 0 rgba(255,255,255, 0.709) , 976px 694px 0 0 rgba(255,255,255, 0.855) , 1163px 1240px 0 0 rgba(255,255,255, 0.754) , 1662px 1784px 0 0 rgba(255,255,255, 0.088) , 656px 1388px 0 0 rgba(255,255,255, 0.688) , 1190px 1100px 0 0 rgba(255,255,255, 0.769) , 33px 392px 0 0 rgba(255,255,255, 0.301) , 56px 1405px 0 0 rgba(255,255,255, 0.969) , 1491px 118px 0 0 rgba(255,255,255, 0.991) , 1216px 997px 0 0 rgba(255,255,255, 0.727) , 1617px 712px 0 0 rgba(255,255,255, 0.45) , 163px 553px 0 0 rgba(255,255,255, 0.977) , 103px 140px 0 0 rgba(255,255,255, 0.916) , 1099px 1404px 0 0 rgba(255,255,255, 0.167) , 1423px 587px 0 0 rgba(255,255,255, 0.792) , 1797px 309px 0 0 rgba(255,255,255, 0.526) , 381px 141px 0 0 rgba(255,255,255, 0.005) , 1214px 802px 0 0 rgba(255,255,255, 0.887) , 211px 829px 0 0 rgba(255,255,255, 0.72) , 1103px 1507px 0 0 rgba(255,255,255, 0.642) , 244px 1231px 0 0 rgba(255,255,255, 0.184) , 118px 1747px 0 0 rgba(255,255,255, 0.475) , 183px 1293px 0 0 rgba(255,255,255, 0.148) , 911px 1362px 0 0 rgba(255,255,255, 0.073) , 817px 457px 0 0 rgba(255,255,255, 0.459) , 756px 18px 0 0 rgba(255,255,255, 0.544) , 481px 1118px 0 0 rgba(255,255,255, 0.878) , 380px 138px 0 0 rgba(255,255,255, 0.132) , 320px 646px 0 0 rgba(255,255,255, 0.04) , 1724px 1716px 0 0 rgba(255,255,255, 0.381) , 978px 1269px 0 0 rgba(255,255,255, 0.431) , 1530px 255px 0 0 rgba(255,255,255, 0.31) , 664px 204px 0 0 rgba(255,255,255, 0.913) , 474px 703px 0 0 rgba(255,255,255, 0.832) , 1722px 1204px 0 0 rgba(255,255,255, 0.356) , 1453px 821px 0 0 rgba(255,255,255, 0.195) , 730px 1468px 0 0 rgba(255,255,255, 0.696) , 928px 1610px 0 0 rgba(255,255,255, 0.894) , 1036px 304px 0 0 rgba(255,255,255, 0.696) , 1590px 172px 0 0 rgba(255,255,255, 0.729) , 249px 1590px 0 0 rgba(255,255,255, 0.277) , 357px 81px 0 0 rgba(255,255,255, 0.526) , 726px 1261px 0 0 rgba(255,255,255, 0.149) , 643px 946px 0 0 rgba(255,255,255, 0.005) , 1263px 995px 0 0 rgba(255,255,255, 0.124) , 1564px 1107px 0 0 rgba(255,255,255, 0.789) , 388px 83px 0 0 rgba(255,255,255, 0.498) , 715px 681px 0 0 rgba(255,255,255, 0.655) , 1618px 1624px 0 0 rgba(255,255,255, 0.63) , 1423px 1576px 0 0 rgba(255,255,255, 0.52) , 564px 1786px 0 0 rgba(255,255,255, 0.482) , 1066px 735px 0 0 rgba(255,255,255, 0.276) , 714px 1179px 0 0 rgba(255,255,255, 0.395) , 967px 1006px 0 0 rgba(255,255,255, 0.923) , 1136px 1790px 0 0 rgba(255,255,255, 0.801) , 215px 1690px 0 0 rgba(255,255,255, 0.957) , 1500px 1338px 0 0 rgba(255,255,255, 0.541) , 1679px 1065px 0 0 rgba(255,255,255, 0.925) , 426px 1489px 0 0 rgba(255,255,255, 0.193) , 1273px 853px 0 0 rgba(255,255,255, 0.317) , 665px 1189px 0 0 rgba(255,255,255, 0.512) , 520px 552px 0 0 rgba(255,255,255, 0.925) , 253px 438px 0 0 rgba(255,255,255, 0.588) , 369px 1354px 0 0 rgba(255,255,255, 0.889) , 749px 205px 0 0 rgba(255,255,255, 0.243) , 820px 145px 0 0 rgba(255,255,255, 0.207) , 1739px 228px 0 0 rgba(255,255,255, 0.267) , 392px 495px 0 0 rgba(255,255,255, 0.504) , 721px 1044px 0 0 rgba(255,255,255, 0.823) , 833px 912px 0 0 rgba(255,255,255, 0.222) , 865px 1499px 0 0 rgba(255,255,255, 0.003) , 313px 756px 0 0 rgba(255,255,255, 0.727) , 439px 1187px 0 0 rgba(255,255,255, 0.572) , 6px 1238px 0 0 rgba(255,255,255, 0.676) , 1567px 11px 0 0 rgba(255,255,255, 0.701) , 1216px 757px 0 0 rgba(255,255,255, 0.87) , 916px 588px 0 0 rgba(255,255,255, 0.565) , 831px 215px 0 0 rgba(255,255,255, 0.597) , 1289px 697px 0 0 rgba(255,255,255, 0.964) , 307px 34px 0 0 rgba(255,255,255, 0.462) , 3px 1685px 0 0 rgba(255,255,255, 0.464) , 1115px 1421px 0 0 rgba(255,255,255, 0.303) , 1451px 473px 0 0 rgba(255,255,255, 0.142) , 1374px 1205px 0 0 rgba(255,255,255, 0.086) , 1564px 317px 0 0 rgba(255,255,255, 0.773) , 304px 1127px 0 0 rgba(255,255,255, 0.653) , 446px 214px 0 0 rgba(255,255,255, 0.135) , 1541px 459px 0 0 rgba(255,255,255, 0.725) , 1387px 880px 0 0 rgba(255,255,255, 0.157) , 1172px 224px 0 0 rgba(255,255,255, 0.088) , 1420px 637px 0 0 rgba(255,255,255, 0.916) , 1385px 932px 0 0 rgba(255,255,255, 0.225) , 174px 1472px 0 0 rgba(255,255,255, 0.649) , 252px 750px 0 0 rgba(255,255,255, 0.277) , 825px 1042px 0 0 rgba(255,255,255, 0.707) , 840px 703px 0 0 rgba(255,255,255, 0.948) , 1478px 1800px 0 0 rgba(255,255,255, 0.151) , 95px 1303px 0 0 rgba(255,255,255, 0.332) , 1198px 740px 0 0 rgba(255,255,255, 0.443) , 141px 312px 0 0 rgba(255,255,255, 0.04) , 291px 729px 0 0 rgba(255,255,255, 0.284) , 1209px 1506px 0 0 rgba(255,255,255, 0.741) , 1188px 307px 0 0 rgba(255,255,255, 0.141) , 958px 41px 0 0 rgba(255,255,255, 0.858) , 1311px 1484px 0 0 rgba(255,255,255, 0.097) , 846px 1153px 0 0 rgba(255,255,255, 0.862) , 1238px 1376px 0 0 rgba(255,255,255, 0.071) , 1499px 342px 0 0 rgba(255,255,255, 0.719) , 640px 833px 0 0 rgba(255,255,255, 0.966) , 712px 545px 0 0 rgba(255,255,255, 0.194) , 1655px 1542px 0 0 rgba(255,255,255, 0.82) , 616px 353px 0 0 rgba(255,255,255, 0.871) , 1591px 1631px 0 0 rgba(255,255,255, 0.61) , 1664px 591px 0 0 rgba(255,255,255, 0.35) , 934px 454px 0 0 rgba(255,255,255, 0.58) , 1175px 477px 0 0 rgba(255,255,255, 0.966) , 299px 914px 0 0 rgba(255,255,255, 0.839) , 534px 243px 0 0 rgba(255,255,255, 0.194) , 773px 1135px 0 0 rgba(255,255,255, 0.42) , 1696px 1472px 0 0 rgba(255,255,255, 0.552) , 125px 523px 0 0 rgba(255,255,255, 0.591) , 1195px 382px 0 0 rgba(255,255,255, 0.904) , 1609px 1374px 0 0 rgba(255,255,255, 0.579) , 843px 82px 0 0 rgba(255,255,255, 0.072) , 1604px 451px 0 0 rgba(255,255,255, 0.545) , 1322px 190px 0 0 rgba(255,255,255, 0.034) , 528px 228px 0 0 rgba(255,255,255, 0.146) , 1470px 1169px 0 0 rgba(255,255,255, 0.912) , 502px 1350px 0 0 rgba(255,255,255, 0.594) , 1031px 298px 0 0 rgba(255,255,255, 0.368) , 1100px 1427px 0 0 rgba(255,255,255, 0.79) , 979px 1105px 0 0 rgba(255,255,255, 0.973) , 643px 1184px 0 0 rgba(255,255,255, 0.813) , 1636px 1701px 0 0 rgba(255,255,255, 0.013) , 1004px 245px 0 0 rgba(255,255,255, 0.412) , 680px 740px 0 0 rgba(255,255,255, 0.967) , 1599px 562px 0 0 rgba(255,255,255, 0.66) , 256px 1617px 0 0 rgba(255,255,255, 0.463) , 314px 1092px 0 0 rgba(255,255,255, 0.734) , 870px 900px 0 0 rgba(255,255,255, 0.512) , 530px 60px 0 0 rgba(255,255,255, 0.198) , 1786px 896px 0 0 rgba(255,255,255, 0.392) , 636px 212px 0 0 rgba(255,255,255, 0.997) , 672px 540px 0 0 rgba(255,255,255, 0.632) , 1118px 1649px 0 0 rgba(255,255,255, 0.377) , 433px 647px 0 0 rgba(255,255,255, 0.902) , 1200px 1737px 0 0 rgba(255,255,255, 0.262) , 1258px 143px 0 0 rgba(255,255,255, 0.729) , 1603px 1364px 0 0 rgba(255,255,255, 0.192) , 66px 1756px 0 0 rgba(255,255,255, 0.681) , 946px 263px 0 0 rgba(255,255,255, 0.105) , 1216px 1082px 0 0 rgba(255,255,255, 0.287) , 6px 1143px 0 0 rgba(255,255,255, 0.017) , 1631px 126px 0 0 rgba(255,255,255, 0.449) , 357px 1565px 0 0 rgba(255,255,255, 0.163) , 1752px 261px 0 0 rgba(255,255,255, 0.423) , 1247px 1631px 0 0 rgba(255,255,255, 0.312) , 320px 671px 0 0 rgba(255,255,255, 0.695) , 1375px 596px 0 0 rgba(255,255,255, 0.856) , 1456px 1340px 0 0 rgba(255,255,255, 0.564) , 447px 1044px 0 0 rgba(255,255,255, 0.623) , 1732px 447px 0 0 rgba(255,255,255, 0.216) , 174px 1509px 0 0 rgba(255,255,255, 0.398) , 16px 861px 0 0 rgba(255,255,255, 0.904) , 878px 1296px 0 0 rgba(255,255,255, 0.205) , 1725px 1483px 0 0 rgba(255,255,255, 0.704) , 255px 48px 0 0 rgba(255,255,255, 0.7) , 610px 1669px 0 0 rgba(255,255,255, 0.865) , 1044px 1251px 0 0 rgba(255,255,255, 0.98) , 884px 862px 0 0 rgba(255,255,255, 0.198) , 986px 545px 0 0 rgba(255,255,255, 0.379) , 1620px 217px 0 0 rgba(255,255,255, 0.159) , 383px 1763px 0 0 rgba(255,255,255, 0.518) , 595px 974px 0 0 rgba(255,255,255, 0.347) , 359px 14px 0 0 rgba(255,255,255, 0.863) , 95px 1385px 0 0 rgba(255,255,255, 0.011) , 411px 1030px 0 0 rgba(255,255,255, 0.038) , 345px 789px 0 0 rgba(255,255,255, 0.771) , 421px 460px 0 0 rgba(255,255,255, 0.133) , 972px 1160px 0 0 rgba(255,255,255, 0.342) , 597px 1061px 0 0 rgba(255,255,255, 0.781) , 1017px 1092px 0 0 rgba(255,255,255, 0.437); } - .warning { background: ; display: flex; align-content: center; padding: 10px; text-align: left; justify-content: center; } - .warning svg { height: 48px; width: 48px; margin-right: 10px; } + .warning { background: ; display: flex; align-items: center; padding: 10px; text-align: left; justify-content: center; } + .warning svg { flex-shrink: 0; height: 32px; width: 32px; margin-right: 10px; } + .warning p { line-height: 1.4; margin: 0; } .container svg.wave { position: absolute; bottom: -2px; left: 0; z-index: 1; } .container .logo { margin-bottom: 1em; } .container .logo svg { fill: hsl(, 20%, 26%); } @@ -45,9 +46,6 @@ @keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } .sf-toolbar { opacity: 0; -webkit-animation: fade-in 1s .2s forwards; animation: fade-in 1s .2s forwards; z-index: 99999; } - body { font-size: 20px; } - .warning { text-align: center; } - .warning svg { height: 32px; width: 32px; } .resources .row { margin-left: 50px; margin-right: 50px; } .resource { padding: 0 30px; } @@ -59,13 +57,19 @@ .resource h2 { font-size: 22px; } .resource a { font-size: 16px; margin-top: 0; } } + @media (min-width: 992px) { + body { font-size: 20px; } + .warning { text-align: center; } + }
- You're seeing this page because you haven't configured any homepage URL and debug mode is enabled. +

+ You're seeing this page because you haven't configured any homepage URL and debug mode is enabled. +

From cd2e325fc34a4a5bbec91eecf69dda8ee8c5ea4f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 1 May 2021 16:38:48 +0200 Subject: [PATCH 154/266] Update VERSION for 4.4.22 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 447c9936eb..947c871e15 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.22-DEV'; + public const VERSION = '4.4.22'; public const VERSION_ID = 40422; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 22; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 62d7cd914463a48541f4209f6d3fa0defb7e0d31 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 1 May 2021 16:48:05 +0200 Subject: [PATCH 155/266] Bump Symfony version to 4.4.23 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 947c871e15..c0d460634d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.22'; - public const VERSION_ID = 40422; + public const VERSION = '4.4.23-DEV'; + public const VERSION_ID = 40423; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 22; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 23; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 95bb42312503a212f4467529bac8735f01226ff9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 May 2021 15:13:32 +0200 Subject: [PATCH 156/266] Update VERSION for 4.4.23 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c0d460634d..9793dd39e2 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.23-DEV'; + public const VERSION = '4.4.23'; public const VERSION_ID = 40423; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 23; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 0cc7b69c66f452d717570f9522abe22bd9397ad5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 12 May 2021 15:18:54 +0200 Subject: [PATCH 157/266] Bump Symfony version to 4.4.24 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9793dd39e2..34bc8d7b4a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.23'; - public const VERSION_ID = 40423; + public const VERSION = '4.4.24-DEV'; + public const VERSION_ID = 40424; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 23; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 24; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 46e66e82a99a8b9ad7b33685b12e8d9465be06e7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 15 May 2021 19:17:06 +0200 Subject: [PATCH 158/266] Fixed deprecation warnings about passing null as parameter --- .../RegisterControllerArgumentLocatorsPass.php | 2 +- EventListener/RouterListener.php | 2 +- Tests/HttpCache/HttpCacheTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 40c850cf66..cf4ab60284 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -124,7 +124,7 @@ public function process(ContainerBuilder $container) $args = []; foreach ($parameters as $p) { /** @var \ReflectionParameter $p */ - $type = ltrim($target = ProxyHelper::getTypeHint($r, $p), '\\'); + $type = ltrim($target = (string) ProxyHelper::getTypeHint($r, $p), '\\'); $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; if (isset($arguments[$r->name][$p->name])) { diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index 0071979688..47ee87b103 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -164,7 +164,7 @@ public static function getSubscribedEvents() private function createWelcomeResponse(): Response { $version = Kernel::VERSION; - $projectDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR; + $projectDir = realpath((string) $this->projectDir).\DIRECTORY_SEPARATOR; $docVersion = substr(Kernel::VERSION, 0, 3); ob_start(); diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index d9dd572bf1..9bec2f7c94 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -212,8 +212,8 @@ public function testIncrementsMaxAgeWhenNoDateIsSpecifiedEventWhenUsingETag() public function testValidatesPrivateResponsesCachedOnTheClient() { - $this->setNextResponse(200, [], '', function ($request, $response) { - $etags = preg_split('/\s*,\s*/', $request->headers->get('IF_NONE_MATCH')); + $this->setNextResponse(200, [], '', function (Request $request, $response) { + $etags = preg_split('/\s*,\s*/', $request->headers->get('IF_NONE_MATCH', '')); if ($request->cookies->has('authenticated')) { $response->headers->set('Cache-Control', 'private, no-store'); $response->setETag('"private tag"'); From 59925ee79f2541b4c6e990843e1a42768e898254 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 19 May 2021 14:12:19 +0200 Subject: [PATCH 159/266] Update VERSION for 4.4.24 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 34bc8d7b4a..3492753cf5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.24-DEV'; + public const VERSION = '4.4.24'; public const VERSION_ID = 40424; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 24; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From f287ea9a4a8bc7d9af813f23c379f1c8538c0aca Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 19 May 2021 14:20:36 +0200 Subject: [PATCH 160/266] Bump Symfony version to 4.4.25 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3492753cf5..885337bf37 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.24'; - public const VERSION_ID = 40424; + public const VERSION = '4.4.25-DEV'; + public const VERSION_ID = 40425; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 24; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 25; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 3879d23e8166d9df60528460dbcea77e1cff330b Mon Sep 17 00:00:00 2001 From: "Antonin \"0x346e3730\" CLAUZIER" Date: Wed, 26 May 2021 12:28:46 +0200 Subject: [PATCH 161/266] [HttpKernel] Fixes tests for PHP7.4+ --- HttpCache/Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 3b69289f17..7dfdc491dd 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -349,7 +349,7 @@ private function load(string $key): ?string { $path = $this->getPath($key); - return file_exists($path) && false !== ($contents = file_get_contents($path)) ? $contents : null; + return file_exists($path) && false !== ($contents = @file_get_contents($path)) ? $contents : null; } /** From a0d8fd719d31477e30e6c849209b8962ade28d51 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 May 2021 13:20:16 +0200 Subject: [PATCH 162/266] Fix markdown --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0136784a72..18d15f5ad8 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ enough to create full-stack frameworks, micro-frameworks or advanced CMS systems Resources --------- - * [Documentation](https://symfony.com/doc/current/components/http_kernel.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) + * [Documentation](https://symfony.com/doc/current/components/http_kernel.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) From 3795165596fe81a52296b78c9aae938d434069cc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 1 Jun 2021 09:12:08 +0200 Subject: [PATCH 163/266] Update VERSION for 4.4.25 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 885337bf37..82ee8b26b9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.25-DEV'; + public const VERSION = '4.4.25'; public const VERSION_ID = 40425; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 25; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From a473739508ceda914f51988fd2fce51acbe6a836 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 1 Jun 2021 11:02:47 +0200 Subject: [PATCH 164/266] Bump Symfony version to 4.4.26 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 82ee8b26b9..819c60538f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.25'; - public const VERSION_ID = 40425; + public const VERSION = '4.4.26-DEV'; + public const VERSION_ID = 40426; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 25; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 26; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From d5fb8335ff377b944d2736b355130917fe5e1eaa Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 10 Jun 2021 20:42:23 +0000 Subject: [PATCH 165/266] [HttpKernel] [HttpCache] Keep s-maxage=0 from ESI sub-responses --- HttpCache/ResponseCacheStrategy.php | 6 ++++-- Tests/HttpCache/ResponseCacheStrategyTest.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 1f09946846..47bbbb7431 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -81,8 +81,10 @@ public function add(Response $response) return; } - $this->storeRelativeAgeDirective('max-age', $response->headers->getCacheControlDirective('max-age'), $age); - $this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age); + $maxAge = $response->headers->hasCacheControlDirective('max-age') ? (int) $response->headers->getCacheControlDirective('max-age') : null; + $this->storeRelativeAgeDirective('max-age', $maxAge, $age); + $sharedMaxAge = $response->headers->hasCacheControlDirective('s-maxage') ? (int) $response->headers->getCacheControlDirective('s-maxage') : $maxAge; + $this->storeRelativeAgeDirective('s-maxage', $sharedMaxAge, $age); $expires = $response->getExpires(); $expires = null !== $expires ? (int) $expires->format('U') - (int) $response->getDate()->format('U') : null; diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index 62179ba154..4875870eef 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -377,6 +377,22 @@ public function cacheControlMergingProvider() ], ]; + yield 's-maxage may be set to 0' => [ + ['public' => true, 's-maxage' => '0', 'max-age' => null], + ['public' => true, 's-maxage' => '0'], + [ + ['public' => true, 's-maxage' => '60'], + ], + ]; + + yield 's-maxage may be set to 0, and works independently from maxage' => [ + ['public' => true, 's-maxage' => '0', 'max-age' => '30'], + ['public' => true, 's-maxage' => '0', 'max-age' => '30'], + [ + ['public' => true, 'max-age' => '60'], + ], + ]; + yield 'result is private when combining private responses' => [ ['no-cache' => false, 'must-revalidate' => false, 'private' => true], ['s-maxage' => 60, 'private' => true], From cb810f450f1ffff8819704260dc416dcbc51afae Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 11 Jun 2021 05:58:59 +0000 Subject: [PATCH 166/266] Public responses without lifetime should not remove lifetime for the resulting response --- HttpCache/ResponseCacheStrategy.php | 29 +++++++++++++++---- Tests/HttpCache/ResponseCacheStrategyTest.php | 26 ++++++++++++++++- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 47bbbb7431..17a7e87fe9 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -81,14 +81,15 @@ public function add(Response $response) return; } + $isHeuristicallyCacheable = $response->headers->hasCacheControlDirective('public'); $maxAge = $response->headers->hasCacheControlDirective('max-age') ? (int) $response->headers->getCacheControlDirective('max-age') : null; - $this->storeRelativeAgeDirective('max-age', $maxAge, $age); + $this->storeRelativeAgeDirective('max-age', $maxAge, $age, $isHeuristicallyCacheable); $sharedMaxAge = $response->headers->hasCacheControlDirective('s-maxage') ? (int) $response->headers->getCacheControlDirective('s-maxage') : $maxAge; - $this->storeRelativeAgeDirective('s-maxage', $sharedMaxAge, $age); + $this->storeRelativeAgeDirective('s-maxage', $sharedMaxAge, $age, $isHeuristicallyCacheable); $expires = $response->getExpires(); $expires = null !== $expires ? (int) $expires->format('U') - (int) $response->getDate()->format('U') : null; - $this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0); + $this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0, $isHeuristicallyCacheable); } /** @@ -199,11 +200,29 @@ private function willMakeFinalResponseUncacheable(Response $response): bool * we have to subtract the age so that the value is normalized for an age of 0. * * If the value is lower than the currently stored value, we update the value, to keep a rolling - * minimal value of each instruction. If the value is NULL, the directive will not be set on the final response. + * minimal value of each instruction. + * + * If the value is NULL and the isHeuristicallyCacheable parameter is false, the directive will + * not be set on the final response. In this case, not all responses had the directive set and no + * value can be found that satisfies the requirements of all responses. The directive will be dropped + * from the final response. + * + * If the isHeuristicallyCacheable parameter is true, however, the current response has been marked + * as cacheable in a public (shared) cache, but did not provide an explicit lifetime that would serve + * as an upper bound. In this case, we can proceed and possibly keep the directive on the final response. */ - private function storeRelativeAgeDirective(string $directive, ?int $value, int $age) + private function storeRelativeAgeDirective(string $directive, ?int $value, int $age, bool $isHeuristicallyCacheable) { if (null === $value) { + if ($isHeuristicallyCacheable) { + /* + * See https://datatracker.ietf.org/doc/html/rfc7234#section-4.2.2 + * This particular response does not require maximum lifetime; heuristics might be applied. + * Other responses, however, might have more stringent requirements on maximum lifetime. + * So, return early here so that the final response can have the more limiting value set. + */ + return; + } $this->ageDirectives[$directive] = false; } diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index 4875870eef..4d56b24285 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -370,7 +370,7 @@ public function cacheControlMergingProvider() ]; yield 'merge max-age and s-maxage' => [ - ['public' => true, 's-maxage' => '60', 'max-age' => null], + ['public' => true, 'max-age' => '60'], ['public' => true, 's-maxage' => 3600], [ ['public' => true, 'max-age' => 60], @@ -393,6 +393,30 @@ public function cacheControlMergingProvider() ], ]; + yield 'public subresponse without lifetime does not remove lifetime for main response' => [ + ['public' => true, 's-maxage' => '30', 'max-age' => null], + ['public' => true, 's-maxage' => '30'], + [ + ['public' => true], + ], + ]; + + yield 'lifetime for subresponse is kept when main response has no lifetime' => [ + ['public' => true, 'max-age' => '30'], + ['public' => true], + [ + ['public' => true, 'max-age' => '30'], + ], + ]; + + yield 's-maxage on the subresponse implies public, so the result is public as well' => [ + ['public' => true, 'max-age' => '10', 's-maxage' => null], + ['public' => true, 'max-age' => '10'], + [ + ['max-age' => '30', 's-maxage' => '20'], + ], + ]; + yield 'result is private when combining private responses' => [ ['no-cache' => false, 'must-revalidate' => false, 'private' => true], ['s-maxage' => 60, 'private' => true], From e08b2fb8a6eedd81c70522e514bad9b2c1fff881 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 Jun 2021 10:18:06 +0200 Subject: [PATCH 167/266] Update VERSION for 4.4.26 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 819c60538f..1275f12e7a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.26-DEV'; + public const VERSION = '4.4.26'; public const VERSION_ID = 40426; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 26; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 5df8755930ac683aedca27fe3bef25ccc37669af Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 Jun 2021 10:22:49 +0200 Subject: [PATCH 168/266] Bump Symfony version to 4.4.27 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1275f12e7a..1c46d1cbb5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.26'; - public const VERSION_ID = 40426; + public const VERSION = '4.4.27-DEV'; + public const VERSION_ID = 40427; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 26; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 27; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From c59bb664de88a3fbe5bef1fe7bd7f3225498783f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Jul 2021 16:28:33 +0200 Subject: [PATCH 169/266] Backport type fixes --- ControllerMetadata/ArgumentMetadataFactoryInterface.php | 2 +- DataCollector/LoggerDataCollector.php | 2 -- DataCollector/RequestDataCollector.php | 2 +- Debug/FileLinkFormatter.php | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ControllerMetadata/ArgumentMetadataFactoryInterface.php b/ControllerMetadata/ArgumentMetadataFactoryInterface.php index 6ea179d783..a34befc22d 100644 --- a/ControllerMetadata/ArgumentMetadataFactoryInterface.php +++ b/ControllerMetadata/ArgumentMetadataFactoryInterface.php @@ -19,7 +19,7 @@ interface ArgumentMetadataFactoryInterface { /** - * @param mixed $controller The controller to resolve the arguments for + * @param string|object|array $controller The controller to resolve the arguments for * * @return ArgumentMetadata[] */ diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 2797a347c8..0e25f8960f 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -18,8 +18,6 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; /** - * LogDataCollector. - * * @author Fabien Potencier * * @final since Symfony 4.4 diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 0e3c13ba06..f40c2fb9f6 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -388,7 +388,7 @@ public function getName() /** * Parse a controller. * - * @param mixed $controller The controller to parse + * @param string|object|array|null $controller The controller to parse * * @return array|string An array of controller data or a simple string */ diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index 6d7c1e942e..79755a8ad7 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -32,7 +32,7 @@ class FileLinkFormatter /** * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) + public function __construct(string $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) { $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !\is_array($fileLinkFormat)) { From 09878fd98ab7a5ab85e8ce32f84b46c90723fdcd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 8 Jul 2021 13:32:35 +0200 Subject: [PATCH 170/266] recover from failed deserializations --- HttpCache/Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index 7dfdc491dd..eeb7a6ef94 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -298,7 +298,7 @@ private function getMetadata(string $key): array return []; } - return unserialize($entries); + return unserialize($entries) ?: []; } /** From 6c5b78e56d50a9992bfc9b4a46f42399d5d8d911 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 9 Jul 2021 12:48:54 +0200 Subject: [PATCH 171/266] do not mock event classes --- .../EventListener/AddRequestFormatsListenerTest.php | 13 ++----------- Tests/EventListener/SaveSessionListenerTest.php | 12 ++++++++---- Tests/EventListener/SessionListenerTest.php | 4 +--- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Tests/EventListener/AddRequestFormatsListenerTest.php b/Tests/EventListener/AddRequestFormatsListenerTest.php index fab9a8a38f..9b3c1a2e58 100644 --- a/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -54,7 +55,7 @@ public function testRegisteredEvent() public function testSetAdditionalFormats() { $request = $this->createMock(Request::class); - $event = $this->getRequestEventMock($request); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $request->expects($this->once()) ->method('setFormat') @@ -62,14 +63,4 @@ public function testSetAdditionalFormats() $this->listener->onKernelRequest($event); } - - protected function getRequestEventMock(Request $request) - { - $event = $this->createMock(RequestEvent::class); - $event->expects($this->any()) - ->method('getRequest') - ->willReturn($request); - - return $event; - } } diff --git a/Tests/EventListener/SaveSessionListenerTest.php b/Tests/EventListener/SaveSessionListenerTest.php index f79b73c5fe..bbb76771e0 100644 --- a/Tests/EventListener/SaveSessionListenerTest.php +++ b/Tests/EventListener/SaveSessionListenerTest.php @@ -26,13 +26,17 @@ class SaveSessionListenerTest extends TestCase { public function testOnlyTriggeredOnMasterRequest() { + $session = $this->createMock(SessionInterface::class); + $session->expects($this->never())->method('save'); + $session->expects($this->any())->method('isStarted')->willReturn(true); + + $request = new Request(); + $request->setSession($session); + $listener = new SaveSessionListener(); - $event = $this->createMock(ResponseEvent::class); - $event->expects($this->once())->method('isMasterRequest')->willReturn(false); - $event->expects($this->never())->method('getRequest'); // sub request - $listener->onKernelResponse($event); + $listener->onKernelResponse(new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::SUB_REQUEST, new Response())); } public function testSessionSaved() diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index e0dba81683..d6ff42f926 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -58,9 +58,7 @@ public function testSessionIsSet() $request = new Request(); $listener = new SessionListener($container); - $event = $this->createMock(RequestEvent::class); - $event->expects($this->exactly(2))->method('isMasterRequest')->willReturn(true); - $event->expects($this->once())->method('getRequest')->willReturn($request); + $event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST); $listener->onKernelRequest($event); From 9da2a51858fb685af52e39540b357e07d84a5320 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 9 Jul 2021 16:39:14 +0200 Subject: [PATCH 172/266] do not mock the Request class --- Tests/EventListener/DisallowRobotsIndexingListenerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/EventListener/DisallowRobotsIndexingListenerTest.php b/Tests/EventListener/DisallowRobotsIndexingListenerTest.php index 6534ebf4e2..4a05d65188 100644 --- a/Tests/EventListener/DisallowRobotsIndexingListenerTest.php +++ b/Tests/EventListener/DisallowRobotsIndexingListenerTest.php @@ -29,7 +29,7 @@ public function testInvoke(?string $expected, array $responseArgs) $response = new Response(...$responseArgs); $listener = new DisallowRobotsIndexingListener(); - $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), KernelInterface::MASTER_REQUEST, $response); + $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), new Request(), KernelInterface::MASTER_REQUEST, $response); $listener->onResponse($event); From f96639df6757d7916fc214e9602b9c320f33effb Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 18 Jul 2021 16:04:40 +0200 Subject: [PATCH 173/266] Indicate compatibility with psr/log 2 and 3 Signed-off-by: Alexander M. Turek --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a2fa2a0eca..1563315ee6 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.15", - "psr/log": "~1.0" + "psr/log": "^1|^2" }, "require-dev": { "symfony/browser-kit": "^4.3|^5.0", @@ -45,7 +45,7 @@ "twig/twig": "^1.43|^2.13|^3.0.4" }, "provide": { - "psr/log-implementation": "1.0" + "psr/log-implementation": "1.0|2.0" }, "conflict": { "symfony/browser-kit": "<4.3", From 0b693cf08befd4d6fbcc22218a1ee699cd0bc796 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Jul 2021 20:11:21 +0200 Subject: [PATCH 174/266] Simplify some code with null coalesce operator --- EventListener/DebugHandlersListener.php | 2 +- Profiler/Profile.php | 6 +----- Tests/KernelTest.php | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index cfc277e330..5027bd1169 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -60,7 +60,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; - $this->levels = null === $levels ? \E_ALL : $levels; + $this->levels = $levels ?? \E_ALL; $this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null)); $this->scream = $scream; $this->fileLinkFormat = $fileLinkFormat; diff --git a/Profiler/Profile.php b/Profiler/Profile.php index ac5b5044c1..88e82b4e2f 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -156,11 +156,7 @@ public function setUrl($url) */ public function getTime() { - if (null === $this->time) { - return 0; - } - - return $this->time; + return $this->time ?? 0; } /** diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 63fb4973f6..ec57289dde 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -709,7 +709,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu $bundle ->expects($this->any()) ->method('getName') - ->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName) + ->willReturn($bundleName ?? \get_class($bundle)) ; $bundle From 21336dbfa9f75bd187fc121a2f74f195980dde0a Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sun, 4 Jul 2021 19:20:55 +0200 Subject: [PATCH 175/266] Leverage str_ends_with added the php80 polyfill to requirements when necessary --- DependencyInjection/AddAnnotatedClassesToCachePass.php | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 5eb833b51d..17a5f7f02e 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -62,7 +62,7 @@ private function expandClasses(array $patterns, array $classes): array // Explicit classes declared in the patterns are returned directly foreach ($patterns as $key => $pattern) { - if ('\\' !== substr($pattern, -1) && false === strpos($pattern, '*')) { + if (!str_ends_with($pattern, '\\') && false === strpos($pattern, '*')) { unset($patterns[$key]); $expanded[] = ltrim($pattern, '\\'); } diff --git a/composer.json b/composer.json index 1563315ee6..d928c7acea 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.15", + "symfony/polyfill-php80": "^1.16", "psr/log": "^1|^2" }, "require-dev": { From 882946ca24631ae97b2f13148866da19a32e0b4f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 7 Jun 2021 01:15:42 +0200 Subject: [PATCH 176/266] Leverage str_contains/str_starts_with Signed-off-by: Alexander M. Turek --- Client.php | 2 +- Config/FileLocator.php | 4 ++-- Controller/ControllerResolver.php | 6 +++--- DataCollector/DumpDataCollector.php | 4 ++-- DataCollector/MemoryDataCollector.php | 4 ++-- DataCollector/RequestDataCollector.php | 4 ++-- Debug/FileLinkFormatter.php | 2 +- DependencyInjection/AddAnnotatedClassesToCachePass.php | 6 +++--- EventListener/AbstractTestSessionListener.php | 2 +- Exception/ControllerDoesNotReturnResponseException.php | 2 +- HttpCache/AbstractSurrogate.php | 2 +- HttpCache/Esi.php | 2 +- HttpCache/Ssi.php | 2 +- Kernel.php | 8 ++++---- Log/Logger.php | 2 +- Profiler/FileProfilerStorage.php | 4 ++-- Tests/EventListener/RouterListenerTest.php | 2 +- 17 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Client.php b/Client.php index f0dd66ece8..5c9169ce4b 100644 --- a/Client.php +++ b/Client.php @@ -85,7 +85,7 @@ protected function getScript($request) $requires = ''; foreach (get_declared_classes() as $class) { - if (0 === strpos($class, 'ComposerAutoloaderInit')) { + if (str_starts_with($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $file = \dirname($r->getFileName(), 2).'/autoload.php'; if (file_exists($file)) { diff --git a/Config/FileLocator.php b/Config/FileLocator.php index 5dc82b33dc..a302419701 100644 --- a/Config/FileLocator.php +++ b/Config/FileLocator.php @@ -70,11 +70,11 @@ public function locate($file, $currentPath = null, $first = true) // no need to trigger deprecations when the loaded file is given as absolute path foreach ($this->paths as $deprecatedPath) { foreach ((array) $locations as $location) { - if (null !== $currentPath && 0 === strpos($location, $currentPath)) { + if (null !== $currentPath && str_starts_with($location, $currentPath)) { return $locations; } - if (0 === strpos($location, $deprecatedPath) && (null === $currentPath || false === strpos($location, $currentPath))) { + if (str_starts_with($location, $deprecatedPath) && (null === $currentPath || !str_contains($location, $currentPath))) { $deprecation = sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath); } } diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 9c2fdd9807..c3df8f9571 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -106,7 +106,7 @@ public function getController(Request $request) */ protected function createController($controller) { - if (false === strpos($controller, '::')) { + if (!str_contains($controller, '::')) { $controller = $this->instantiateController($controller); if (!\is_callable($controller)) { @@ -154,7 +154,7 @@ protected function instantiateController($class) private function getControllerError($callable): string { if (\is_string($callable)) { - if (false !== strpos($callable, '::')) { + if (str_contains($callable, '::')) { $callable = explode('::', $callable, 2); } else { return sprintf('Function "%s" does not exist.', $callable); @@ -195,7 +195,7 @@ private function getControllerError($callable): string foreach ($collection as $item) { $lev = levenshtein($method, $item); - if ($lev <= \strlen($method) / 3 || false !== strpos($item, $method)) { + if ($lev <= \strlen($method) / 3 || str_contains($item, $method)) { $alternatives[] = $item; } } diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index a3cf2147cb..a66224b6f4 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -120,11 +120,11 @@ public function collect(Request $request, Response $response/*, \Throwable $exce if (!$this->requestStack || !$response->headers->has('X-Debug-Token') || $response->isRedirection() - || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html')) + || ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html')) || 'html' !== $request->getRequestFormat() || false === strripos($response->getContent(), '') ) { - if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) { + if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type'), 'html')) { $dumper = new HtmlDumper('php://output', $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { diff --git a/DataCollector/MemoryDataCollector.php b/DataCollector/MemoryDataCollector.php index 7ffcdab41d..ff0ccd9fa9 100644 --- a/DataCollector/MemoryDataCollector.php +++ b/DataCollector/MemoryDataCollector.php @@ -104,9 +104,9 @@ private function convertToBytes(string $memoryLimit) $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); - if (0 === strpos($max, '0x')) { + if (str_starts_with($max, '0x')) { $max = \intval($max, 16); - } elseif (0 === strpos($max, '0')) { + } elseif (str_starts_with($max, '0')) { $max = \intval($max, 8); } else { $max = (int) $max; diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index f40c2fb9f6..2a3f6ce514 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -394,7 +394,7 @@ public function getName() */ protected function parseController($controller) { - if (\is_string($controller) && false !== strpos($controller, '::')) { + if (\is_string($controller) && str_contains($controller, '::')) { $controller = explode('::', $controller); } @@ -431,7 +431,7 @@ protected function parseController($controller) 'line' => $r->getStartLine(), ]; - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return $controller; } $controller['method'] = $r->name; diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index 79755a8ad7..27c71708b2 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -50,7 +50,7 @@ public function format($file, $line) { if ($fmt = $this->getFileLinkFormat()) { for ($i = 1; isset($fmt[$i]); ++$i) { - if (0 === strpos($file, $k = $fmt[$i++])) { + if (str_starts_with($file, $k = $fmt[$i++])) { $file = substr_replace($file, $fmt[$i], 0, \strlen($k)); break; } diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 17a5f7f02e..9825151ab0 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -62,7 +62,7 @@ private function expandClasses(array $patterns, array $classes): array // Explicit classes declared in the patterns are returned directly foreach ($patterns as $key => $pattern) { - if (!str_ends_with($pattern, '\\') && false === strpos($pattern, '*')) { + if (!str_ends_with($pattern, '\\') && !str_contains($pattern, '*')) { unset($patterns[$key]); $expanded[] = ltrim($pattern, '\\'); } @@ -127,10 +127,10 @@ private function patternsToRegexps(array $patterns): array private function matchAnyRegexps(string $class, array $regexps): bool { - $isTest = false !== strpos($class, 'Test'); + $isTest = str_contains($class, 'Test'); foreach ($regexps as $regex) { - if ($isTest && false === strpos($regex, 'Test')) { + if ($isTest && !str_contains($regex, 'Test')) { continue; } diff --git a/EventListener/AbstractTestSessionListener.php b/EventListener/AbstractTestSessionListener.php index 86f179add7..25be3b3907 100644 --- a/EventListener/AbstractTestSessionListener.php +++ b/EventListener/AbstractTestSessionListener.php @@ -81,7 +81,7 @@ public function onKernelResponse(FilterResponseEvent $event) if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) { $params = session_get_cookie_params() + ['samesite' => null]; foreach ($this->sessionOptions as $k => $v) { - if (0 === strpos($k, 'cookie_')) { + if (str_starts_with($k, 'cookie_')) { $params[substr($k, 7)] = $v; } } diff --git a/Exception/ControllerDoesNotReturnResponseException.php b/Exception/ControllerDoesNotReturnResponseException.php index 1e87690ff1..54c80be90f 100644 --- a/Exception/ControllerDoesNotReturnResponseException.php +++ b/Exception/ControllerDoesNotReturnResponseException.php @@ -38,7 +38,7 @@ public function __construct(string $message, callable $controller, string $file, private function parseControllerDefinition(callable $controller): ?array { - if (\is_string($controller) && false !== strpos($controller, '::')) { + if (\is_string($controller) && str_contains($controller, '::')) { $controller = explode('::', $controller); } diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 472d87e483..3385940243 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -57,7 +57,7 @@ public function hasSurrogateCapability(Request $request) return false; } - return false !== strpos($value, sprintf('%s/1.0', strtoupper($this->getName()))); + return str_contains($value, sprintf('%s/1.0', strtoupper($this->getName()))); } /** diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 0bad63e748..829f4ac643 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -37,7 +37,7 @@ public function getName() */ public function addSurrogateControl(Response $response) { - if (false !== strpos($response->getContent(), 'getContent(), 'headers->set('Surrogate-Control', 'content="ESI/1.0"'); } } diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 6dba4e11df..a2856f2760 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -34,7 +34,7 @@ public function getName() */ public function addSurrogateControl(Response $response) { - if (false !== strpos($response->getContent(), '