From 39a217598692e56b1b7b2de2542cfcfa92a78079 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 28 Feb 2018 14:53:23 -0800 Subject: [PATCH 001/294] updated VERSION for 2.7.42 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 159bde4d1b..9b7f5e6865 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.42-DEV'; + const VERSION = '2.7.42'; const VERSION_ID = 20742; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 42; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 7c876ad44735c2dc91d8cea8d4d5933072480750 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Mar 2018 06:32:34 -0800 Subject: [PATCH 002/294] bumped Symfony version to 2.7.43 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9b7f5e6865..fb24b4d650 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.42'; - const VERSION_ID = 20742; + const VERSION = '2.7.43-DEV'; + const VERSION_ID = 20743; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 42; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 43; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From ac0ee1442bf86c97f615116ae81920f4786c5b66 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Mar 2018 08:45:28 -0800 Subject: [PATCH 003/294] updated VERSION for 2.8.35 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7f61bdc645..df4421a131 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.35-DEV'; + const VERSION = '2.8.35'; const VERSION_ID = 20835; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 35; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From c44cc865857504eee594dd4c9bc34e1709257e1f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 1 Mar 2018 11:16:54 -0800 Subject: [PATCH 004/294] bumped Symfony version to 2.8.36 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index df4421a131..52b08bf2bc 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.35'; - const VERSION_ID = 20835; + const VERSION = '2.8.36-DEV'; + const VERSION_ID = 20836; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 35; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 36; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 11ef2d10a8d3218bd6db465030235bab35a8f370 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 10:32:00 -0800 Subject: [PATCH 005/294] updated VERSION for 2.7.43 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index fb24b4d650..a27a875f18 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.43-DEV'; + const VERSION = '2.7.43'; const VERSION_ID = 20743; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 43; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From e67fc2e471560873a5159119d3e878f6fe025625 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:05:22 -0800 Subject: [PATCH 006/294] bumped Symfony version to 2.7.44 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a27a875f18..ff57c10b47 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.43'; - const VERSION_ID = 20743; + const VERSION = '2.7.44-DEV'; + const VERSION_ID = 20744; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 43; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 44; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From ec519618d94b48b6d11f9861a902016ddc3c36e6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:06:26 -0800 Subject: [PATCH 007/294] updated VERSION for 2.8.36 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 52b08bf2bc..2ee1982875 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.36-DEV'; + const VERSION = '2.8.36'; const VERSION_ID = 20836; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 36; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 237027e950dec230a2c7191fb2ea9a7ab3e2a82c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 11:40:00 -0800 Subject: [PATCH 008/294] bumped Symfony version to 2.8.37 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 2ee1982875..cb055f5a67 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.36'; - const VERSION_ID = 20836; + const VERSION = '2.8.37-DEV'; + const VERSION_ID = 20837; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 36; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 37; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 66a0fe61ee7cb08eee94c5a5fc83378cce062cd4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Mar 2018 14:26:20 -0800 Subject: [PATCH 009/294] bumped Symfony version to 3.4.7 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 156a0f511f..f5b8cb7213 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.6'; - const VERSION_ID = 30406; + const VERSION = '3.4.7-DEV'; + const VERSION_ID = 30407; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 6; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 7; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From b100d75a4931d14e759b99c337c0901a14be8add Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 4 Feb 2018 17:33:12 +0100 Subject: [PATCH 010/294] Display the Welcome Page when there is no homepage defined --- 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 d8c37beb56..caac7fd6eb 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -76,7 +76,7 @@

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

From 178e5240da376d20fb067efd8c287e5b291fbe4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Sat, 17 Mar 2018 13:20:09 +0100 Subject: [PATCH 011/294] [HttpKernel] Allow generators in registerBundle --- KernelInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KernelInterface.php b/KernelInterface.php index b341e3e9fc..9ec4e7a9fc 100644 --- a/KernelInterface.php +++ b/KernelInterface.php @@ -27,7 +27,7 @@ interface KernelInterface extends HttpKernelInterface, \Serializable /** * Returns an array of bundles to register. * - * @return BundleInterface[] An array of bundle instances + * @return iterable|BundleInterface[] An iterable of bundle instances */ public function registerBundles(); From 15c2d2ff3c0d26d31bfb0a3dfeb25030623ecfe7 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Mon, 26 Mar 2018 19:04:09 +0200 Subject: [PATCH 012/294] [HttpKernel] DumpDataCollector: do not flush when a dumper is provided --- DataCollector/DumpDataCollector.php | 2 +- Tests/DataCollector/DumpDataCollectorTest.php | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 049053150f..a3880a6e8b 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -67,7 +67,7 @@ public function dump(Data $data) if ($this->stopwatch) { $this->stopwatch->start('dump'); } - if ($this->isCollected) { + if ($this->isCollected && !$this->dumper) { $this->isCollected = false; } diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index 23b1d87d1c..2dbb799109 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\CliDumper; /** * @author Nicolas Grekas @@ -130,4 +131,24 @@ public function testFlush() $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean()); } } + + public function testFlushNothingWhenDataDumperIsProvided() + { + $data = new Data(array(array(456))); + $dumper = new CliDumper('php://output'); + $collector = new DumpDataCollector(null, null, null, null, $dumper); + + ob_start(); + $collector->dump($data); + $line = __LINE__ - 1; + if (\PHP_VERSION_ID >= 50400) { + $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean()); + } else { + $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean()); + } + + ob_start(); + $collector->__destruct(); + $this->assertEmpty(ob_get_clean()); + } } From a466daf912d6434860b95a84556a254f656e3892 Mon Sep 17 00:00:00 2001 From: Chansig Date: Sat, 31 Mar 2018 09:59:49 +0200 Subject: [PATCH 013/294] [HttpCache] Unlink tmp file on error --- HttpCache/Store.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index fa0d4a8671..d20bfaa1b0 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -387,16 +387,22 @@ private function save($key, $data) $tmpFile = tempnam(dirname($path), basename($path)); if (false === $fp = @fopen($tmpFile, 'wb')) { + @unlink($tmpFile); + return false; } @fwrite($fp, $data); @fclose($fp); if ($data != file_get_contents($tmpFile)) { + @unlink($tmpFile); + return false; } if (false === @rename($tmpFile, $path)) { + @unlink($tmpFile); + return false; } } From 4a8ae13552673175b941c743c5afafe4caa51a35 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Apr 2018 11:53:22 +0200 Subject: [PATCH 014/294] updated VERSION for 2.7.44 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index ff57c10b47..6867adf518 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.44-DEV'; + const VERSION = '2.7.44'; const VERSION_ID = 20744; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 44; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 39ea54e1dad25601c3b39a116dfb9457bc2652b6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Apr 2018 13:31:07 +0200 Subject: [PATCH 015/294] bumped Symfony version to 2.7.45 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6867adf518..687760865b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.44'; - const VERSION_ID = 20744; + const VERSION = '2.7.45-DEV'; + const VERSION_ID = 20745; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 44; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 45; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From f780a1ff2c7a861816bd1e51e3c073abcb982d53 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Apr 2018 13:38:22 +0200 Subject: [PATCH 016/294] updated VERSION for 2.8.37 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index cb055f5a67..aba3e3c55b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.37-DEV'; + const VERSION = '2.8.37'; const VERSION_ID = 20837; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 37; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From ae96153d7ea55700524df84bd1a1e9bb7f8e8ead Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 2 Apr 2018 13:53:17 +0200 Subject: [PATCH 017/294] bumped Symfony version to 2.8.38 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index aba3e3c55b..defbf43974 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.37'; - const VERSION_ID = 20837; + const VERSION = '2.8.38-DEV'; + const VERSION_ID = 20838; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 37; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 38; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 476ddb34a21fa3864654bc36d2eb4003e65bbc66 Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Tue, 3 Apr 2018 01:34:16 +0300 Subject: [PATCH 018/294] Add PHPDbg support to HTTP components --- DataCollector/DumpDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index a3880a6e8b..8c312aaf09 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -246,7 +246,7 @@ public function __destruct() --$i; } - if ('cli' !== PHP_SAPI && stripos($h[$i], 'html')) { + if (!\in_array(PHP_SAPI, array('cli', 'phpdbg'), true) && stripos($h[$i], 'html')) { $this->dumper = new HtmlDumper('php://output', $this->charset); } else { $this->dumper = new CliDumper('php://output', $this->charset); From 43cfdad2ca1dba608662db0699c1bbb715d08191 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Apr 2018 07:49:44 +0200 Subject: [PATCH 019/294] updated VERSION for 3.4.7 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f5b8cb7213..d092db6a35 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.7-DEV'; + const VERSION = '3.4.7'; const VERSION_ID = 30407; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 7; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From bb16079e63ce187768788f4606a9a2da25c18add Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 3 Apr 2018 08:18:41 +0200 Subject: [PATCH 020/294] bumped Symfony version to 3.4.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d092db6a35..7cb3621744 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.7'; - const VERSION_ID = 30407; + const VERSION = '3.4.8-DEV'; + const VERSION_ID = 30408; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 7; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 8; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 7edf80042882273e77a965d1ca85d8bc14b23a46 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Apr 2018 12:04:49 +0200 Subject: [PATCH 021/294] [WebProfilerBundle][HttpKernel] Make FileLinkFormatter URL format generation lazy --- Debug/FileLinkFormatter.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index c340d9b672..1a72ac7e25 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -13,6 +13,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Routing\Exception\ExceptionInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Formats debug file links. @@ -26,6 +28,9 @@ class FileLinkFormatter implements \Serializable private $baseDir; private $urlFormat; + /** + * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand + */ public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) { $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); @@ -70,6 +75,18 @@ public function unserialize($serialized) } } + /** + * @internal + */ + public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString) + { + try { + return $router->generate($routeName).$queryString; + } catch (ExceptionInterface $e) { + return null; + } + } + private function getFileLinkFormat() { if ($this->fileLinkFormat) { @@ -78,6 +95,10 @@ private function getFileLinkFormat() if ($this->requestStack && $this->baseDir && $this->urlFormat) { $request = $this->requestStack->getMasterRequest(); if ($request instanceof Request) { + if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) { + return; + } + return array( $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, $this->baseDir.DIRECTORY_SEPARATOR, '', From 8b8f17fecc6931dd9ca1a1c37e2f8fafc8426596 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 6 Apr 2018 14:49:33 +0200 Subject: [PATCH 022/294] updated VERSION for 2.7.45 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 687760865b..ca42a5e299 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.45-DEV'; + const VERSION = '2.7.45'; const VERSION_ID = 20745; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 45; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 9f765d80d0b4020649152abccfaf9bfdaa44dc71 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 6 Apr 2018 16:50:48 +0200 Subject: [PATCH 023/294] bumped Symfony version to 2.7.46 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ca42a5e299..1b8abba147 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.45'; - const VERSION_ID = 20745; + const VERSION = '2.7.46-DEV'; + const VERSION_ID = 20746; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 45; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 46; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From f7dc6e2364d515ec83542e14982eea1cd2425ce1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 6 Apr 2018 16:52:08 +0200 Subject: [PATCH 024/294] updated VERSION for 2.8.38 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index defbf43974..3d54fdffcf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.38-DEV'; + const VERSION = '2.8.38'; const VERSION_ID = 20838; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 38; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 6e0b634ab6d7efa560cc31d50b7e875166dc94f9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 6 Apr 2018 17:19:00 +0200 Subject: [PATCH 025/294] bumped Symfony version to 2.8.39 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3d54fdffcf..3193b61e8b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.38'; - const VERSION_ID = 20838; + const VERSION = '2.8.39-DEV'; + const VERSION_ID = 20839; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 38; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 39; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 3cc2d4374aa9590c09277ad68657671cf49dbbf4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 6 Apr 2018 17:19:48 +0200 Subject: [PATCH 026/294] updated VERSION for 3.4.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7cb3621744..03cd708ebf 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.8-DEV'; + const VERSION = '3.4.8'; const VERSION_ID = 30408; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 8; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 0bbb650dad9e0809c8646ebd1636bc28e89f67ca Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 6 Apr 2018 18:24:29 +0200 Subject: [PATCH 027/294] bumped Symfony version to 3.4.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 03cd708ebf..0d68c4f7ff 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.8'; - const VERSION_ID = 30408; + const VERSION = '3.4.9-DEV'; + const VERSION_ID = 30409; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 8; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 9; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 642c63165eb754a199c7fb3821bf7b3c744cdec3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 7 Apr 2018 16:29:23 +0200 Subject: [PATCH 028/294] [HttpKernel] Dont create mock cookie for new sessions in tests --- EventListener/AbstractTestSessionListener.php | 2 +- Tests/EventListener/TestSessionListenerTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/EventListener/AbstractTestSessionListener.php b/EventListener/AbstractTestSessionListener.php index 0a153dd943..82061fd6ea 100644 --- a/EventListener/AbstractTestSessionListener.php +++ b/EventListener/AbstractTestSessionListener.php @@ -69,7 +69,7 @@ public function onKernelResponse(FilterResponseEvent $event) $session->save(); } - if ($session instanceof Session ? !$session->isEmpty() || $session->getId() !== $this->sessionId : $wasStarted) { + if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) { $params = session_get_cookie_params(); $event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'])); $this->sessionId = $session->getId(); diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index 0a2263d5a8..22a2b71239 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -13,7 +13,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; -use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -46,6 +45,9 @@ protected function setUp() { $this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener'); $this->session = $this->getSession(); + $this->listener->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($this->session)); } public function testShouldSaveMasterRequestSession() @@ -95,7 +97,7 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie() $this->fixSessionId('456'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('/', 'GET', array(), array(new Cookie('MOCKSESSID', '123'))); + $request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123')); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); From 739fa851b444f26e22a2ef861a9a32e422432c47 Mon Sep 17 00:00:00 2001 From: Mathieu TUDISCO Date: Tue, 3 Apr 2018 15:10:16 +0200 Subject: [PATCH 029/294] [HttpKernel] Make ServiceValueResolver work if controller namespace starts with a backslash in routing --- .../ArgumentResolver/ServiceValueResolver.php | 12 +++++++++++- .../ServiceValueResolverTest.php | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Controller/ArgumentResolver/ServiceValueResolver.php b/Controller/ArgumentResolver/ServiceValueResolver.php index c55564c046..7bc195f233 100644 --- a/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/Controller/ArgumentResolver/ServiceValueResolver.php @@ -39,9 +39,15 @@ public function supports(Request $request, ArgumentMetadata $argument) if (\is_array($controller) && \is_callable($controller, true) && \is_string($controller[0])) { $controller = $controller[0].'::'.$controller[1]; + } elseif (!\is_string($controller) || '' === $controller) { + return false; } - return \is_string($controller) && $this->container->has($controller) && $this->container->get($controller)->has($argument->getName()); + if ('\\' === $controller[0]) { + $controller = ltrim($controller, '\\'); + } + + return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName()); } /** @@ -53,6 +59,10 @@ public function resolve(Request $request, ArgumentMetadata $argument) $controller = $controller[0].'::'.$controller[1]; } + if ('\\' === $controller[0]) { + $controller = ltrim($controller, '\\'); + } + yield $this->container->get($controller)->get($argument->getName()); } } diff --git a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index b05828f5bf..7d34172ce3 100644 --- a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -47,6 +47,25 @@ public function testExistingController() $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); } + public function testExistingControllerWithATrailingBackSlash() + { + $resolver = new ServiceValueResolver(new ServiceLocator(array( + 'App\\Controller\\Mine::method' => function () { + return new ServiceLocator(array( + 'dummy' => function () { + return new DummyService(); + }, + )); + }, + ))); + + $request = $this->requestWithAttributes(array('_controller' => '\\App\\Controller\\Mine::method')); + $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); + + $this->assertTrue($resolver->supports($request, $argument)); + $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + } + public function testControllerNameIsAnArray() { $resolver = new ServiceValueResolver(new ServiceLocator(array( From 64afbfabad0b5481427363b0e41c168ec6b73035 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 22 Mar 2018 20:40:31 +0100 Subject: [PATCH 030/294] Fix that ESI/SSI processing can turn a \"private\" response \"public\" --- HttpCache/ResponseCacheStrategy.php | 2 +- Tests/HttpCache/ResponseCacheStrategyTest.php | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 027b2b1761..672cc893fe 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -72,7 +72,7 @@ public function update(Response $response) $response->setLastModified(null); } - if (!$response->isFresh()) { + if (!$response->isFresh() || !$response->isCacheable()) { $this->cacheable = false; } diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index 5e4c322223..6d67a17739 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -175,8 +175,26 @@ public function testEmbeddingPrivateResponseMakesMainResponsePrivate() $cacheStrategy->update($masterResponse); $this->assertTrue($masterResponse->headers->hasCacheControlDirective('private')); - // Not sure if we should pass "max-age: 60" in this case, as long as the response is private and - // that's the more conservative of both the master and embedded response...? + $this->assertFalse($masterResponse->headers->hasCacheControlDirective('public')); + } + + public function testEmbeddingPublicResponseDoesNotMakeMainResponsePublic() + { + $cacheStrategy = new ResponseCacheStrategy(); + + $masterResponse = new Response(); + $masterResponse->setPrivate(); // this is the default, but let's be explicit + $masterResponse->setMaxAge(100); + + $embeddedResponse = new Response(); + $embeddedResponse->setPublic(); + $embeddedResponse->setSharedMaxAge(100); + + $cacheStrategy->add($embeddedResponse); + $cacheStrategy->update($masterResponse); + + $this->assertTrue($masterResponse->headers->hasCacheControlDirective('private')); + $this->assertFalse($masterResponse->headers->hasCacheControlDirective('public')); } public function testResponseIsExiprableWhenEmbeddedResponseCombinesExpiryAndValidation() From d022ba4006434186ce486ee958e66b43a3226b2f Mon Sep 17 00:00:00 2001 From: cvilleger Date: Thu, 5 Apr 2018 14:19:22 +0200 Subject: [PATCH 031/294] [HttpFoundation] Add functional tests for Response::sendHeaders() --- Tests/ClientTest.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index 051d5d47c0..b774d8ec7a 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -60,22 +60,17 @@ public function testFilterResponseConvertsCookies() $m = $r->getMethod('filterResponse'); $m->setAccessible(true); - $expected = array( - 'foo=bar; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly', - 'foo1=bar1; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly', - ); - $response = new Response(); - $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); + $response->headers->setCookie($cookie1 = new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); + $this->assertSame((string) $cookie1, $domResponse->getHeader('Set-Cookie')); $response = new Response(); - $response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); - $response->headers->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); + $response->headers->setCookie($cookie1 = new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); + $response->headers->setCookie($cookie2 = new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); $domResponse = $m->invoke($client, $response); - $this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie')); - $this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false)); + $this->assertSame((string) $cookie1, $domResponse->getHeader('Set-Cookie')); + $this->assertSame(array((string) $cookie1, (string) $cookie2), $domResponse->getHeader('Set-Cookie', false)); } public function testFilterResponseSupportsStreamedResponses() From 667dd5750dcf2f91824f540beee13cc4b3900c84 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 25 Apr 2018 16:05:38 +0200 Subject: [PATCH 032/294] [VarDumper] Remove decoration from actual output in tests --- Tests/DataCollector/DumpDataCollectorTest.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index 2dbb799109..4c7cd9a51c 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -67,7 +67,7 @@ public function testCollectDefault() ob_start(); $collector->collect(new Request(), new Response()); - $output = ob_get_clean(); + $output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean()); if (\PHP_VERSION_ID >= 50400) { $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output); @@ -125,10 +125,11 @@ public function testFlush() ob_start(); $collector->__destruct(); + $output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean()); if (\PHP_VERSION_ID >= 50400) { - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean()); + $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output); } else { - $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean()); + $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", $output); } } @@ -141,10 +142,11 @@ public function testFlushNothingWhenDataDumperIsProvided() ob_start(); $collector->dump($data); $line = __LINE__ - 1; + $output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean()); if (\PHP_VERSION_ID >= 50400) { - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean()); + $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output); } else { - $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean()); + $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", $output); } ob_start(); From 4ed5b896f179339653ff2f70305b2d208fb3a535 Mon Sep 17 00:00:00 2001 From: Chris McCafferty Date: Sat, 10 Feb 2018 19:57:41 -0500 Subject: [PATCH 033/294] bug #25844 [HttpKernel] Catch HttpExceptions when templating is not installed --- EventListener/ExceptionListener.php | 14 +++++++++++--- Tests/EventListener/ExceptionListenerTest.php | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index f18e42c7d3..3dfa4cd8ea 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -12,9 +12,11 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; +use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; @@ -33,12 +35,14 @@ class ExceptionListener implements EventSubscriberInterface protected $controller; protected $logger; protected $debug; + private $charset; - public function __construct($controller, LoggerInterface $logger = null, $debug = false) + public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null) { $this->controller = $controller; $this->logger = $logger; $this->debug = $debug; + $this->charset = $charset; } public function onKernelException(GetResponseForExceptionEvent $event) @@ -117,8 +121,12 @@ protected function logException(\Exception $exception, $message) protected function duplicateRequest(\Exception $exception, Request $request) { $attributes = array( - '_controller' => $this->controller, - 'exception' => FlattenException::create($exception), + 'exception' => $exception = FlattenException::create($exception), + '_controller' => $this->controller ?: function () use ($exception) { + $handler = new ExceptionHandler($this->debug, $this->charset); + + return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders()); + }, 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, ); $request = $request->duplicate(null, null, $attributes); diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index 3cb0b298bb..b607bf900a 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -151,6 +151,23 @@ public function testCSPHeaderIsRemoved() $this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed'); $this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed'); } + + public function testNullController() + { + $listener = new ExceptionListener(null); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $controller = $request->attributes->get('_controller'); + + return $controller(); + })); + $request = Request::create('/'); + $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); + + $listener->onKernelException($event); + + $this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent()); + } } class TestLogger extends Logger implements DebugLoggerInterface From b974d6bb2d034e1e58994319bba4721a690c95a9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 26 Apr 2018 13:28:24 +0200 Subject: [PATCH 034/294] [HttpKernel] Don't clean legacy containers that are still loaded --- Kernel.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0d68c4f7ff..247bea208a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -670,9 +670,11 @@ protected function initializeContainer() // Because concurrent requests might still be using them, // old container files are not removed immediately, // but on a next dump of the container. + static $legacyContainers = array(); $oldContainerDir = dirname($oldContainer->getFileName()); - foreach (glob(dirname($oldContainerDir).'/*.legacy') as $legacyContainer) { - if ($oldContainerDir.'.legacy' !== $legacyContainer && @unlink($legacyContainer)) { + $legacyContainers[$oldContainerDir.'.legacy'] = true; + foreach (glob(dirname($oldContainerDir).DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) { + if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) { (new Filesystem())->remove(substr($legacyContainer, 0, -7)); } } From 980328e9ffa695acc6642890f642bed782930225 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 27 Apr 2018 07:41:32 +0200 Subject: [PATCH 035/294] updated VERSION for 2.7.46 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1b8abba147..43a441fbe2 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.46-DEV'; + const VERSION = '2.7.46'; const VERSION_ID = 20746; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 46; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 4c866d4a6991e01ea13262380536c029887d9aa2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 27 Apr 2018 11:17:42 +0200 Subject: [PATCH 036/294] bumped Symfony version to 2.7.47 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 43a441fbe2..33bbddabc9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.46'; - const VERSION_ID = 20746; + const VERSION = '2.7.47-DEV'; + const VERSION_ID = 20747; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 46; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 47; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From e9ac04d23ca9a34d8d54ad34d21f50fc3d121fde Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Apr 2018 07:52:51 +0200 Subject: [PATCH 037/294] updated VERSION for 2.8.39 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3193b61e8b..06f80811b0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.39-DEV'; + const VERSION = '2.8.39'; const VERSION_ID = 20839; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 39; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From e906d18852cf541f01441c1ff64cd49121a435e0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Apr 2018 08:11:59 +0200 Subject: [PATCH 038/294] bumped Symfony version to 2.8.40 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 06f80811b0..baeb200a6d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.39'; - const VERSION_ID = 20839; + const VERSION = '2.8.40-DEV'; + const VERSION_ID = 20840; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 39; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 40; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 280fcedbcb3dabcc467a9c1734054af61928fe4f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Apr 2018 21:27:02 +0200 Subject: [PATCH 039/294] updated VERSION for 3.4.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 247bea208a..f584242a16 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.9-DEV'; + const VERSION = '3.4.9'; const VERSION_ID = 30409; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 9; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 7936b1198e310595329c9ff0be1370734dde508f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Apr 2018 21:44:07 +0200 Subject: [PATCH 040/294] bumped Symfony version to 3.4.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f584242a16..f54d3589f7 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.9'; - const VERSION_ID = 30409; + const VERSION = '3.4.10-DEV'; + const VERSION_ID = 30410; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 9; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 10; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 2f49f362d21a1e3c5006a8cac3bad26eaf6970a8 Mon Sep 17 00:00:00 2001 From: Gert de Pagter Date: Tue, 1 May 2018 20:24:18 +0200 Subject: [PATCH 041/294] Use symfony/polyfill-ctype Use the polyfill for every package that uses cytpe functions. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 1b6b096a8a..6986945497 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "symfony/event-dispatcher": "^2.6.7", "symfony/http-foundation": "~2.7.36|^2.8.29", "symfony/debug": "^2.6.2", + "symfony/polyfill-ctype": "~1.8", "psr/log": "~1.0" }, "require-dev": { From f7a14a8a0405b86a04acdb034a39f750a01d32dc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 10 May 2018 11:44:29 -0700 Subject: [PATCH 042/294] [HttpKernel] Handle NoConfigurationException "onKernelException()" --- EventListener/RouterListener.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index caaf80f86b..959f2ba0d1 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -14,6 +14,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\KernelEvents; @@ -129,12 +130,6 @@ public function onKernelRequest(GetResponseEvent $event) unset($parameters['_route'], $parameters['_controller']); $request->attributes->set('_route_params', $parameters); } catch (ResourceNotFoundException $e) { - if ($this->debug && $e instanceof NoConfigurationException) { - $event->setResponse($this->createWelcomeResponse()); - - return; - } - $message = sprintf('No route found for "%s %s"', $request->getMethod(), $request->getPathInfo()); if ($referer = $request->headers->get('referer')) { @@ -149,11 +144,23 @@ public function onKernelRequest(GetResponseEvent $event) } } + public function onKernelException(GetResponseForExceptionEvent $event) + { + if (!$this->debug || !($e = $event->getException()) instanceof NotFoundHttpException) { + return; + } + + if ($e->getPrevious() instanceof NoConfigurationException) { + $event->setResponse($this->createWelcomeResponse()); + } + } + public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => array(array('onKernelRequest', 32)), KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), + KernelEvents::EXCEPTION => array('onKernelException', -64), ); } From 8a01e6bf0f830e587221fad323a14d39a6621b28 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 13 May 2018 13:51:16 +0200 Subject: [PATCH 043/294] [HttpKernel] do file_exists() check instead of silent notice --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f54d3589f7..b5e5a2b5ca 100644 --- a/Kernel.php +++ b/Kernel.php @@ -587,7 +587,7 @@ protected function initializeContainer() $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); $fresh = $oldContainer = false; try { - if (\is_object($this->container = include $cache->getPath())) { + if (file_exists($cache->getPath()) && \is_object($this->container = include $cache->getPath())) { $this->container->set('kernel', $this); $oldContainer = $this->container; $fresh = true; @@ -650,7 +650,7 @@ protected function initializeContainer() } } - if (null === $oldContainer) { + if (null === $oldContainer && file_exists($cache->getPath())) { $errorLevel = error_reporting(\E_ALL ^ \E_WARNING); try { $oldContainer = include $cache->getPath(); From a424955fc9bdd75a8590cfe984678f05e7fb858f Mon Sep 17 00:00:00 2001 From: ncou Date: Mon, 14 May 2018 10:51:37 +0200 Subject: [PATCH 044/294] Cleanup 2 tests for the HttpException classes --- .../UnprocessableEntityHttpExceptionTest.php | 15 --------------- .../UnsupportedMediaTypeHttpExceptionTest.php | 12 +----------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/Tests/Exception/UnprocessableEntityHttpExceptionTest.php index 760366c694..05d8d787aa 100644 --- a/Tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ b/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -6,21 +6,6 @@ class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest { - /** - * Test that setting the headers using the setter function - * is working as expected. - * - * @param array $headers The headers to set - * - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = new UnprocessableEntityHttpException(10); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - protected function createException() { return new UnprocessableEntityHttpException(); diff --git a/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php index d47287a1fb..4dae039c11 100644 --- a/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php +++ b/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -6,17 +6,7 @@ class UnsupportedMediaTypeHttpExceptionTest extends HttpExceptionTest { - /** - * @dataProvider headerDataProvider - */ - public function testHeadersSetter($headers) - { - $exception = new UnsupportedMediaTypeHttpException(10); - $exception->setHeaders($headers); - $this->assertSame($headers, $exception->getHeaders()); - } - - protected function createException($headers = array()) + protected function createException() { return new UnsupportedMediaTypeHttpException(); } From 3eaad09082fb6d08b22a984bf6251f146e40f156 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 11 May 2018 17:58:37 +0200 Subject: [PATCH 045/294] fixed CS --- .../ArgumentMetadataFactory.php | 28 +++++++++++++------ Profiler/Profiler.php | 2 +- .../ArgumentMetadataFactoryTest.php | 4 +-- Tests/Profiler/ProfilerTest.php | 2 +- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ControllerMetadata/ArgumentMetadataFactory.php b/ControllerMetadata/ArgumentMetadataFactory.php index d1e7af2068..0424850e14 100644 --- a/ControllerMetadata/ArgumentMetadataFactory.php +++ b/ControllerMetadata/ArgumentMetadataFactory.php @@ -58,7 +58,7 @@ public function createArgumentMetadata($controller) } foreach ($reflection->getParameters() as $param) { - $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $param->allowsNull()); + $arguments[] = new ArgumentMetadata($param->getName(), $this->getType($param, $reflection), $this->isVariadic($param), $this->hasDefaultValue($param), $this->getDefaultValue($param), $param->allowsNull()); } return $arguments; @@ -107,23 +107,35 @@ private function getDefaultValue(\ReflectionParameter $parameter) * * @return null|string */ - private function getType(\ReflectionParameter $parameter) + private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function) { if ($this->supportsParameterType) { if (!$type = $parameter->getType()) { return; } - $typeName = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); - if ('array' === $typeName && !$type->isBuiltin()) { + $name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); + if ('array' === $name && !$type->isBuiltin()) { // Special case for HHVM with variadics return; } - - return $typeName; + } elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $name)) { + $name = $name[1]; + } else { + return; } + $lcName = strtolower($name); - if (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $parameter, $info)) { - return $info[1]; + if ('self' !== $lcName && 'parent' !== $lcName) { + return $name; + } + if (!$function instanceof \ReflectionMethod) { + return; + } + if ('self' === $lcName) { + return $function->getDeclaringClass()->name; + } + if ($parent = $function->getDeclaringClass()->getParentClass()) { + return $parent->name; } } } diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index 15bfbc5a07..6245a21b5f 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -37,7 +37,7 @@ class Profiler private $enabled = true; /** - * @param bool $enable The initial enabled state + * @param bool $enable The initial enabled state */ public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, $enable = true) { diff --git a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index b4b449f358..bf0db5ad56 100644 --- a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -126,11 +126,11 @@ public function testNullableTypesSignature() ), $arguments); } - private function signature1(ArgumentMetadataFactoryTest $foo, array $bar, callable $baz) + private function signature1(self $foo, array $bar, callable $baz) { } - private function signature2(ArgumentMetadataFactoryTest $foo = null, FakeClassThatDoesNotExist $bar = null, ImportedAndFake $baz = null) + private function signature2(self $foo = null, FakeClassThatDoesNotExist $bar = null, ImportedAndFake $baz = null) { } diff --git a/Tests/Profiler/ProfilerTest.php b/Tests/Profiler/ProfilerTest.php index 243c3c5c5a..2d5f0ca5ad 100644 --- a/Tests/Profiler/ProfilerTest.php +++ b/Tests/Profiler/ProfilerTest.php @@ -44,7 +44,7 @@ public function testCollect() public function testReset() { $collector = $this->getMockBuilder(DataCollectorInterface::class) - ->setMethods(['collect', 'getName', 'reset']) + ->setMethods(array('collect', 'getName', 'reset')) ->getMock(); $collector->expects($this->any())->method('getName')->willReturn('mock'); $collector->expects($this->once())->method('reset'); From 9e97822dc057d57709d7929f5a13fc8778037a95 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 21 May 2018 15:17:29 +0200 Subject: [PATCH 046/294] updated VERSION for 2.8.40 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index baeb200a6d..1eee70532a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.40-DEV'; + const VERSION = '2.8.40'; const VERSION_ID = 20840; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 40; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 788e259f8be2098c760744daf87e4db2b097062c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 21 May 2018 15:43:22 +0200 Subject: [PATCH 047/294] bumped Symfony version to 2.8.41 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1eee70532a..70038526fa 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.40'; - const VERSION_ID = 20840; + const VERSION = '2.8.41-DEV'; + const VERSION_ID = 20841; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 40; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 41; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 66644bc7d17cc071d796efab9b950adbb86da134 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 21 May 2018 15:44:03 +0200 Subject: [PATCH 048/294] updated VERSION for 3.4.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b5e5a2b5ca..abd7f74a03 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.10-DEV'; + const VERSION = '3.4.10'; const VERSION_ID = 30410; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 10; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 2e207d6d0a3f2a15eb84593a5754e2b4ccd6915e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 21 May 2018 16:00:59 +0200 Subject: [PATCH 049/294] bumped Symfony version to 3.4.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index abd7f74a03..5e3b9a8578 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.10'; - const VERSION_ID = 30410; + const VERSION = '3.4.11-DEV'; + const VERSION_ID = 30411; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 10; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 11; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From b8c0ae53cae5d1ab4d34d8e963e30ccf6bc143df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 25 May 2018 14:02:50 +0200 Subject: [PATCH 050/294] updated VERSION for 2.8.41 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 70038526fa..d7ac3985b4 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.41-DEV'; + const VERSION = '2.8.41'; const VERSION_ID = 20841; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 41; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 4854e8aaf0ef6612c0582224a160e85f16abdc4c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 25 May 2018 14:30:40 +0200 Subject: [PATCH 051/294] bumped Symfony version to 2.8.42 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d7ac3985b4..0e298381b9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.41'; - const VERSION_ID = 20841; + const VERSION = '2.8.42-DEV'; + const VERSION_ID = 20842; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 41; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 42; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 3dac45df55ee0c5134c457a730cd68e2a2ce0445 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 25 May 2018 15:16:28 +0200 Subject: [PATCH 052/294] updated VERSION for 3.4.11 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 5e3b9a8578..ca0f0b95c7 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.11-DEV'; + const VERSION = '3.4.11'; const VERSION_ID = 30411; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 11; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 9f17904ae4c127df57852bbc934415a639f5ef2e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 25 May 2018 15:32:08 +0200 Subject: [PATCH 053/294] bumped Symfony version to 3.4.12 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ca0f0b95c7..242016f7c0 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.11'; - const VERSION_ID = 30411; + const VERSION = '3.4.12-DEV'; + const VERSION_ID = 30412; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 11; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 12; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From ba0c8eb4bb0ffd5f77985a3c5a616c3b88f034a5 Mon Sep 17 00:00:00 2001 From: kiler129 Date: Tue, 22 May 2018 22:00:46 -0500 Subject: [PATCH 054/294] [HttpKernel] reset kernel start time on reboot --- Kernel.php | 12 ++++-------- Tests/KernelTest.php | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Kernel.php b/Kernel.php index 5e3b9a8578..9806e240f7 100644 --- a/Kernel.php +++ b/Kernel.php @@ -87,18 +87,10 @@ public function __construct($environment, $debug) $this->debug = (bool) $debug; $this->rootDir = $this->getRootDir(); $this->name = $this->getName(); - - if ($this->debug) { - $this->startTime = microtime(true); - } } public function __clone() { - if ($this->debug) { - $this->startTime = microtime(true); - } - $this->booted = false; $this->container = null; $this->requestStackSize = 0; @@ -110,6 +102,10 @@ public function __clone() */ public function boot() { + if ($this->debug) { + $this->startTime = microtime(true); + } + if (true === $this->booted) { if (!$this->requestStackSize && $this->resetServices) { if ($this->container->has('services_resetter')) { diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index a16ac37dee..628be627fd 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -901,6 +901,21 @@ public function testServicesResetter() $this->assertEquals(1, ResettableService::$counter); } + /** + * @group time-sensitive + */ + public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() + { + $kernel = $this->getKernelForTest(array('initializeBundles'), true); + $kernel->boot(); + $preReBoot = $kernel->getStartTime(); + + sleep(3600); //Intentionally large value to detect if ClockMock ever breaks + $kernel->boot(); + + $this->assertGreaterThan($preReBoot, $kernel->getStartTime()); + } + /** * Returns a mock for the BundleInterface. * @@ -970,10 +985,10 @@ protected function getKernel(array $methods = array(), array $bundles = array()) return $kernel; } - protected function getKernelForTest(array $methods = array()) + protected function getKernelForTest(array $methods = array(), $debug = false) { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setConstructorArgs(array('test', false)) + ->setConstructorArgs(array('test', $debug)) ->setMethods($methods) ->getMock(); $p = new \ReflectionProperty($kernel, 'rootDir'); From 3e9a7a8afe4d65903d6d5cb239cf1a19ebf3f9b5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 25 May 2018 17:06:28 +0200 Subject: [PATCH 055/294] [HttpKernel] Dont reset start time when not needed --- Kernel.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 143006e4b1..948c30a495 100644 --- a/Kernel.php +++ b/Kernel.php @@ -102,20 +102,22 @@ public function __clone() */ public function boot() { - if ($this->debug) { - $this->startTime = microtime(true); - } - if (true === $this->booted) { if (!$this->requestStackSize && $this->resetServices) { if ($this->container->has('services_resetter')) { $this->container->get('services_resetter')->reset(); } $this->resetServices = false; + if ($this->debug) { + $this->startTime = microtime(true); + } } return; } + if ($this->debug) { + $this->startTime = microtime(true); + } if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) { putenv('SHELL_VERBOSITY=3'); $_ENV['SHELL_VERBOSITY'] = 3; From 49b12be305779ab0d599c5dc19b5b4a8f3010c1f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 25 May 2018 17:22:00 +0200 Subject: [PATCH 056/294] [HttpKernel] fix test --- Tests/KernelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 628be627fd..7cde2ac5e2 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -911,7 +911,7 @@ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() $preReBoot = $kernel->getStartTime(); sleep(3600); //Intentionally large value to detect if ClockMock ever breaks - $kernel->boot(); + $kernel->reboot(null); $this->assertGreaterThan($preReBoot, $kernel->getStartTime()); } From 71a7dda135fddf3188a77729ae6ca85adf59221a Mon Sep 17 00:00:00 2001 From: Kamil Madejski Date: Wed, 18 Apr 2018 13:57:06 +0200 Subject: [PATCH 057/294] [HttpKernel] Set first trusted proxy as REMOTE_ADDR in InlineFragmentRenderer. --- Fragment/InlineFragmentRenderer.php | 4 +++- Tests/Fragment/InlineFragmentRendererTest.php | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index 17ed967fb5..76c8e95d79 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -122,7 +122,9 @@ protected function createSubRequest($uri, Request $request) // Do nothing } - $server['REMOTE_ADDR'] = '127.0.0.1'; + $trustedProxies = Request::getTrustedProxies(); + $server['REMOTE_ADDR'] = $trustedProxies ? reset($trustedProxies) : '127.0.0.1'; + unset($server['HTTP_IF_MODIFIED_SINCE']); unset($server['HTTP_IF_NONE_MATCH']); diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 4c1d6a00c4..6ed3c86537 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -56,6 +56,7 @@ public function testRenderWithObjectsAsAttributes() $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $subRequest->server->set('REMOTE_ADDR', '1.1.1.1'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); @@ -84,7 +85,7 @@ public function testRenderWithTrustedHeaderDisabled() { Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')))); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); } @@ -168,6 +169,7 @@ public function testESIHeaderIsKeptInSubrequest() { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); @@ -193,7 +195,7 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled() public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() { - $expectedSubRequest = Request::create('/'); + $expectedSubRequest = Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); From 386394370451f20265b037a074a6244244d946b1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 28 May 2018 17:16:05 +0200 Subject: [PATCH 058/294] [HttpKernel] fix registering IDE links --- EventListener/ExceptionListener.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index 3dfa4cd8ea..4d8ad1e7e5 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -36,13 +36,15 @@ class ExceptionListener implements EventSubscriberInterface protected $logger; protected $debug; private $charset; + private $fileLinkFormat; - public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null) + public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null, $fileLinkFormat = null) { $this->controller = $controller; $this->logger = $logger; $this->debug = $debug; $this->charset = $charset; + $this->fileLinkFormat = $fileLinkFormat; } public function onKernelException(GetResponseForExceptionEvent $event) @@ -123,7 +125,7 @@ protected function duplicateRequest(\Exception $exception, Request $request) $attributes = array( 'exception' => $exception = FlattenException::create($exception), '_controller' => $this->controller ?: function () use ($exception) { - $handler = new ExceptionHandler($this->debug, $this->charset); + $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat); return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders()); }, From 31fdb01867d37fd0f2aab5d2bc2e704df480f474 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 31 May 2018 12:02:37 +0200 Subject: [PATCH 059/294] [HttpKernel] Fix restoring trusted proxies in tests --- .../ValidateRequestListenerTest.php | 5 ++++ Tests/Fragment/InlineFragmentRendererTest.php | 28 ++++++++++++++++--- Tests/HttpCache/HttpCacheTest.php | 2 ++ Tests/HttpKernelTest.php | 2 ++ 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Tests/EventListener/ValidateRequestListenerTest.php b/Tests/EventListener/ValidateRequestListenerTest.php index 55dc59e13f..388f1b814b 100644 --- a/Tests/EventListener/ValidateRequestListenerTest.php +++ b/Tests/EventListener/ValidateRequestListenerTest.php @@ -21,6 +21,11 @@ class ValidateRequestListenerTest extends TestCase { + protected function tearDown() + { + Request::setTrustedProxies(array()); + } + /** * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException */ diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 6ed3c86537..998b372181 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -56,7 +56,6 @@ public function testRenderWithObjectsAsAttributes() $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - $subRequest->server->set('REMOTE_ADDR', '1.1.1.1'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); @@ -85,7 +84,7 @@ public function testRenderWithTrustedHeaderDisabled() { Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')))); + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); } @@ -169,7 +168,6 @@ public function testESIHeaderIsKeptInSubrequest() { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); @@ -195,7 +193,7 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled() public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() { - $expectedSubRequest = Request::create('/', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '1.1.1.1')); + $expectedSubRequest = Request::create('/'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); @@ -206,6 +204,28 @@ public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() $strategy->render('/', $request); } + public function testFirstTrustedProxyIsSetAsRemote() + { + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); + + if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + } + + Request::setTrustedProxies(array('1.1.1.1')); + + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); + + $request = Request::create('/'); + $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $strategy->render('/', $request); + + Request::setTrustedProxies(array()); + } + /** * Creates a Kernel expecting a request equals to $request * Allows delta in comparison in case REQUEST_TIME changed by 1 second. diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index d6902f4880..41c2d57833 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -1315,6 +1315,8 @@ public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expect $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); $this->assertEquals($expected, Request::getTrustedProxies()); + + Request::setTrustedProxies(array()); } public function getTrustedProxyData() diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 448dc10cf1..22d9907e5c 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -291,6 +291,8 @@ public function testInconsistentClientIpsOnMasterRequests() $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); $kernel->handle($request, $kernel::MASTER_REQUEST, false); + + Request::setTrustedProxies(array()); } protected function getResolver($controller = null) From 89b519cac85313d292b2cf2df2a2e864796a4cbd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 1 Jun 2018 14:37:16 +0200 Subject: [PATCH 060/294] [HttpKernel] fix session tracking in surrogate master requests --- EventListener/AbstractSessionListener.php | 17 ++++++++- Tests/EventListener/SessionListenerTest.php | 38 +++++++++++++++++++-- composer.json | 2 +- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index dff29ee80b..a54ca62d87 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -25,6 +26,8 @@ */ abstract class AbstractSessionListener implements EventSubscriberInterface { + private $sessionUsageStack = array(); + public function onKernelRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { @@ -33,6 +36,7 @@ public function onKernelRequest(GetResponseEvent $event) $request = $event->getRequest(); $session = $this->getSession(); + $this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : null; if (null === $session || $request->hasSession()) { return; } @@ -50,7 +54,7 @@ public function onKernelResponse(FilterResponseEvent $event) return; } - if ($session->isStarted() || ($session instanceof Session && $session->hasBeenStarted())) { + if ($session instanceof Session ? $session->getUsageIndex() !== end($this->sessionUsageStack) : $session->isStarted()) { $event->getResponse() ->setPrivate() ->setMaxAge(0) @@ -58,12 +62,23 @@ public function onKernelResponse(FilterResponseEvent $event) } } + /** + * @internal + */ + public function onFinishRequest(FinishRequestEvent $event) + { + if ($event->isMasterRequest()) { + array_pop($this->sessionUsageStack); + } + } + public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => array('onKernelRequest', 128), // low priority to come after regular response listeners, same as SaveSessionListener KernelEvents::RESPONSE => array('onKernelResponse', -1000), + KernelEvents::FINISH_REQUEST => array('onFinishRequest'), ); } diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 34598363c8..a6416e7f69 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; use Symfony\Component\HttpKernel\EventListener\SessionListener; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -58,8 +59,7 @@ public function testSessionIsSet() public function testResponseIsPrivate() { $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); - $session->expects($this->once())->method('isStarted')->willReturn(false); - $session->expects($this->once())->method('hasBeenStarted')->willReturn(true); + $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1)); $container = new Container(); $container->set('session', $session); @@ -76,4 +76,38 @@ public function testResponseIsPrivate() $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate')); $this->assertSame('0', $response->headers->getCacheControlDirective('max-age')); } + + public function testSurrogateMasterRequestIsPublic() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->expects($this->exactly(4))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1, 1, 1)); + + $container = new Container(); + $container->set('session', $session); + + $listener = new SessionListener($container); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + + $request = new Request(); + $response = new Response(); + $response->setCache(array('public' => true, 'max_age' => '30')); + $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + $this->assertTrue($request->hasSession()); + + $subRequest = clone $request; + $this->assertSame($request->getSession(), $subRequest->getSession()); + $listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST)); + $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST, $response)); + $listener->onFinishRequest(new FinishRequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST)); + + $this->assertFalse($response->headers->hasCacheControlDirective('private')); + $this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate')); + $this->assertSame('30', $response->headers->getCacheControlDirective('max-age')); + + $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); + + $this->assertTrue($response->headers->hasCacheControlDirective('private')); + $this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate')); + $this->assertSame('0', $response->headers->getCacheControlDirective('max-age')); + } } diff --git a/composer.json b/composer.json index 17c0544c62..585ab5b37d 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^5.5.9|>=7.0.8", "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "^3.4.4|^4.0.4", + "symfony/http-foundation": "~3.4.12|~4.0.12|^4.1.1", "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-ctype": "~1.8", "psr/log": "~1.0" From 0d6ad20e35cfdef456406a37bac3c113597b321d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 6 Jun 2018 11:42:07 +0200 Subject: [PATCH 061/294] Revert "bug #26138 [HttpKernel] Catch HttpExceptions when templating is not installed (cilefen)" This reverts commit b213c5a758bc8b02375bd388b52b351c7e862f6a, reversing changes made to 61af0e3a25fbb2d169999a5b550c1f1801f1c0de. --- EventListener/ExceptionListener.php | 16 +++------------- Tests/EventListener/ExceptionListenerTest.php | 17 ----------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index 4d8ad1e7e5..f18e42c7d3 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -12,11 +12,9 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; -use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; @@ -35,16 +33,12 @@ class ExceptionListener implements EventSubscriberInterface protected $controller; protected $logger; protected $debug; - private $charset; - private $fileLinkFormat; - public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null, $fileLinkFormat = null) + public function __construct($controller, LoggerInterface $logger = null, $debug = false) { $this->controller = $controller; $this->logger = $logger; $this->debug = $debug; - $this->charset = $charset; - $this->fileLinkFormat = $fileLinkFormat; } public function onKernelException(GetResponseForExceptionEvent $event) @@ -123,12 +117,8 @@ protected function logException(\Exception $exception, $message) protected function duplicateRequest(\Exception $exception, Request $request) { $attributes = array( - 'exception' => $exception = FlattenException::create($exception), - '_controller' => $this->controller ?: function () use ($exception) { - $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat); - - return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders()); - }, + '_controller' => $this->controller, + 'exception' => FlattenException::create($exception), 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, ); $request = $request->duplicate(null, null, $attributes); diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index b607bf900a..3cb0b298bb 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -151,23 +151,6 @@ public function testCSPHeaderIsRemoved() $this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed'); $this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed'); } - - public function testNullController() - { - $listener = new ExceptionListener(null); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { - $controller = $request->attributes->get('_controller'); - - return $controller(); - })); - $request = Request::create('/'); - $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); - - $listener->onKernelException($event); - - $this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent()); - } } class TestLogger extends Logger implements DebugLoggerInterface From 82c8b12aad2d472ace0f123c06813b67fb12d852 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 16 Jun 2018 10:34:48 +0200 Subject: [PATCH 062/294] [HttpKernel] Fix resetting DumpDataCollector::$isCollected --- DataCollector/DumpDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 27a9a82524..be06a61c40 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -171,7 +171,7 @@ public function reset() } $this->data = array(); $this->dataCount = 0; - $this->isCollected = false; + $this->isCollected = true; $this->clonesCount = 0; $this->clonesIndex = 0; } From 6d999733756f5e746f6140a779ac2c771ee76b42 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Fri, 18 May 2018 16:21:08 +0200 Subject: [PATCH 063/294] Fix surrogate not using original request --- HttpCache/HttpCache.php | 6 ++++- Tests/HttpCache/HttpCacheTest.php | 39 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index 81c75ff740..6f46787698 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -185,7 +185,11 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism if (HttpKernelInterface::MASTER_REQUEST === $type) { $this->traces = array(); - $this->request = $request; + // Keep a clone of the original request for surrogates so they can access it. + // We must clone here to get a separate instance because the application will modify the request during + // the application flow (we know it always does because we do ourselves by setting REMOTE_ADDR to 127.0.0.1 + // and adding the X-Forwarded-For header, see HttpCache::forward()). + $this->request = clone $request; if (null !== $this->surrogate) { $this->surrogateCacheStrategy = $this->surrogate->createCacheStrategy(); } diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 41c2d57833..ab584a9871 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -11,9 +11,12 @@ namespace Symfony\Component\HttpKernel\Tests\HttpCache; +use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpCache\Store; +use Symfony\Component\HttpKernel\HttpCache\StoreInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; /** @@ -1432,6 +1435,42 @@ public function testDoesNotCacheOptionsRequest() $this->assertHttpKernelIsNotCalled(); $this->assertSame('get', $this->response->getContent()); } + + public function testUsesOriginalRequestForSurrogate() + { + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); + $store = $this->getMockBuilder(StoreInterface::class)->getMock(); + + $kernel + ->expects($this->exactly(2)) + ->method('handle') + ->willReturnCallback(function (Request $request) { + $this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); + + return new Response(); + }); + + $cache = new HttpCache($kernel, + $store, + new Esi() + ); + + $request = Request::create('/'); + $request->server->set('REMOTE_ADDR', '10.0.0.1'); + + // Main request + $cache->handle($request, HttpKernelInterface::MASTER_REQUEST); + + // Main request was now modified by HttpCache + // The surrogate will ask for the request using $this->cache->getRequest() + // which MUST return the original request so the surrogate + // can actually behave like a reverse proxy like e.g. Varnish would. + $this->assertSame('10.0.0.1', $cache->getRequest()->getClientIp()); + $this->assertSame('10.0.0.1', $cache->getRequest()->server->get('REMOTE_ADDR')); + + // Surrogate request + $cache->handle($request, HttpKernelInterface::SUB_REQUEST); + } } class TestKernel implements HttpKernelInterface From 382e74c6c30c7be2a7d23db99a80901e48821854 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 19 Jun 2018 22:37:28 +0200 Subject: [PATCH 064/294] [HttpKernel] fix PHP 5.4 compat --- Tests/HttpCache/HttpCacheTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index ab584a9871..2c2d015dc9 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -16,7 +16,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\HttpCache\Store; -use Symfony\Component\HttpKernel\HttpCache\StoreInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; /** @@ -1438,8 +1437,8 @@ public function testDoesNotCacheOptionsRequest() public function testUsesOriginalRequestForSurrogate() { - $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); - $store = $this->getMockBuilder(StoreInterface::class)->getMock(); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock(); $kernel ->expects($this->exactly(2)) From 3ebef47692d85107b2f77c8f28e10f4f9abb2985 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 20 Jun 2018 21:52:27 +0200 Subject: [PATCH 065/294] fix handling of nested Error instances --- EventListener/ExceptionListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index f18e42c7d3..983f1c2b8f 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -64,7 +64,7 @@ public function onKernelException(GetResponseForExceptionEvent $event) } } - $prev = new \ReflectionProperty('Exception', 'previous'); + $prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous'); $prev->setAccessible(true); $prev->setValue($wrapper, $exception); From 0cd1ffbfdadf3a6bad053ec3aab14a9e1cb07a27 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 21 Jun 2018 13:07:36 +0200 Subject: [PATCH 066/294] [HttpKernel] fix test compat with PHP 5.3 --- Tests/HttpCache/HttpCacheTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 2c2d015dc9..f5b4000246 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -1440,11 +1440,12 @@ public function testUsesOriginalRequestForSurrogate() $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock(); + $that = $this; $kernel ->expects($this->exactly(2)) ->method('handle') - ->willReturnCallback(function (Request $request) { - $this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); + ->willReturnCallback(function (Request $request) use ($that) { + $that->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); return new Response(); }); From 5f01e7b4a82458906e81231993abe1fbb7b25fbc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jun 2018 14:01:56 +0200 Subject: [PATCH 067/294] updated VERSION for 2.8.42 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0e298381b9..e628f1f359 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.42-DEV'; + const VERSION = '2.8.42'; const VERSION_ID = 20842; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 42; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 882e3757167d1faf3ab99a9e4a822fdf4199cb92 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jun 2018 14:28:20 +0200 Subject: [PATCH 068/294] bumped Symfony version to 2.8.43 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index e628f1f359..10ff79297b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.42'; - const VERSION_ID = 20842; + const VERSION = '2.8.43-DEV'; + const VERSION_ID = 20843; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 42; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 43; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From cb7edcdc47cab3c61c891e6e55337f8dd470d820 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jun 2018 14:29:19 +0200 Subject: [PATCH 069/294] updated VERSION for 3.4.12 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 948c30a495..3c740e45ef 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.12-DEV'; + const VERSION = '3.4.12'; const VERSION_ID = 30412; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 12; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From c297d2dab02dc02117014e3e28550ccaffa2cb35 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jun 2018 15:00:40 +0200 Subject: [PATCH 070/294] bumped Symfony version to 3.4.13 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3c740e45ef..9668b9ecd1 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.12'; - const VERSION_ID = 30412; + const VERSION = '3.4.13-DEV'; + const VERSION_ID = 30413; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 12; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 13; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From c68aac9c0d221826e6511466a182c4c990df96bd Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Wed, 20 Jun 2018 16:02:10 +0100 Subject: [PATCH 071/294] [HttpKernel] Make AbstractTestSessionListener compatible with CookieClearingLogoutHandler --- EventListener/AbstractTestSessionListener.php | 7 ++++ .../EventListener/TestSessionListenerTest.php | 34 +++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/EventListener/AbstractTestSessionListener.php b/EventListener/AbstractTestSessionListener.php index 82061fd6ea..75f810e988 100644 --- a/EventListener/AbstractTestSessionListener.php +++ b/EventListener/AbstractTestSessionListener.php @@ -71,6 +71,13 @@ public function onKernelResponse(FilterResponseEvent $event) if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) { $params = session_get_cookie_params(); + + foreach ($event->getResponse()->headers->getCookies() as $cookie) { + if ($session->getName() === $cookie->getName() && $params['path'] === $cookie->getPath() && $params['domain'] == $cookie->getDomain()) { + return; + } + } + $event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'])); $this->sessionId = $session->getId(); } diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index 22a2b71239..01f0a3b864 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -106,6 +106,36 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie() $this->assertNotEmpty($response->headers->getCookies()); } + /** + * @dataProvider anotherCookieProvider + */ + public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie($existing, array $expected) + { + $this->sessionHasBeenStarted(); + $this->sessionIsEmpty(); + $this->fixSessionId('456'); + + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123')); + $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); + $this->listener->onKernelRequest($event); + + $response = new Response('', 200, array('Set-Cookie' => $existing)); + + $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST, $response); + + $this->assertSame($expected, $response->headers->get('Set-Cookie', null, false)); + } + + public function anotherCookieProvider() + { + return array( + 'same' => array('MOCKSESSID=789; path=/', array('MOCKSESSID=789; path=/')), + 'different domain' => array('MOCKSESSID=789; path=/; domain=example.com', array('MOCKSESSID=789; path=/; domain=example.com', 'MOCKSESSID=456; path=/')), + 'different path' => array('MOCKSESSID=789; path=/foo', array('MOCKSESSID=789; path=/foo', 'MOCKSESSID=456; path=/')), + ); + } + public function testUnstartedSessionIsNotSave() { $this->sessionHasNotBeenStarted(); @@ -123,10 +153,10 @@ public function testDoesNotImplementServiceSubscriberInterface() $this->assertFalse(is_subclass_of(TestSessionListener::class, ServiceSubscriberInterface::class, 'Implementing ServiceSubscriberInterface would create a dep on the DI component, which eg Silex cannot afford')); } - private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST) + private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, Response $response = null) { $request->setSession($this->session); - $response = new Response(); + $response = $response ?: new Response(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $event = new FilterResponseEvent($kernel, $request, $type, $response); From d468c8c026b7bc7c5df0a524c7be634bf954bb02 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 6 Jul 2018 10:46:11 +0200 Subject: [PATCH 072/294] improve deprecation messages --- Controller/ControllerResolver.php | 4 ++-- Controller/TraceableControllerResolver.php | 2 +- Kernel.php | 4 ++-- Tests/KernelTest.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index b9d9f9fa25..0811fdf772 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('%s 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]); @@ -126,7 +126,7 @@ public function getArguments(Request $request, $controller) */ protected function doGetArguments(Request $request, $controller, array $parameters) { - @trigger_error(sprintf('%s 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 = array(); diff --git a/Controller/TraceableControllerResolver.php b/Controller/TraceableControllerResolver.php index 7501077140..bfb770a0d0 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/Kernel.php b/Kernel.php index 9668b9ecd1..5041ecb4a9 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])) { @@ -734,7 +734,7 @@ 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 = array(); diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 7cde2ac5e2..916cf8d24d 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -809,7 +809,7 @@ public function testKernelRootDirNameStartingWithANumber() /** * @group legacy - * @expectedDeprecation The Symfony\Component\HttpKernel\Kernel::getEnvParameters() method is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax to get the value of any environment variable from configuration files instead. + * @expectedDeprecation The "Symfony\Component\HttpKernel\Kernel::getEnvParameters()" method is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax to get the value of any environment variable from configuration files instead. * @expectedDeprecation The support of special environment variables that start with SYMFONY__ (such as "SYMFONY__FOO__BAR") is deprecated as of 3.3 and will be removed in 4.0. Use the %cenv()%c syntax instead to get the value of environment variables in configuration files. */ public function testSymfonyEnvironmentVariables() From 099db043010847c95d62b2b4917f80802603f09d Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Wed, 18 Jul 2018 13:02:07 +0200 Subject: [PATCH 073/294] Fix PHPDoc return type GetResponseEvent::getResponse() may return null too --- Event/GetResponseEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Event/GetResponseEvent.php b/Event/GetResponseEvent.php index f7745ea3dc..c25a0f1cf1 100644 --- a/Event/GetResponseEvent.php +++ b/Event/GetResponseEvent.php @@ -29,7 +29,7 @@ class GetResponseEvent extends KernelEvent /** * Returns the response object. * - * @return Response + * @return Response|null */ public function getResponse() { From 218dcae825d05e702872a055068f51d3ee04bc18 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 19 Jul 2018 11:59:26 -0400 Subject: [PATCH 074/294] Fixed templateExists on parse error of the template name --- Fragment/HIncludeFragmentRenderer.php | 2 +- Tests/Fragment/HIncludeFragmentRendererTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index 3252f061e5..4ee89d6e8c 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -135,7 +135,7 @@ private function templateExists($template) if ($this->templating instanceof EngineInterface) { try { return $this->templating->exists($template); - } catch (\InvalidArgumentException $e) { + } catch (\Exception $e) { return false; } } diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index 1be052e5e6..7171c71bc3 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -86,4 +86,17 @@ public function testRenderWithDefaultText() $strategy = new HIncludeFragmentRenderer($engine); $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); } + + public function testRenderWithEngineAndDefaultText() + { + $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); + $engine->expects($this->once()) + ->method('exists') + ->with('loading...') + ->will($this->throwException(new \RuntimeException())); + + // only default + $strategy = new HIncludeFragmentRenderer($engine); + $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), array('default' => 'loading...'))->getContent()); + } } From b4f724a74028a70bcc834140694e1109d83db258 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Jul 2018 11:02:45 +0200 Subject: [PATCH 075/294] updated VERSION for 2.8.43 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 10ff79297b..d97d56d201 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.43-DEV'; + const VERSION = '2.8.43'; const VERSION_ID = 20843; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 43; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 85fae7240d424b94f482c0a5e1daa111ea8b4585 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Jul 2018 16:56:24 +0200 Subject: [PATCH 076/294] bumped Symfony version to 2.8.44 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d97d56d201..70735892ff 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.43'; - const VERSION_ID = 20843; + const VERSION = '2.8.44-DEV'; + const VERSION_ID = 20844; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 43; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 44; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 22a1d000d45f09966a363223548a150aec759e61 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Jul 2018 18:37:31 +0200 Subject: [PATCH 077/294] updated VERSION for 3.4.13 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 5041ecb4a9..be20edd8ad 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.13-DEV'; + const VERSION = '3.4.13'; const VERSION_ID = 30413; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 13; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 71e5d300222f70dfebc895d3ccc67fb53550304c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 23 Jul 2018 19:11:49 +0200 Subject: [PATCH 078/294] bumped Symfony version to 3.4.14 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index be20edd8ad..de0771ed2c 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.13'; - const VERSION_ID = 30413; + const VERSION = '3.4.14-DEV'; + const VERSION_ID = 30414; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 13; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 14; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 3a967355402d2f308951528f42961a2076678535 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 24 Jul 2018 08:16:38 +0200 Subject: [PATCH 079/294] [HttpKernel] Fix merging bindings for controllers' locators --- ...RegisterControllerArgumentLocatorsPass.php | 2 +- ...sterControllerArgumentLocatorsPassTest.php | 24 +++++++++++++++++++ composer.json | 4 ++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index cb88594e3a..cb05f6fbeb 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -60,7 +60,7 @@ public function process(ContainerBuilder $container) while ($def instanceof ChildDefinition) { $def = $container->findDefinition($def->getParent()); $class = $class ?: $def->getClass(); - $bindings = $def->getBindings(); + $bindings += $def->getBindings(); } $class = $parameterBag->resolveValue($class); diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 4016deb4ab..a3f8d8dfb4 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -326,6 +327,29 @@ public function testDoNotBindScalarValueToControllerArgument() $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); $this->assertEmpty($locator); } + + public function testBindingsOnChildDefinitions() + { + $container = new ContainerBuilder(); + $resolver = $container->register('argument_resolver.service')->addArgument(array()); + + $container->register('parent', ArgumentWithoutTypeController::class); + + $container->setDefinition('child', (new ChildDefinition('parent')) + ->setBindings(array('$someArg' => new Reference('parent'))) + ->addTag('controller.service_arguments') + ); + + $pass = new RegisterControllerArgumentLocatorsPass(); + $pass->process($container); + + $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); + $this->assertInstanceOf(ServiceClosureArgument::class, $locator['child:fooAction']); + + $locator = $container->getDefinition((string) $locator['child:fooAction']->getValues()[0])->getArgument(0); + $this->assertInstanceOf(ServiceClosureArgument::class, $locator['someArg']); + $this->assertEquals(new Reference('parent'), $locator['someArg']->getValues()[0]); + } } class RegisterTestController diff --git a/composer.json b/composer.json index 585ab5b37d..9ad3877ba1 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/config": "~2.8|~3.0|~4.0", "symfony/console": "~2.8|~3.0|~4.0", "symfony/css-selector": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "^3.4.5|^4.0.5", + "symfony/dependency-injection": "^3.4.10|^4.0.10", "symfony/dom-crawler": "~2.8|~3.0|~4.0", "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", @@ -46,7 +46,7 @@ }, "conflict": { "symfony/config": "<2.8", - "symfony/dependency-injection": "<3.4.5|<4.0.5,>=4", + "symfony/dependency-injection": "<3.4.10|<4.0.10,>=4", "symfony/var-dumper": "<3.3", "twig/twig": "<1.34|<2.4,>=2" }, From c688c0a6a9bc2fa56c6fc0ebb632a4af7521e4a7 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 5 Jul 2018 13:24:53 +0200 Subject: [PATCH 080/294] Enable the fixer enforcing fully-qualified calls for compiler-optimized functions --- Bundle/Bundle.php | 8 +++---- CacheWarmer/CacheWarmer.php | 2 +- Client.php | 4 ++-- Controller/ControllerResolver.php | 24 +++++++++---------- DataCollector/ConfigDataCollector.php | 12 +++++----- DataCollector/DumpDataCollector.php | 6 ++--- DataCollector/LoggerDataCollector.php | 10 ++++---- DataCollector/MemoryDataCollector.php | 4 ++-- DataCollector/RequestDataCollector.php | 14 +++++------ DataCollector/Util/ValueExporter.php | 12 +++++----- .../LazyLoadingFragmentHandler.php | 2 +- .../MergeExtensionConfigurationPass.php | 2 +- Event/FilterControllerEvent.php | 10 ++++---- EventListener/DebugHandlersListener.php | 8 +++---- EventListener/ExceptionListener.php | 6 ++--- EventListener/LocaleListener.php | 4 ++-- EventListener/ProfilerListener.php | 2 +- .../AbstractSurrogateFragmentRenderer.php | 2 +- Fragment/FragmentHandler.php | 8 +++---- Fragment/HIncludeFragmentRenderer.php | 6 ++--- Fragment/RoutableFragmentRenderer.php | 2 +- HttpCache/Esi.php | 2 +- HttpCache/HttpCache.php | 10 ++++---- HttpCache/Ssi.php | 2 +- HttpCache/Store.php | 10 ++++---- HttpKernel.php | 8 +++---- Kernel.php | 14 +++++------ Profiler/BaseMemcacheProfilerStorage.php | 2 +- Profiler/FileProfilerStorage.php | 4 ++-- Profiler/MysqlProfilerStorage.php | 2 +- Profiler/PdoProfilerStorage.php | 4 ++-- Profiler/Profiler.php | 2 +- Profiler/RedisProfilerStorage.php | 4 ++-- Profiler/SqliteProfilerStorage.php | 8 +++---- Tests/CacheWarmer/CacheWarmerTest.php | 4 ++-- Tests/ClientTest.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 12 +++++----- Tests/DataCollector/DumpDataCollectorTest.php | 2 +- Tests/EventListener/ExceptionListenerTest.php | 6 ++--- Tests/Fragment/FragmentHandlerTest.php | 2 +- Tests/HttpCache/EsiTest.php | 4 ++-- Tests/HttpCache/HttpCacheTest.php | 6 ++--- Tests/HttpCache/HttpCacheTestCase.php | 2 +- Tests/HttpCache/SsiTest.php | 4 ++-- Tests/KernelTest.php | 4 ++-- Tests/Profiler/Mock/MemcacheMock.php | 2 +- Tests/Profiler/Mock/RedisMock.php | 4 ++-- 47 files changed, 137 insertions(+), 137 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 2aac43e933..024754e05f 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -84,7 +84,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 @@ -116,7 +116,7 @@ public function getContainerExtension() */ public function getNamespace() { - $class = get_class($this); + $class = \get_class($this); return substr($class, 0, strrpos($class, '\\')); } @@ -130,7 +130,7 @@ public function getPath() { if (null === $this->path) { $reflected = new \ReflectionObject($this); - $this->path = dirname($reflected->getFileName()); + $this->path = \dirname($reflected->getFileName()); } return $this->path; @@ -156,7 +156,7 @@ final public function getName() return $this->name; } - $name = get_class($this); + $name = \get_class($this); $pos = strrpos($name, '\\'); return $this->name = false === $pos ? $name : substr($name, $pos + 1); diff --git a/CacheWarmer/CacheWarmer.php b/CacheWarmer/CacheWarmer.php index dba35a639a..52dc2ad2c3 100644 --- a/CacheWarmer/CacheWarmer.php +++ b/CacheWarmer/CacheWarmer.php @@ -20,7 +20,7 @@ abstract class CacheWarmer implements CacheWarmerInterface { protected function writeCacheFile($file, $content) { - $tmpFile = @tempnam(dirname($file), basename($file)); + $tmpFile = @tempnam(\dirname($file), basename($file)); if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { @chmod($file, 0666 & ~umask()); diff --git a/Client.php b/Client.php index c19b6ade76..63efc44f51 100644 --- a/Client.php +++ b/Client.php @@ -76,7 +76,7 @@ protected function getScript($request) $r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader'); $requirePath = str_replace("'", "\\'", $r->getFileName()); - $symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__)))); + $symfonyPath = str_replace("'", "\\'", \dirname(\dirname(\dirname(__DIR__)))); $errorReporting = error_reporting(); $code = << $value) { - if (is_array($value)) { + if (\is_array($value)) { $filtered[$key] = $this->filterFiles($value); } elseif ($value instanceof UploadedFile) { if ($value->isValid() && $value->getSize() > UploadedFile::getMaxFilesize()) { diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 8a3ea1b840..8e547a4b15 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -65,29 +65,29 @@ public function getController(Request $request) return false; } - if (is_array($controller)) { + if (\is_array($controller)) { return $controller; } - if (is_object($controller)) { + if (\is_object($controller)) { if (method_exists($controller, '__invoke')) { return $controller; } - throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo())); + throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', \get_class($controller), $request->getPathInfo())); } if (false === strpos($controller, ':')) { if (method_exists($controller, '__invoke')) { return $this->instantiateController($controller); - } elseif (function_exists($controller)) { + } elseif (\function_exists($controller)) { return $controller; } } $callable = $this->createController($controller); - if (!is_callable($callable)) { + if (!\is_callable($callable)) { throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo())); } @@ -99,9 +99,9 @@ public function getController(Request $request) */ public function getArguments(Request $request, $controller) { - if (is_array($controller)) { + if (\is_array($controller)) { $r = new \ReflectionMethod($controller[0], $controller[1]); - } elseif (is_object($controller) && !$controller instanceof \Closure) { + } elseif (\is_object($controller) && !$controller instanceof \Closure) { $r = new \ReflectionObject($controller); $r = $r->getMethod('__invoke'); } else { @@ -124,7 +124,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete $arguments = array(); foreach ($parameters as $param) { if (array_key_exists($param->name, $attributes)) { - if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) { + if ($this->supportsVariadic && $param->isVariadic() && \is_array($attributes[$param->name])) { $arguments = array_merge($arguments, array_values($attributes[$param->name])); } else { $arguments[] = $attributes[$param->name]; @@ -136,10 +136,10 @@ protected function doGetArguments(Request $request, $controller, array $paramete } elseif ($this->supportsScalarTypes && $param->hasType() && $param->allowsNull()) { $arguments[] = null; } else { - if (is_array($controller)) { - $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); - } elseif (is_object($controller)) { - $repr = get_class($controller); + if (\is_array($controller)) { + $repr = sprintf('%s::%s()', \get_class($controller[0]), $controller[1]); + } elseif (\is_object($controller)) { + $repr = \get_class($controller); } else { $repr = $controller; } diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 318c6522b4..45046eda8a 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -61,12 +61,12 @@ 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, - 'xdebug_enabled' => extension_loaded('xdebug'), - 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), - 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), - 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), - 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), - 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), + 'xdebug_enabled' => \extension_loaded('xdebug'), + 'eaccel_enabled' => \extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), + 'apc_enabled' => \extension_loaded('apc') && ini_get('apc.enabled'), + 'xcache_enabled' => \extension_loaded('xcache') && ini_get('xcache.cacher'), + 'wincache_enabled' => \extension_loaded('wincache') && ini_get('wincache.ocenabled'), + 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), 'sapi_name' => PHP_SAPI, ); diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 27208ea625..5f57bed7f0 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -110,7 +110,7 @@ public function dump(Data $data) $src = explode("\n", $src); $fileExcerpt = array(); - for ($i = max($line - 3, 1), $max = min($line + 3, count($src)); $i <= $max; ++$i) { + for ($i = max($line - 3, 1), $max = min($line + 3, \count($src)); $i <= $max; ++$i) { $fileExcerpt[] = ''.$this->htmlEncode($src[$i - 1]).''; } @@ -192,7 +192,7 @@ public function unserialize($data) parent::unserialize($data); $charset = array_pop($this->data); $fileLinkFormat = array_pop($this->data); - $this->dataCount = count($this->data); + $this->dataCount = \count($this->data); self::__construct($this->stopwatch, $fileLinkFormat, $charset); } @@ -240,7 +240,7 @@ public function __destruct() $this->isCollected = true; $h = headers_list(); - $i = count($h); + $i = \count($h); array_unshift($h, 'Content-Type: '.ini_get('default_mimetype')); while (0 !== stripos($h[$i], 'Content-Type:')) { --$i; diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 0e4df12baa..150e746664 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -155,7 +155,7 @@ private function sanitizeLogs($logs) private function sanitizeContext($context) { - if (is_array($context)) { + if (\is_array($context)) { foreach ($context as $key => $value) { $context[$key] = $this->sanitizeContext($value); } @@ -163,16 +163,16 @@ private function sanitizeContext($context) return $context; } - if (is_resource($context)) { + if (\is_resource($context)) { return sprintf('Resource(%s)', get_resource_type($context)); } - if (is_object($context)) { + if (\is_object($context)) { if ($context instanceof \Exception) { - return sprintf('Exception(%s): %s', get_class($context), $context->getMessage()); + return sprintf('Exception(%s): %s', \get_class($context), $context->getMessage()); } - return sprintf('Object(%s)', get_class($context)); + return sprintf('Object(%s)', \get_class($context)); } return $context; diff --git a/DataCollector/MemoryDataCollector.php b/DataCollector/MemoryDataCollector.php index b7f61f46fd..0d9b562c60 100644 --- a/DataCollector/MemoryDataCollector.php +++ b/DataCollector/MemoryDataCollector.php @@ -90,9 +90,9 @@ private function convertToBytes($memoryLimit) $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); if (0 === strpos($max, '0x')) { - $max = intval($max, 16); + $max = \intval($max, 16); } elseif (0 === strpos($max, '0')) { - $max = intval($max, 8); + $max = \intval($max, 8); } else { $max = (int) $max; } diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index face98ffa8..b6e1613a64 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -43,7 +43,7 @@ public function collect(Request $request, Response $response, \Exception $except // attributes are serialized and as they can be anything, they need to be converted to strings. $attributes = array(); foreach ($request->attributes->all() as $key => $value) { - if ('_route' === $key && is_object($value)) { + if ('_route' === $key && \is_object($value)) { $attributes[$key] = $this->varToString($value->getPath()); } elseif ('_route_params' === $key) { // we need to keep route params as an array (see getRouteParams()) @@ -114,7 +114,7 @@ public function collect(Request $request, Response $response, \Exception $except } foreach ($this->data as $key => $value) { - if (!is_array($value)) { + if (!\is_array($value)) { continue; } if ('request_headers' === $key || 'response_headers' === $key) { @@ -127,20 +127,20 @@ public function collect(Request $request, Response $response, \Exception $except if (isset($this->controllers[$request])) { $controller = $this->controllers[$request]; - if (is_array($controller)) { + if (\is_array($controller)) { try { $r = new \ReflectionMethod($controller[0], $controller[1]); $this->data['controller'] = array( - 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], + 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFileName(), 'line' => $r->getStartLine(), ); } catch (\ReflectionException $e) { - if (is_callable($controller)) { + if (\is_callable($controller)) { // using __call or __callStatic $this->data['controller'] = array( - 'class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], + 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => 'n/a', 'line' => 'n/a', @@ -155,7 +155,7 @@ public function collect(Request $request, Response $response, \Exception $except 'file' => $r->getFileName(), 'line' => $r->getStartLine(), ); - } elseif (is_object($controller)) { + } elseif (\is_object($controller)) { $r = new \ReflectionClass($controller); $this->data['controller'] = array( 'class' => $r->getName(), diff --git a/DataCollector/Util/ValueExporter.php b/DataCollector/Util/ValueExporter.php index 324e8d65d9..5eb505789c 100644 --- a/DataCollector/Util/ValueExporter.php +++ b/DataCollector/Util/ValueExporter.php @@ -31,15 +31,15 @@ public function exportValue($value, $depth = 1, $deep = false) return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value)); } - if (is_object($value)) { + if (\is_object($value)) { if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) { - return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM)); + return sprintf('Object(%s) - %s', \get_class($value), $value->format(\DateTime::ATOM)); } - return sprintf('Object(%s)', get_class($value)); + return sprintf('Object(%s)', \get_class($value)); } - if (is_array($value)) { + if (\is_array($value)) { if (empty($value)) { return '[]'; } @@ -48,7 +48,7 @@ public function exportValue($value, $depth = 1, $deep = false) $a = array(); foreach ($value as $k => $v) { - if (is_array($v)) { + if (\is_array($v)) { $deep = true; } $a[] = sprintf('%s => %s', $k, $this->exportValue($v, $depth + 1, $deep)); @@ -61,7 +61,7 @@ public function exportValue($value, $depth = 1, $deep = false) return sprintf('[%s]', implode(', ', $a)); } - if (is_resource($value)) { + if (\is_resource($value)) { return sprintf('Resource(%s#%d)', get_resource_type($value), $value); } diff --git a/DependencyInjection/LazyLoadingFragmentHandler.php b/DependencyInjection/LazyLoadingFragmentHandler.php index b513816cc9..f13aec6834 100644 --- a/DependencyInjection/LazyLoadingFragmentHandler.php +++ b/DependencyInjection/LazyLoadingFragmentHandler.php @@ -39,7 +39,7 @@ public function __construct(ContainerInterface $container, $requestStack = null, if ((null !== $requestStack && !$requestStack instanceof RequestStack) || $debug instanceof RequestStack) { $tmp = $debug; $debug = $requestStack; - $requestStack = func_num_args() < 3 ? null : $tmp; + $requestStack = \func_num_args() < 3 ? null : $tmp; @trigger_error('The '.__METHOD__.' method now requires a RequestStack to be given as second argument as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED); } elseif (!$requestStack instanceof RequestStack) { diff --git a/DependencyInjection/MergeExtensionConfigurationPass.php b/DependencyInjection/MergeExtensionConfigurationPass.php index dcd73828de..1dbf7f7bee 100644 --- a/DependencyInjection/MergeExtensionConfigurationPass.php +++ b/DependencyInjection/MergeExtensionConfigurationPass.php @@ -31,7 +31,7 @@ public function __construct(array $extensions) public function process(ContainerBuilder $container) { foreach ($this->extensions as $extension) { - if (!count($container->getExtensionConfig($extension))) { + if (!\count($container->getExtensionConfig($extension))) { $container->loadFromExtension($extension, array()); } } diff --git a/Event/FilterControllerEvent.php b/Event/FilterControllerEvent.php index 1da23b7017..19831faf02 100644 --- a/Event/FilterControllerEvent.php +++ b/Event/FilterControllerEvent.php @@ -56,7 +56,7 @@ public function getController() public function setController($controller) { // controller must be a callable - if (!is_callable($controller)) { + if (!\is_callable($controller)) { throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller))); } @@ -65,11 +65,11 @@ public function setController($controller) private function varToString($var) { - if (is_object($var)) { - return sprintf('Object(%s)', get_class($var)); + if (\is_object($var)) { + return sprintf('Object(%s)', \get_class($var)); } - if (is_array($var)) { + if (\is_array($var)) { $a = array(); foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); @@ -78,7 +78,7 @@ private function varToString($var) return sprintf('Array(%s)', implode(', ', $a)); } - if (is_resource($var)) { + if (\is_resource($var)) { return sprintf('Resource(%s)', get_resource_type($var)); } diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index b560e24d72..c0c68bc806 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -67,14 +67,14 @@ public function configure(Event $event = null) $this->firstCall = $this->hasTerminatedWithException = false; $handler = set_exception_handler('var_dump'); - $handler = is_array($handler) ? $handler[0] : null; + $handler = \is_array($handler) ? $handler[0] : null; restore_exception_handler(); if ($this->logger || null !== $this->throwAt) { if ($handler instanceof ErrorHandler) { if ($this->logger) { $handler->setDefaultLogger($this->logger, $this->levels); - if (is_array($this->levels)) { + if (\is_array($this->levels)) { $scream = 0; foreach ($this->levels as $type => $log) { $scream |= $type; @@ -118,7 +118,7 @@ public function configure(Event $event = null) if ($this->exceptionHandler) { if ($handler instanceof ErrorHandler) { $h = $handler->setExceptionHandler('var_dump'); - if (is_array($h) && $h[0] instanceof ExceptionHandler) { + if (\is_array($h) && $h[0] instanceof ExceptionHandler) { $handler->setExceptionHandler($h); $handler = $h[0]; } else { @@ -139,7 +139,7 @@ public static function getSubscribedEvents() { $events = array(KernelEvents::REQUEST => array('configure', 2048)); - if (defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { + if (\defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { $events[ConsoleEvents::COMMAND] = array('configure', 2048); } diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index 32d0a130ff..fa23e06bb1 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -45,16 +45,16 @@ public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $request = $event->getRequest(); - $eventDispatcher = func_num_args() > 2 ? func_get_arg(2) : null; + $eventDispatcher = \func_num_args() > 2 ? func_get_arg(2) : null; - $this->logException($exception, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); + $this->logException($exception, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', \get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); $request = $this->duplicateRequest($exception, $request); try { $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false); } catch (\Exception $e) { - $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())); + $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', \get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())); $wrapper = $e; diff --git a/EventListener/LocaleListener.php b/EventListener/LocaleListener.php index 8d389150b0..36ef263075 100644 --- a/EventListener/LocaleListener.php +++ b/EventListener/LocaleListener.php @@ -48,9 +48,9 @@ public function __construct($requestStack = null, $defaultLocale = 'en', $router { if ((null !== $requestStack && !$requestStack instanceof RequestStack) || $defaultLocale instanceof RequestContextAwareInterface || $router instanceof RequestStack) { $tmp = $router; - $router = func_num_args() < 2 ? null : $defaultLocale; + $router = \func_num_args() < 2 ? null : $defaultLocale; $defaultLocale = $requestStack; - $requestStack = func_num_args() < 3 ? null : $tmp; + $requestStack = \func_num_args() < 3 ? null : $tmp; @trigger_error('The '.__METHOD__.' method now requires a RequestStack to be given as first argument as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED); } elseif (!$requestStack instanceof RequestStack) { diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index c7a0e9cd37..cb634e8204 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -52,7 +52,7 @@ public function __construct(Profiler $profiler, $requestStack = null, $matcher = $onlyMasterRequests = $onlyException; $onlyException = $matcher; $matcher = $requestStack; - $requestStack = func_num_args() < 5 ? null : $tmp; + $requestStack = \func_num_args() < 5 ? null : $tmp; @trigger_error('The '.__METHOD__.' method now requires a RequestStack to be given as second argument as '.__CLASS__.'::onKernelRequest method will be removed in 3.0.', E_USER_DEPRECATED); } elseif (!$requestStack instanceof RequestStack) { diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index 07eda6f1c1..65474aa490 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -88,6 +88,6 @@ private function generateSignedFragmentUri($uri, Request $request) // we need to sign the absolute URI, but want to return the path only. $fragmentUri = $this->signer->sign($this->generateFragmentUri($uri, $request, true)); - return substr($fragmentUri, strlen($request->getSchemeAndHttpHost())); + return substr($fragmentUri, \strlen($request->getSchemeAndHttpHost())); } } diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 34bf121bd9..0a7ed907eb 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -48,11 +48,11 @@ class FragmentHandler */ public function __construct($requestStack = null, $renderers = array(), $debug = false) { - if (is_array($requestStack)) { + if (\is_array($requestStack)) { $tmp = $debug; - $debug = func_num_args() < 2 ? false : $renderers; + $debug = \func_num_args() < 2 ? false : $renderers; $renderers = $requestStack; - $requestStack = func_num_args() < 3 ? null : $tmp; + $requestStack = \func_num_args() < 3 ? null : $tmp; @trigger_error('The '.__METHOD__.' method now requires a RequestStack to be given as first argument as '.__CLASS__.'::setRequest method will not be supported anymore in 3.0.', E_USER_DEPRECATED); } elseif (!$requestStack instanceof RequestStack) { @@ -62,7 +62,7 @@ public function __construct($requestStack = null, $renderers = array(), $debug = if (null !== $requestStack && !$requestStack instanceof RequestStack) { throw new \InvalidArgumentException('RequestStack instance expected.'); } - if (!is_array($renderers)) { + if (!\is_array($renderers)) { throw new \InvalidArgumentException('Renderers must be an array.'); } diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index 4ee89d6e8c..191f729b2c 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -89,7 +89,7 @@ public function render($uri, Request $request, array $options = array()) } // we need to sign the absolute URI, but want to return the path only. - $uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), strlen($request->getSchemeAndHttpHost())); + $uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), \strlen($request->getSchemeAndHttpHost())); } // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content. @@ -102,12 +102,12 @@ public function render($uri, Request $request, array $options = array()) $content = $template; } - $attributes = isset($options['attributes']) && is_array($options['attributes']) ? $options['attributes'] : array(); + $attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : array(); if (isset($options['id']) && $options['id']) { $attributes['id'] = $options['id']; } $renderedAttributes = ''; - if (count($attributes) > 0) { + if (\count($attributes) > 0) { if (\PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { diff --git a/Fragment/RoutableFragmentRenderer.php b/Fragment/RoutableFragmentRenderer.php index d7eeb89a6b..087995f290 100644 --- a/Fragment/RoutableFragmentRenderer.php +++ b/Fragment/RoutableFragmentRenderer.php @@ -80,7 +80,7 @@ protected function generateFragmentUri(ControllerReference $reference, Request $ private function checkNonScalar($values) { foreach ($values as $key => $value) { - if (is_array($value)) { + if (\is_array($value)) { $this->checkNonScalar($value); } elseif (!is_scalar($value) && null !== $value) { throw new \LogicException(sprintf('Controller attributes cannot contain non-scalar/non-null values (value for key "%s" is not a scalar or null).', $key)); diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 02db7ce672..d49c63c550 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -193,7 +193,7 @@ public function process(Request $request, Response $response) } $parts = explode(';', $type); - if (!in_array($parts[0], $this->contentTypes)) { + if (!\in_array($parts[0], $this->contentTypes)) { return $response; } diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index 6f46787698..5f3acf1beb 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -396,7 +396,7 @@ protected function validate(Request $request, Response $entry, $catch = false) // return the response and not the cache entry if the response is valid but not cached $etag = $response->getEtag(); - if ($etag && in_array($etag, $requestEtags) && !in_array($etag, $cachedEtags)) { + if ($etag && \in_array($etag, $requestEtags) && !\in_array($etag, $cachedEtags)) { return $response; } @@ -481,7 +481,7 @@ protected function forward(Request $request, $catch = false, Response $entry = n $request->server->set('REMOTE_ADDR', '127.0.0.1'); // make sure HttpCache is a trusted proxy - if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { + if (!\in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { $trustedProxies[] = '127.0.0.1'; Request::setTrustedProxies($trustedProxies); } @@ -491,7 +491,7 @@ protected function forward(Request $request, $catch = false, Response $entry = n // FIXME: we probably need to also catch exceptions if raw === true // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC - if (null !== $entry && in_array($response->getStatusCode(), array(500, 502, 503, 504))) { + if (null !== $entry && \in_array($response->getStatusCode(), array(500, 502, 503, 504))) { if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { $age = $this->options['stale_if_error']; } @@ -632,7 +632,7 @@ private function restoreResponseBody(Request $request, Response $response) $response->setContent(ob_get_clean()); $response->headers->remove('X-Body-Eval'); if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); + $response->headers->set('Content-Length', \strlen($response->getContent())); } } elseif ($response->headers->has('X-Body-File')) { // Response does not include possibly dynamic content (ESI, SSI), so we need @@ -666,7 +666,7 @@ private function isPrivateRequest(Request $request) $key = strtolower(str_replace('HTTP_', '', $key)); if ('cookie' === $key) { - if (count($request->cookies->all())) { + if (\count($request->cookies->all())) { return true; } } elseif ($request->headers->has($key)) { diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index e7a70c19a2..73067672b3 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -117,7 +117,7 @@ public function process(Request $request, Response $response) } $parts = explode(';', $type); - if (!in_array($parts[0], $this->contentTypes)) { + if (!\in_array($parts[0], $this->contentTypes)) { return $response; } diff --git a/HttpCache/Store.php b/HttpCache/Store.php index d20bfaa1b0..fcdd7fa5e6 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -68,7 +68,7 @@ public function lock(Request $request) if (!isset($this->locks[$key])) { $path = $this->getPath($key); - if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) { + if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) { return $path; } $h = fopen($path, 'cb'); @@ -187,7 +187,7 @@ public function write(Request $request, Response $response) $response->headers->set('X-Content-Digest', $digest); if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', strlen($response->getContent())); + $response->headers->set('Content-Length', \strlen($response->getContent())); } } @@ -375,17 +375,17 @@ private function save($key, $data) @ftruncate($fp, 0); @fseek($fp, 0); $len = @fwrite($fp, $data); - if (strlen($data) !== $len) { + if (\strlen($data) !== $len) { @ftruncate($fp, 0); return false; } } else { - if (!file_exists(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) { + if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) { return false; } - $tmpFile = tempnam(dirname($path), basename($path)); + $tmpFile = tempnam(\dirname($path), basename($path)); if (false === $fp = @fopen($tmpFile, 'wb')) { @unlink($tmpFile); diff --git a/HttpKernel.php b/HttpKernel.php index 60c000f030..8331d8a6c1 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -247,11 +247,11 @@ private function handleException(\Exception $e, $request, $type) private function varToString($var) { - if (is_object($var)) { - return sprintf('Object(%s)', get_class($var)); + if (\is_object($var)) { + return sprintf('Object(%s)', \get_class($var)); } - if (is_array($var)) { + if (\is_array($var)) { $a = array(); foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); @@ -260,7 +260,7 @@ private function varToString($var) return sprintf('Array(%s)', implode(', ', $a)); } - if (is_resource($var)) { + if (\is_resource($var)) { return sprintf('Resource(%s)', get_resource_type($var)); } diff --git a/Kernel.php b/Kernel.php index 70735892ff..1df4c2eddc 100644 --- a/Kernel.php +++ b/Kernel.php @@ -225,7 +225,7 @@ public function isClassInActiveBundle($class) public function getBundle($name, $first = true) { 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, \get_class($this))); } if (true === $first) { @@ -287,7 +287,7 @@ public function locateResource($name, $dir = null, $first = true) } } - if (count($files) > 0) { + if (\count($files) > 0) { return $first && $isResource ? $files[0] : $files; } @@ -332,7 +332,7 @@ public function getRootDir() { if (null === $this->rootDir) { $r = new \ReflectionObject($this); - $this->rootDir = dirname($r->getFileName()); + $this->rootDir = \dirname($r->getFileName()); } return $this->rootDir; @@ -449,7 +449,7 @@ protected function initializeBundles() } // look for orphans - if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) { + if (!empty($directChildren) && \count($diff = array_diff_key($directChildren, $this->bundles))) { $diff = array_keys($diff); throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0])); @@ -536,7 +536,7 @@ protected function getKernelParameters() $bundlesMetadata = array(); foreach ($this->bundles as $name => $bundle) { - $bundles[$name] = get_class($bundle); + $bundles[$name] = \get_class($bundle); $bundlesMetadata[$name] = array( 'parent' => $bundle->getParent(), 'path' => $bundle->getPath(), @@ -707,7 +707,7 @@ protected function getContainerLoader(ContainerInterface $container) */ public static function stripComments($source) { - if (!function_exists('token_get_all')) { + if (!\function_exists('token_get_all')) { return $source; } @@ -735,7 +735,7 @@ public static function stripComments($source) // replace multiple new lines with a single newline $rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]); - } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + } elseif (\in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { $ignoreSpace = true; } else { $rawChunk .= $token[1]; diff --git a/Profiler/BaseMemcacheProfilerStorage.php b/Profiler/BaseMemcacheProfilerStorage.php index 70f3dbcc04..d990e98a46 100644 --- a/Profiler/BaseMemcacheProfilerStorage.php +++ b/Profiler/BaseMemcacheProfilerStorage.php @@ -302,7 +302,7 @@ private function getIndexName() private function isItemNameValid($name) { - $length = strlen($name); + $length = \strlen($name); if ($length > 250) { throw new \RuntimeException(sprintf('The memcache item key "%s" is too long (%s bytes). Allowed maximum size is 250 bytes.', $name, $length)); diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index 0450589910..0d7e3955c6 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -61,7 +61,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null) fseek($file, 0, SEEK_END); $result = array(); - while (count($result) < $limit && $line = $this->readLineFromFile($file)) { + while (\count($result) < $limit && $line = $this->readLineFromFile($file)) { $values = str_getcsv($line); list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = $values; $csvStatusCode = isset($values[6]) ? $values[6] : null; @@ -138,7 +138,7 @@ public function write(Profile $profile) $profileIndexed = is_file($file); if (!$profileIndexed) { // Create directory - $dir = dirname($file); + $dir = \dirname($file); if (!is_dir($dir) && false === @mkdir($dir, 0777, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf('Unable to create the storage directory (%s).', $dir)); } diff --git a/Profiler/MysqlProfilerStorage.php b/Profiler/MysqlProfilerStorage.php index 45d9cfffbb..086aa87416 100644 --- a/Profiler/MysqlProfilerStorage.php +++ b/Profiler/MysqlProfilerStorage.php @@ -33,7 +33,7 @@ protected function initDb() throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Mysql with an invalid dsn "%s". The expected format is "mysql:dbname=database_name;host=host_name".', $this->dsn)); } - if (!class_exists('PDO') || !in_array('mysql', \PDO::getAvailableDrivers(), true)) { + if (!class_exists('PDO') || !\in_array('mysql', \PDO::getAvailableDrivers(), true)) { throw new \RuntimeException('You need to enable PDO_Mysql extension for the profiler to run properly.'); } diff --git a/Profiler/PdoProfilerStorage.php b/Profiler/PdoProfilerStorage.php index 700607e4c9..e5f8bc72fc 100644 --- a/Profiler/PdoProfilerStorage.php +++ b/Profiler/PdoProfilerStorage.php @@ -160,7 +160,7 @@ protected function exec($db, $query, array $args = array()) $stmt = $this->prepareStatement($db, $query); foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); + $stmt->bindValue($arg, $val, \is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); } $success = $stmt->execute(); if (!$success) { @@ -188,7 +188,7 @@ protected function fetch($db, $query, array $args = array()) $stmt = $this->prepareStatement($db, $query); foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); + $stmt->bindValue($arg, $val, \is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR); } $stmt->execute(); diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index 0faf005ce1..7919203a67 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -102,7 +102,7 @@ public function saveProfile(Profile $profile) } if (!($ret = $this->storage->write($profile)) && null !== $this->logger) { - $this->logger->warning('Unable to store the profiler information.', array('configured_storage' => get_class($this->storage))); + $this->logger->warning('Unable to store the profiler information.', array('configured_storage' => \get_class($this->storage))); } return $ret; diff --git a/Profiler/RedisProfilerStorage.php b/Profiler/RedisProfilerStorage.php index e5aa93da8d..6d3d9676ca 100644 --- a/Profiler/RedisProfilerStorage.php +++ b/Profiler/RedisProfilerStorage.php @@ -216,7 +216,7 @@ protected function getRedis() throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn)); } - if (!extension_loaded('redis')) { + if (!\extension_loaded('redis')) { throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.'); } @@ -317,7 +317,7 @@ private function getIndexName() private function isItemNameValid($name) { - $length = strlen($name); + $length = \strlen($name); if ($length > 2147483648) { throw new \RuntimeException(sprintf('The Redis item key "%s" is too long (%s bytes). Allowed maximum size is 2^31 bytes.', $name, $length)); diff --git a/Profiler/SqliteProfilerStorage.php b/Profiler/SqliteProfilerStorage.php index 7f3d9baa50..549c27e1b3 100644 --- a/Profiler/SqliteProfilerStorage.php +++ b/Profiler/SqliteProfilerStorage.php @@ -33,12 +33,12 @@ protected function initDb() throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Sqlite with an invalid dsn "%s". The expected format is "sqlite:/path/to/the/db/file".', $this->dsn)); } if (class_exists('SQLite3')) { - $db = new \SQLite3(substr($this->dsn, 7, strlen($this->dsn)), \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE); + $db = new \SQLite3(substr($this->dsn, 7, \strlen($this->dsn)), \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE); if (method_exists($db, 'busyTimeout')) { // busyTimeout only exists for PHP >= 5.3.3 $db->busyTimeout(1000); } - } elseif (class_exists('PDO') && in_array('sqlite', \PDO::getAvailableDrivers(), true)) { + } elseif (class_exists('PDO') && \in_array('sqlite', \PDO::getAvailableDrivers(), true)) { $db = new \PDO($this->dsn); } else { throw new \RuntimeException('You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.'); @@ -64,7 +64,7 @@ protected function exec($db, $query, array $args = array()) if ($db instanceof \SQLite3) { $stmt = $this->prepareStatement($db, $query); foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); + $stmt->bindValue($arg, $val, \is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); } $res = $stmt->execute(); @@ -84,7 +84,7 @@ protected function fetch($db, $query, array $args = array()) if ($db instanceof \SQLite3) { $stmt = $this->prepareStatement($db, $query); foreach ($args as $arg => $val) { - $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); + $stmt->bindValue($arg, $val, \is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); } $res = $stmt->execute(); while ($row = $res->fetchArray(\SQLITE3_ASSOC)) { diff --git a/Tests/CacheWarmer/CacheWarmerTest.php b/Tests/CacheWarmer/CacheWarmerTest.php index 05666cb0dc..4d34e7bfc9 100644 --- a/Tests/CacheWarmer/CacheWarmerTest.php +++ b/Tests/CacheWarmer/CacheWarmerTest.php @@ -31,7 +31,7 @@ public static function tearDownAfterClass() public function testWriteCacheFileCreatesTheFile() { $warmer = new TestCacheWarmer(self::$cacheFile); - $warmer->warmUp(dirname(self::$cacheFile)); + $warmer->warmUp(\dirname(self::$cacheFile)); $this->assertFileExists(self::$cacheFile); } @@ -43,7 +43,7 @@ public function testWriteNonWritableCacheFileThrowsARuntimeException() { $nonWritableFile = '/this/file/is/very/probably/not/writable'; $warmer = new TestCacheWarmer($nonWritableFile); - $warmer->warmUp(dirname($nonWritableFile)); + $warmer->warmUp(\dirname($nonWritableFile)); } } diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index ac3ea1e860..158484d97b 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -121,7 +121,7 @@ public function testUploadedFile() $this->assertTrue($file->isValid()); } - $file->move(dirname($target), basename($target)); + $file->move(\dirname($target), basename($target)); $this->assertFileExists($target); unlink($target); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index 6d9f65d0ac..50aa388631 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -36,22 +36,22 @@ public function testCollect() $this->assertNull($c->getToken()); // if else clause because we don't know it - if (extension_loaded('xdebug')) { + if (\extension_loaded('xdebug')) { $this->assertTrue($c->hasXDebug()); } else { $this->assertFalse($c->hasXDebug()); } // if else clause because we don't know it - if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) + if (((\extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) || - (extension_loaded('apc') && ini_get('apc.enabled')) + (\extension_loaded('apc') && ini_get('apc.enabled')) || - (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) + (\extension_loaded('Zend OPcache') && ini_get('opcache.enable')) || - (extension_loaded('xcache') && ini_get('xcache.cacher')) + (\extension_loaded('xcache') && ini_get('xcache.cacher')) || - (extension_loaded('wincache') && ini_get('wincache.ocenabled')))) { + (\extension_loaded('wincache') && ini_get('wincache.ocenabled')))) { $this->assertTrue($c->hasAccelerator()); } else { $this->assertFalse($c->hasAccelerator()); diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index 4c7cd9a51c..3b57168a52 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -94,7 +94,7 @@ public function testCollectHtml() EOTXT; } else { - $len = strlen("DumpDataCollectorTest.php on line {$line}:"); + $len = \strlen("DumpDataCollectorTest.php on line {$line}:"); $xOutput = <<"DumpDataCollectorTest.php on line {$line}:" diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index 3cb0b298bb..e6508554f2 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -37,9 +37,9 @@ public function testConstruct() $logger = new TestLogger(); $l = new ExceptionListener('foo', $logger); - $_logger = new \ReflectionProperty(get_class($l), 'logger'); + $_logger = new \ReflectionProperty(\get_class($l), 'logger'); $_logger->setAccessible(true); - $_controller = new \ReflectionProperty(get_class($l), 'controller'); + $_controller = new \ReflectionProperty(\get_class($l), 'controller'); $_controller->setAccessible(true); $this->assertSame($logger, $_logger->getValue($l)); @@ -157,7 +157,7 @@ class TestLogger extends Logger implements DebugLoggerInterface { public function countErrors() { - return count($this->logs['critical']); + return \count($this->logs['critical']); } } diff --git a/Tests/Fragment/FragmentHandlerTest.php b/Tests/Fragment/FragmentHandlerTest.php index 9c906b50a0..a625795fba 100644 --- a/Tests/Fragment/FragmentHandlerTest.php +++ b/Tests/Fragment/FragmentHandlerTest.php @@ -88,7 +88,7 @@ protected function getHandler($returnValue, $arguments = array()) ; if ($arguments) { - call_user_func_array(array($e, 'with'), $arguments); + \call_user_func_array(array($e, 'with'), $arguments); } $handler = new FragmentHandler($this->requestStack); diff --git a/Tests/HttpCache/EsiTest.php b/Tests/HttpCache/EsiTest.php index 28a566e0d2..f6921b1131 100644 --- a/Tests/HttpCache/EsiTest.php +++ b/Tests/HttpCache/EsiTest.php @@ -231,10 +231,10 @@ protected function getCache($request, $response) ->method('getRequest') ->will($this->returnValue($request)) ; - if (is_array($response)) { + if (\is_array($response)) { $cache->expects($this->any()) ->method('handle') - ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) + ->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) ; } else { $cache->expects($this->any()) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index f5b4000246..54d68e5b94 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -215,7 +215,7 @@ public function testValidatesPrivateResponsesCachedOnTheClient() if ($request->cookies->has('authenticated')) { $response->headers->set('Cache-Control', 'private, no-store'); $response->setETag('"private tag"'); - if (in_array('"private tag"', $etags)) { + if (\in_array('"private tag"', $etags)) { $response->setStatusCode(304); } else { $response->setStatusCode(200); @@ -225,7 +225,7 @@ public function testValidatesPrivateResponsesCachedOnTheClient() } else { $response->headers->set('Cache-Control', 'public'); $response->setETag('"public tag"'); - if (in_array('"public tag"', $etags)) { + if (\in_array('"public tag"', $etags)) { $response->setStatusCode(304); } else { $response->setStatusCode(200); @@ -958,7 +958,7 @@ public function testUsesCacheToRespondToHeadRequestsWhenFresh() $this->assertHttpKernelIsNotCalled(); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('', $this->response->getContent()); - $this->assertEquals(strlen('Hello World'), $this->response->headers->get('Content-Length')); + $this->assertEquals(\strlen('Hello World'), $this->response->headers->get('Content-Length')); } public function testSendsNoContentWhenFresh() diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index 96a66771a0..138924d15d 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -164,7 +164,7 @@ public static function clearDirectory($directory) $fp = opendir($directory); while (false !== $file = readdir($fp)) { - if (!in_array($file, array('.', '..'))) { + if (!\in_array($file, array('.', '..'))) { if (is_link($directory.'/'.$file)) { unlink($directory.'/'.$file); } elseif (is_dir($directory.'/'.$file)) { diff --git a/Tests/HttpCache/SsiTest.php b/Tests/HttpCache/SsiTest.php index 8634aff6f9..65846abb16 100644 --- a/Tests/HttpCache/SsiTest.php +++ b/Tests/HttpCache/SsiTest.php @@ -198,10 +198,10 @@ protected function getCache($request, $response) ->method('getRequest') ->will($this->returnValue($request)) ; - if (is_array($response)) { + if (\is_array($response)) { $cache->expects($this->any()) ->method('handle') - ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) + ->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) ; } else { $cache->expects($this->any()) diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index a6d6285481..3e2453d17c 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -142,7 +142,7 @@ public function testEnvParametersResourceIsAdded() ->method('getLogDir') ->will($this->returnValue(sys_get_temp_dir())); - $reflection = new \ReflectionClass(get_class($kernel)); + $reflection = new \ReflectionClass(\get_class($kernel)); $method = $reflection->getMethod('buildContainer'); $method->setAccessible(true); $method->invoke($kernel); @@ -799,7 +799,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu $bundle ->expects($this->any()) ->method('getName') - ->will($this->returnValue(null === $bundleName ? get_class($bundle) : $bundleName)) + ->will($this->returnValue(null === $bundleName ? \get_class($bundle) : $bundleName)) ; $bundle diff --git a/Tests/Profiler/Mock/MemcacheMock.php b/Tests/Profiler/Mock/MemcacheMock.php index 9ca9816802..52d7abed5f 100644 --- a/Tests/Profiler/Mock/MemcacheMock.php +++ b/Tests/Profiler/Mock/MemcacheMock.php @@ -172,7 +172,7 @@ public function get($key, &$flags = null) return false; } - if (is_array($key)) { + if (\is_array($key)) { $result = array(); foreach ($key as $k) { if (isset($this->storage[$k])) { diff --git a/Tests/Profiler/Mock/RedisMock.php b/Tests/Profiler/Mock/RedisMock.php index 91222c165b..866ce81218 100644 --- a/Tests/Profiler/Mock/RedisMock.php +++ b/Tests/Profiler/Mock/RedisMock.php @@ -148,7 +148,7 @@ public function append($key, $value) if (isset($this->storage[$key])) { $this->storeData($key, $this->getData($key).$value); - return strlen($this->storage[$key]); + return \strlen($this->storage[$key]); } return false; @@ -167,7 +167,7 @@ public function delete($key) return false; } - if (is_array($key)) { + if (\is_array($key)) { $result = 0; foreach ($key as $k) { if (isset($this->storage[$k])) { From d453c43feac252a9250442d0f52b4103fba603ef Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 26 Jul 2018 11:03:18 +0200 Subject: [PATCH 081/294] Alpha-ordering for "use" statements --- Bundle/Bundle.php | 8 +++---- Client.php | 6 ++--- Controller/TraceableControllerResolver.php | 2 +- DataCollector/ConfigDataCollector.php | 4 ++-- DataCollector/DumpDataCollector.php | 2 +- DataCollector/EventDataCollector.php | 4 ++-- DataCollector/RequestDataCollector.php | 4 ++-- DataCollector/RouterDataCollector.php | 2 +- Debug/TraceableEventDispatcher.php | 4 ++-- DependencyInjection/AddClassesToCachePass.php | 2 +- .../ContainerAwareHttpKernel.php | 10 ++++----- DependencyInjection/FragmentRendererPass.php | 2 +- Event/FilterControllerEvent.php | 2 +- Event/FilterResponseEvent.php | 2 +- Event/GetResponseForControllerResultEvent.php | 2 +- Event/GetResponseForExceptionEvent.php | 2 +- Event/KernelEvent.php | 4 ++-- Event/PostResponseEvent.php | 2 +- EventListener/AddRequestFormatsListener.php | 2 +- EventListener/DebugHandlersListener.php | 6 ++--- EventListener/ExceptionListener.php | 8 +++---- EventListener/FragmentListener.php | 4 ++-- EventListener/LocaleListener.php | 8 +++---- EventListener/ProfilerListener.php | 8 +++---- EventListener/ResponseListener.php | 2 +- EventListener/RouterListener.php | 12 +++++----- EventListener/SessionListener.php | 2 +- EventListener/StreamedResponseListener.php | 2 +- EventListener/SurrogateListener.php | 2 +- EventListener/TestSessionListener.php | 4 ++-- EventListener/TranslatorListener.php | 4 ++-- Fragment/FragmentHandler.php | 2 +- Fragment/FragmentRendererInterface.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 2 +- Fragment/InlineFragmentRenderer.php | 6 ++--- Fragment/RoutableFragmentRenderer.php | 2 +- HttpCache/HttpCache.php | 4 ++-- HttpKernel.php | 16 +++++++------- Kernel.php | 22 +++++++++---------- KernelInterface.php | 2 +- Profiler/Profiler.php | 2 +- Tests/Bundle/BundleTest.php | 4 ++-- Tests/ClientTest.php | 6 ++--- Tests/Controller/ControllerResolverTest.php | 2 +- .../DataCollector/ConfigDataCollectorTest.php | 4 ++-- Tests/DataCollector/DumpDataCollectorTest.php | 2 +- .../ExceptionDataCollectorTest.php | 2 +- .../DataCollector/MemoryDataCollectorTest.php | 2 +- .../RequestDataCollectorTest.php | 12 +++++----- Tests/DataCollector/TimeDataCollectorTest.php | 2 +- Tests/Debug/TraceableEventDispatcherTest.php | 4 ++-- .../ContainerAwareHttpKernelTest.php | 8 +++---- .../LazyLoadingFragmentHandlerTest.php | 2 +- .../AddRequestFormatsListenerTest.php | 2 +- .../DebugHandlersListenerTest.php | 2 +- Tests/EventListener/ExceptionListenerTest.php | 8 +++---- Tests/EventListener/FragmentListenerTest.php | 4 ++-- Tests/EventListener/LocaleListenerTest.php | 2 +- Tests/EventListener/ProfilerListenerTest.php | 2 +- Tests/EventListener/ResponseListenerTest.php | 6 ++--- Tests/EventListener/RouterListenerTest.php | 2 +- Tests/EventListener/SurrogateListenerTest.php | 12 +++++----- .../EventListener/TestSessionListenerTest.php | 6 ++--- .../ValidateRequestListenerTest.php | 2 +- Tests/Fixtures/123/Kernel123.php | 2 +- Tests/Fixtures/KernelForOverrideName.php | 2 +- Tests/Fixtures/KernelForTest.php | 2 +- Tests/Fragment/EsiFragmentRendererTest.php | 2 +- Tests/Fragment/FragmentHandlerTest.php | 2 +- .../Fragment/HIncludeFragmentRendererTest.php | 2 +- Tests/Fragment/InlineFragmentRendererTest.php | 8 +++---- Tests/Fragment/SsiFragmentRendererTest.php | 2 +- Tests/HttpCache/EsiTest.php | 2 +- Tests/HttpCache/HttpCacheTest.php | 4 ++-- Tests/HttpCache/TestHttpKernel.php | 6 ++--- Tests/HttpCache/TestMultipleHttpKernel.php | 6 ++--- Tests/HttpKernelTest.php | 12 +++++----- Tests/KernelTest.php | 10 ++++----- Tests/Profiler/MongoDbProfilerStorageTest.php | 6 ++--- Tests/Profiler/ProfilerTest.php | 4 ++-- Tests/TestHttpKernel.php | 4 ++-- 81 files changed, 181 insertions(+), 181 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 024754e05f..c99862a10f 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\Bundle; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Console\Application; -use Symfony\Component\Finder\Finder; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; +use Symfony\Component\Finder\Finder; /** * An implementation of BundleInterface that adds a few conventions diff --git a/Client.php b/Client.php index 63efc44f51..49f0e4c169 100644 --- a/Client.php +++ b/Client.php @@ -12,11 +12,11 @@ namespace Symfony\Component\HttpKernel; use Symfony\Component\BrowserKit\Client as BaseClient; -use Symfony\Component\BrowserKit\Request as DomRequest; -use Symfony\Component\BrowserKit\Response as DomResponse; use Symfony\Component\BrowserKit\Cookie as DomCookie; -use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\CookieJar; +use Symfony\Component\BrowserKit\History; +use Symfony\Component\BrowserKit\Request as DomRequest; +use Symfony\Component\BrowserKit\Response as DomResponse; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/Controller/TraceableControllerResolver.php b/Controller/TraceableControllerResolver.php index 2f27fe5c70..f1c03aa1ce 100644 --- a/Controller/TraceableControllerResolver.php +++ b/Controller/TraceableControllerResolver.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Controller; -use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Stopwatch\Stopwatch; /** * @author Fabien Potencier diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 45046eda8a..b52dbe777a 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -11,10 +11,10 @@ namespace Symfony\Component\HttpKernel\DataCollector; -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\HttpKernel\KernelInterface; /** * @author Fabien Potencier diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 5f57bed7f0..82457abee6 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -18,8 +18,8 @@ use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Symfony\Component\VarDumper\Dumper\DataDumperInterface; +use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Twig\Template; /** diff --git a/DataCollector/EventDataCollector.php b/DataCollector/EventDataCollector.php index 0a87bc3892..b91b0ba383 100644 --- a/DataCollector/EventDataCollector.php +++ b/DataCollector/EventDataCollector.php @@ -11,10 +11,10 @@ namespace Symfony\Component\HttpKernel\DataCollector; +use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; /** * EventDataCollector. diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index b6e1613a64..373bed3bc8 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\DataCollector; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\KernelEvents; /** * @author Fabien Potencier diff --git a/DataCollector/RouterDataCollector.php b/DataCollector/RouterDataCollector.php index b0a1417b6f..5d024e384e 100644 --- a/DataCollector/RouterDataCollector.php +++ b/DataCollector/RouterDataCollector.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\DataCollector; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; /** diff --git a/Debug/TraceableEventDispatcher.php b/Debug/TraceableEventDispatcher.php index 545b1c9f42..0d6cf7d26c 100644 --- a/Debug/TraceableEventDispatcher.php +++ b/Debug/TraceableEventDispatcher.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Debug; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher; -use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\Profiler\Profiler; /** * Collects some data about event listeners. diff --git a/DependencyInjection/AddClassesToCachePass.php b/DependencyInjection/AddClassesToCachePass.php index 09af6bd25d..a01d3614b8 100644 --- a/DependencyInjection/AddClassesToCachePass.php +++ b/DependencyInjection/AddClassesToCachePass.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; /** diff --git a/DependencyInjection/ContainerAwareHttpKernel.php b/DependencyInjection/ContainerAwareHttpKernel.php index a473838bf8..b1db5f3367 100644 --- a/DependencyInjection/ContainerAwareHttpKernel.php +++ b/DependencyInjection/ContainerAwareHttpKernel.php @@ -11,14 +11,14 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Scope; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Scope; +use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Adds a managed request scope. diff --git a/DependencyInjection/FragmentRendererPass.php b/DependencyInjection/FragmentRendererPass.php index 0c4cecef66..2e15f9ae2b 100644 --- a/DependencyInjection/FragmentRendererPass.php +++ b/DependencyInjection/FragmentRendererPass.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\DependencyInjection; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Adds services tagged kernel.fragment_renderer as HTTP content rendering strategies. diff --git a/Event/FilterControllerEvent.php b/Event/FilterControllerEvent.php index 19831faf02..3f29a67f72 100644 --- a/Event/FilterControllerEvent.php +++ b/Event/FilterControllerEvent.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows filtering of a controller callable. diff --git a/Event/FilterResponseEvent.php b/Event/FilterResponseEvent.php index 53a7efce76..1b80e34bab 100644 --- a/Event/FilterResponseEvent.php +++ b/Event/FilterResponseEvent.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to filter a Response object. diff --git a/Event/GetResponseForControllerResultEvent.php b/Event/GetResponseForControllerResultEvent.php index f70ce09e0a..d68eaa18c2 100644 --- a/Event/GetResponseForControllerResultEvent.php +++ b/Event/GetResponseForControllerResultEvent.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to create a response for the return value of a controller. diff --git a/Event/GetResponseForExceptionEvent.php b/Event/GetResponseForExceptionEvent.php index 003953feac..7d8a1d36bf 100644 --- a/Event/GetResponseForExceptionEvent.php +++ b/Event/GetResponseForExceptionEvent.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to create a response for a thrown exception. diff --git a/Event/KernelEvent.php b/Event/KernelEvent.php index 992f6b4dc0..cccf01f3da 100644 --- a/Event/KernelEvent.php +++ b/Event/KernelEvent.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Base class for events thrown in the HttpKernel component. diff --git a/Event/PostResponseEvent.php b/Event/PostResponseEvent.php index 2406fddbe8..0981e64c92 100644 --- a/Event/PostResponseEvent.php +++ b/Event/PostResponseEvent.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Allows to execute logic after a response was sent. diff --git a/EventListener/AddRequestFormatsListener.php b/EventListener/AddRequestFormatsListener.php index f21fc6ab7c..5ec528417c 100644 --- a/EventListener/AddRequestFormatsListener.php +++ b/EventListener/AddRequestFormatsListener.php @@ -12,8 +12,8 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\KernelEvents; /** * Adds configured formats to each request. diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index c0c68bc806..9c0b56132b 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -12,15 +12,15 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; +use Symfony\Component\Console\ConsoleEvents; +use Symfony\Component\Console\Event\ConsoleEvent; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Console\ConsoleEvents; -use Symfony\Component\Console\Event\ConsoleEvent; -use Symfony\Component\Console\Output\ConsoleOutputInterface; /** * Configures errors and exceptions handlers. diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index fa23e06bb1..f033e452d6 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -14,14 +14,14 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; /** * ExceptionListener. diff --git a/EventListener/FragmentListener.php b/EventListener/FragmentListener.php index 0420ecd1af..ecba72b99c 100644 --- a/EventListener/FragmentListener.php +++ b/EventListener/FragmentListener.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Handles content fragments represented by special URIs. diff --git a/EventListener/LocaleListener.php b/EventListener/LocaleListener.php index 36ef263075..de7f370e2f 100644 --- a/EventListener/LocaleListener.php +++ b/EventListener/LocaleListener.php @@ -11,13 +11,13 @@ namespace Symfony\Component\HttpKernel\EventListener; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +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\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Initializes the locale based on the current request. diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index cb634e8204..9592c9f911 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -11,15 +11,15 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpFoundation\RequestMatcherInterface; +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\RequestMatcherInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * ProfilerListener collects data for the current request by listening to the kernel events. diff --git a/EventListener/ResponseListener.php b/EventListener/ResponseListener.php index 6d56197a73..f24784527b 100644 --- a/EventListener/ResponseListener.php +++ b/EventListener/ResponseListener.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * ResponseListener fixes the Response headers based on the Request. diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index b02ca86f4a..63c9d20cfc 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -12,21 +12,21 @@ namespace Symfony\Component\HttpKernel\EventListener; use Psr\Log\LoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +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\KernelEvents; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; +use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; /** * Initializes the context from the request and sets request attributes based on a matching route. diff --git a/EventListener/SessionListener.php b/EventListener/SessionListener.php index 2d6adfa012..a198e1ac94 100644 --- a/EventListener/SessionListener.php +++ b/EventListener/SessionListener.php @@ -11,10 +11,10 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Sets the session in the request. diff --git a/EventListener/StreamedResponseListener.php b/EventListener/StreamedResponseListener.php index 671db5d827..2c616b9182 100644 --- a/EventListener/StreamedResponseListener.php +++ b/EventListener/StreamedResponseListener.php @@ -11,10 +11,10 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * StreamedResponseListener is responsible for sending the Response diff --git a/EventListener/SurrogateListener.php b/EventListener/SurrogateListener.php index 2f4e8449fb..8426cf20f9 100644 --- a/EventListener/SurrogateListener.php +++ b/EventListener/SurrogateListener.php @@ -11,10 +11,10 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * SurrogateListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for Surrogates. diff --git a/EventListener/TestSessionListener.php b/EventListener/TestSessionListener.php index 445caacd8a..a3e974edc6 100644 --- a/EventListener/TestSessionListener.php +++ b/EventListener/TestSessionListener.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\EventListener; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\KernelEvents; /** * TestSessionListener. diff --git a/EventListener/TranslatorListener.php b/EventListener/TranslatorListener.php index 6967ad0298..2a5fc71280 100644 --- a/EventListener/TranslatorListener.php +++ b/EventListener/TranslatorListener.php @@ -13,10 +13,10 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Translation\TranslatorInterface; /** diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 0a7ed907eb..7eebd3709d 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Fragment; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Controller\ControllerReference; /** diff --git a/Fragment/FragmentRendererInterface.php b/Fragment/FragmentRendererInterface.php index b177c3ac12..bcf4e9944a 100644 --- a/Fragment/FragmentRendererInterface.php +++ b/Fragment/FragmentRendererInterface.php @@ -12,8 +12,8 @@ namespace Symfony\Component\HttpKernel\Fragment; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Controller\ControllerReference; /** * Interface implemented by all rendering strategies. diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index 191f729b2c..b9c8cb9628 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -13,9 +13,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\EngineInterface; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\UriSigner; +use Symfony\Component\Templating\EngineInterface; use Twig\Environment; use Twig\Error\LoaderError; use Twig\Loader\ExistsLoaderInterface; diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index 76c8e95d79..d7d2e55a9e 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -11,13 +11,13 @@ namespace Symfony\Component\HttpKernel\Fragment; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\KernelEvents; /** * Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel. diff --git a/Fragment/RoutableFragmentRenderer.php b/Fragment/RoutableFragmentRenderer.php index 087995f290..0c1b95d4e9 100644 --- a/Fragment/RoutableFragmentRenderer.php +++ b/Fragment/RoutableFragmentRenderer.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Fragment; -use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\EventListener\FragmentListener; /** diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index 5f3acf1beb..de68eed942 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -15,10 +15,10 @@ namespace Symfony\Component\HttpKernel\HttpCache; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\TerminableInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\TerminableInterface; /** * Cache provides HTTP caching. diff --git a/HttpKernel.php b/HttpKernel.php index 8331d8a6c1..5571aa498d 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -11,10 +11,12 @@ namespace Symfony\Component\HttpKernel; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; @@ -22,11 +24,9 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * HttpKernel notifies events to convert a Request object to a Response one. diff --git a/Kernel.php b/Kernel.php index 1df4c2eddc..e07787699b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -13,27 +13,27 @@ use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\ClassLoader\ClassCollectionLoader; +use Symfony\Component\Config\ConfigCache; +use Symfony\Component\Config\Loader\DelegatingLoader; +use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\DependencyInjection\Loader\ClosureLoader; +use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; use Symfony\Component\DependencyInjection\Loader\IniFileLoader; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Config\EnvParametersResource; use Symfony\Component\HttpKernel\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; -use Symfony\Component\Config\Loader\LoaderResolver; -use Symfony\Component\Config\Loader\DelegatingLoader; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\ClassLoader\ClassCollectionLoader; +use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; /** * The Kernel is the heart of the Symfony system. diff --git a/KernelInterface.php b/KernelInterface.php index 3e2ffe2fb3..18b128c296 100644 --- a/KernelInterface.php +++ b/KernelInterface.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel; +use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\Config\Loader\LoaderInterface; /** * The Kernel is the heart of the Symfony system. diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index 7919203a67..1ccfccf9f0 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\Profiler; +use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; -use Psr\Log\LoggerInterface; /** * Profiler. diff --git a/Tests/Bundle/BundleTest.php b/Tests/Bundle/BundleTest.php index 7bae54630c..26cdb44580 100644 --- a/Tests/Bundle/BundleTest.php +++ b/Tests/Bundle/BundleTest.php @@ -13,10 +13,10 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle; -use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionAbsentBundle\ExtensionAbsentBundle; +use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionNotValidBundle\ExtensionNotValidBundle; use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand; +use Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\ExtensionPresentBundle; class BundleTest extends TestCase { diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index 158484d97b..27360441a2 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -12,11 +12,11 @@ namespace Symfony\Component\HttpKernel\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Client; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient; class ClientTest extends TestCase diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index 58ca07fc53..ad6ea544a9 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -13,10 +13,10 @@ use PHPUnit\Framework\TestCase; 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\VariadicController; -use Symfony\Component\HttpFoundation\Request; class ControllerResolverTest extends TestCase { diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index 50aa388631..0ac4d3cfbc 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -12,11 +12,11 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector; +use Symfony\Component\HttpKernel\Kernel; class ConfigDataCollectorTest extends TestCase { diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index 3b57168a52..22afd3a308 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Dumper\CliDumper; diff --git a/Tests/DataCollector/ExceptionDataCollectorTest.php b/Tests/DataCollector/ExceptionDataCollectorTest.php index afad9f58af..0f1c6d9f19 100644 --- a/Tests/DataCollector/ExceptionDataCollectorTest.php +++ b/Tests/DataCollector/ExceptionDataCollectorTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector; class ExceptionDataCollectorTest extends TestCase { diff --git a/Tests/DataCollector/MemoryDataCollectorTest.php b/Tests/DataCollector/MemoryDataCollectorTest.php index ab78e9e8e1..1435d05e83 100644 --- a/Tests/DataCollector/MemoryDataCollectorTest.php +++ b/Tests/DataCollector/MemoryDataCollectorTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector; class MemoryDataCollectorTest extends TestCase { diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 20bd1a8364..c496c4e124 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -12,14 +12,14 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; -use Symfony\Component\HttpKernel\Event\FilterControllerEvent; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; +use Symfony\Component\HttpKernel\Event\FilterControllerEvent; +use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; class RequestDataCollectorTest extends TestCase { diff --git a/Tests/DataCollector/TimeDataCollectorTest.php b/Tests/DataCollector/TimeDataCollectorTest.php index 814b958163..3c54939188 100644 --- a/Tests/DataCollector/TimeDataCollectorTest.php +++ b/Tests/DataCollector/TimeDataCollectorTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; /** * @group time-sensitive diff --git a/Tests/Debug/TraceableEventDispatcherTest.php b/Tests/Debug/TraceableEventDispatcherTest.php index d8c926f793..6e879057b4 100644 --- a/Tests/Debug/TraceableEventDispatcherTest.php +++ b/Tests/Debug/TraceableEventDispatcherTest.php @@ -13,10 +13,10 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; -use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; +use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\Stopwatch\Stopwatch; class TraceableEventDispatcherTest extends TestCase diff --git a/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php b/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php index cfe9a18546..ba0bc12066 100644 --- a/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php +++ b/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php @@ -12,12 +12,12 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * @group legacy diff --git a/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php b/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php index 63090d0503..c6bf6f9b22 100644 --- a/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php +++ b/Tests/DependencyInjection/LazyLoadingFragmentHandlerTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler; class LazyLoadingFragmentHandlerTest extends TestCase { diff --git a/Tests/EventListener/AddRequestFormatsListenerTest.php b/Tests/EventListener/AddRequestFormatsListenerTest.php index f4878f626f..3ffb9f3d63 100644 --- a/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -12,8 +12,8 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener; use Symfony\Component\HttpKernel\KernelEvents; /** diff --git a/Tests/EventListener/DebugHandlersListenerTest.php b/Tests/EventListener/DebugHandlersListenerTest.php index 467b8dde88..9a9c17edab 100644 --- a/Tests/EventListener/DebugHandlersListenerTest.php +++ b/Tests/EventListener/DebugHandlersListenerTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; -use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\ConsoleEvents; +use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Output\ConsoleOutput; diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index e6508554f2..0b73075e7b 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -13,14 +13,14 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\EventListener\ExceptionListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Tests\Logger; /** diff --git a/Tests/EventListener/FragmentListenerTest.php b/Tests/EventListener/FragmentListenerTest.php index 464b2ab462..edf0498265 100644 --- a/Tests/EventListener/FragmentListenerTest.php +++ b/Tests/EventListener/FragmentListenerTest.php @@ -12,10 +12,10 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\EventListener\FragmentListener; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\EventListener\FragmentListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\UriSigner; class FragmentListenerTest extends TestCase diff --git a/Tests/EventListener/LocaleListenerTest.php b/Tests/EventListener/LocaleListenerTest.php index 332393eead..f442235ad0 100644 --- a/Tests/EventListener/LocaleListenerTest.php +++ b/Tests/EventListener/LocaleListenerTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\EventListener\LocaleListener; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; class LocaleListenerTest extends TestCase { diff --git a/Tests/EventListener/ProfilerListenerTest.php b/Tests/EventListener/ProfilerListenerTest.php index 1a8748b368..a6d440a46c 100644 --- a/Tests/EventListener/ProfilerListenerTest.php +++ b/Tests/EventListener/ProfilerListenerTest.php @@ -13,11 +13,11 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent; +use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Kernel; diff --git a/Tests/EventListener/ResponseListenerTest.php b/Tests/EventListener/ResponseListenerTest.php index 12a31eb3ee..1d8960267d 100644 --- a/Tests/EventListener/ResponseListenerTest.php +++ b/Tests/EventListener/ResponseListenerTest.php @@ -12,13 +12,13 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\EventListener\ResponseListener; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\EventListener\ResponseListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\EventDispatcher\EventDispatcher; class ResponseListenerTest extends TestCase { diff --git a/Tests/EventListener/RouterListenerTest.php b/Tests/EventListener/RouterListenerTest.php index 0d3c558546..4570cc3be8 100644 --- a/Tests/EventListener/RouterListenerTest.php +++ b/Tests/EventListener/RouterListenerTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\EventListener\RouterListener; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Routing\RequestContext; class RouterListenerTest extends TestCase diff --git a/Tests/EventListener/SurrogateListenerTest.php b/Tests/EventListener/SurrogateListenerTest.php index 1e79ebe052..b955c07d47 100644 --- a/Tests/EventListener/SurrogateListenerTest.php +++ b/Tests/EventListener/SurrogateListenerTest.php @@ -12,14 +12,14 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\EventListener\SurrogateListener; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; -use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\EventListener\SurrogateListener; +use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpKernel\KernelEvents; class SurrogateListenerTest extends TestCase { diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index 47ee153342..e91a742b1a 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -12,11 +12,11 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * SessionListenerTest. diff --git a/Tests/EventListener/ValidateRequestListenerTest.php b/Tests/EventListener/ValidateRequestListenerTest.php index 388f1b814b..c46f2ee6b1 100644 --- a/Tests/EventListener/ValidateRequestListenerTest.php +++ b/Tests/EventListener/ValidateRequestListenerTest.php @@ -14,8 +14,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; diff --git a/Tests/Fixtures/123/Kernel123.php b/Tests/Fixtures/123/Kernel123.php index b6cf1cba20..d3a76684df 100644 --- a/Tests/Fixtures/123/Kernel123.php +++ b/Tests/Fixtures/123/Kernel123.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures\_123; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Kernel; class Kernel123 extends Kernel { diff --git a/Tests/Fixtures/KernelForOverrideName.php b/Tests/Fixtures/KernelForOverrideName.php index a1102ab784..f7baaa6325 100644 --- a/Tests/Fixtures/KernelForOverrideName.php +++ b/Tests/Fixtures/KernelForOverrideName.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Kernel; class KernelForOverrideName extends Kernel { diff --git a/Tests/Fixtures/KernelForTest.php b/Tests/Fixtures/KernelForTest.php index 5fd61bbc7e..9acee4cac5 100644 --- a/Tests/Fixtures/KernelForTest.php +++ b/Tests/Fixtures/KernelForTest.php @@ -11,8 +11,8 @@ namespace Symfony\Component\HttpKernel\Tests\Fixtures; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Kernel; class KernelForTest extends Kernel { diff --git a/Tests/Fragment/EsiFragmentRendererTest.php b/Tests/Fragment/EsiFragmentRendererTest.php index 6cefea6b02..b0c0bacb72 100644 --- a/Tests/Fragment/EsiFragmentRendererTest.php +++ b/Tests/Fragment/EsiFragmentRendererTest.php @@ -12,10 +12,10 @@ namespace Symfony\Component\HttpKernel\Tests\Fragment; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\UriSigner; class EsiFragmentRendererTest extends TestCase diff --git a/Tests/Fragment/FragmentHandlerTest.php b/Tests/Fragment/FragmentHandlerTest.php index a625795fba..a296aa0e18 100644 --- a/Tests/Fragment/FragmentHandlerTest.php +++ b/Tests/Fragment/FragmentHandlerTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Tests\Fragment; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Fragment\FragmentHandler; /** * @group time-sensitive diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index 7171c71bc3..10fbccf0fa 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -12,10 +12,10 @@ namespace Symfony\Component\HttpKernel\Tests\Fragment; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; use Symfony\Component\HttpKernel\UriSigner; -use Symfony\Component\HttpFoundation\Request; class HIncludeFragmentRendererTest extends TestCase { diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 998b372181..bb56536c58 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -12,13 +12,13 @@ namespace Symfony\Component\HttpKernel\Tests\Fragment; use PHPUnit\Framework\TestCase; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer; +use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\EventDispatcher\EventDispatcher; class InlineFragmentRendererTest extends TestCase { diff --git a/Tests/Fragment/SsiFragmentRendererTest.php b/Tests/Fragment/SsiFragmentRendererTest.php index b537625f24..f725803118 100644 --- a/Tests/Fragment/SsiFragmentRendererTest.php +++ b/Tests/Fragment/SsiFragmentRendererTest.php @@ -12,10 +12,10 @@ namespace Symfony\Component\HttpKernel\Tests\Fragment; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Ssi; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\UriSigner; class SsiFragmentRendererTest extends TestCase diff --git a/Tests/HttpCache/EsiTest.php b/Tests/HttpCache/EsiTest.php index f6921b1131..ab24e1c69e 100644 --- a/Tests/HttpCache/EsiTest.php +++ b/Tests/HttpCache/EsiTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\HttpKernel\Tests\HttpCache; use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpCache\Esi; class EsiTest extends TestCase { diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 54d68e5b94..7231fc1c8e 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -11,10 +11,10 @@ namespace Symfony\Component\HttpKernel\Tests\HttpCache; -use Symfony\Component\HttpKernel\HttpCache\Esi; -use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpCache\Esi; +use Symfony\Component\HttpKernel\HttpCache\HttpCache; use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\HttpKernel\HttpKernelInterface; diff --git a/Tests/HttpCache/TestHttpKernel.php b/Tests/HttpCache/TestHttpKernel.php index 5546ba2ed8..198eafd2bf 100644 --- a/Tests/HttpCache/TestHttpKernel.php +++ b/Tests/HttpCache/TestHttpKernel.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\Tests\HttpCache; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; class TestHttpKernel extends HttpKernel implements ControllerResolverInterface { diff --git a/Tests/HttpCache/TestMultipleHttpKernel.php b/Tests/HttpCache/TestMultipleHttpKernel.php index 5b5209e9a6..5be898de40 100644 --- a/Tests/HttpCache/TestMultipleHttpKernel.php +++ b/Tests/HttpCache/TestMultipleHttpKernel.php @@ -11,12 +11,12 @@ namespace Symfony\Component\HttpKernel\Tests\HttpCache; -use Symfony\Component\HttpKernel\HttpKernel; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\HttpKernel\HttpKernelInterface; class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface { diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 22d9907e5c..d7c217569d 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -12,15 +12,15 @@ namespace Symfony\Component\HttpKernel\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\EventDispatcher\EventDispatcher; class HttpKernelTest extends TestCase { diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 3e2453d17c..fb3f628c26 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -14,15 +14,15 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Config\EnvParametersResource; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; -use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Tests\Fixtures\FooBarBundle; +use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName; +use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest; class KernelTest extends TestCase { diff --git a/Tests/Profiler/MongoDbProfilerStorageTest.php b/Tests/Profiler/MongoDbProfilerStorageTest.php index 2d093dfd37..24a0cfebf5 100644 --- a/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler; -use Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage; -use Symfony\Component\HttpKernel\Profiler\Profile; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\DataCollector; +use Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage; +use Symfony\Component\HttpKernel\Profiler\Profile; class MongoDbProfilerStorageTestDataCollector extends DataCollector { diff --git a/Tests/Profiler/ProfilerTest.php b/Tests/Profiler/ProfilerTest.php index 6b2c57a076..1c76337b70 100644 --- a/Tests/Profiler/ProfilerTest.php +++ b/Tests/Profiler/ProfilerTest.php @@ -12,11 +12,11 @@ namespace Symfony\Component\HttpKernel\Tests\Profiler; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector; use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage; use Symfony\Component\HttpKernel\Profiler\Profiler; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; class ProfilerTest extends TestCase { diff --git a/Tests/TestHttpKernel.php b/Tests/TestHttpKernel.php index d526c4de80..69474dce4d 100644 --- a/Tests/TestHttpKernel.php +++ b/Tests/TestHttpKernel.php @@ -11,11 +11,11 @@ namespace Symfony\Component\HttpKernel\Tests; -use Symfony\Component\HttpKernel\HttpKernel; +use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpKernel\HttpKernel; class TestHttpKernel extends HttpKernel implements ControllerResolverInterface { From 572e195e1b40a742382f73bda8de27227013b7ef Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 26 Jul 2018 12:58:07 +0200 Subject: [PATCH 082/294] Fix tests for legacy phpunit versions --- Profiler/Profile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Profiler/Profile.php b/Profiler/Profile.php index 490f406e26..c21c9d38a3 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -74,7 +74,7 @@ public function getToken() /** * Sets the parent token. */ - public function setParent(self $parent) + public function setParent(Profile $parent) { $this->parent = $parent; } @@ -213,7 +213,7 @@ public function setChildren(array $children) /** * Adds the child token. */ - public function addChild(self $child) + public function addChild(Profile $child) { $this->children[] = $child; $child->setParent($this); From ec68e19b5f67cee87e81db3ff08f67d6a78e9f98 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 26 Jul 2018 13:13:39 +0200 Subject: [PATCH 083/294] Enable native_constant_invocation CS fixer --- DataCollector/ConfigDataCollector.php | 2 +- DataCollector/DumpDataCollector.php | 2 +- HttpCache/Store.php | 2 +- Tests/KernelTest.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index b52dbe777a..8d8ea1a3e3 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -68,7 +68,7 @@ public function collect(Request $request, Response $response, \Exception $except 'wincache_enabled' => \extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), - 'sapi_name' => PHP_SAPI, + 'sapi_name' => \PHP_SAPI, ); if (isset($this->kernel)) { diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 82457abee6..dbec7ea16a 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -246,7 +246,7 @@ public function __destruct() --$i; } - if (!\in_array(PHP_SAPI, array('cli', 'phpdbg'), true) && stripos($h[$i], 'html')) { + if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true) && stripos($h[$i], 'html')) { $this->dumper = new HtmlDumper('php://output', $this->charset); } else { $this->dumper = new CliDumper('php://output', $this->charset); diff --git a/HttpCache/Store.php b/HttpCache/Store.php index fcdd7fa5e6..990091d065 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -412,7 +412,7 @@ private function save($key, $data) public function getPath($key) { - return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6); + return $this->root.\DIRECTORY_SEPARATOR.substr($key, 0, 2).\DIRECTORY_SEPARATOR.substr($key, 2, 2).\DIRECTORY_SEPARATOR.substr($key, 4, 2).\DIRECTORY_SEPARATOR.substr($key, 6); } /** diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index fb3f628c26..1a21267935 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -313,7 +313,7 @@ public function doStuff() // Heredocs are preserved, making the output mixing Unix and Windows line // endings, switching to "\n" everywhere on Windows to avoid failure. - if ('\\' === DIRECTORY_SEPARATOR) { + if ('\\' === \DIRECTORY_SEPARATOR) { $expected = str_replace("\r\n", "\n", $expected); $output = str_replace("\r\n", "\n", $output); } @@ -367,7 +367,7 @@ public function testGetRootDir() { $kernel = new KernelForTest('test', true); - $this->assertEquals(__DIR__.DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir())); + $this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir())); } public function testGetName() From 639f3d4f06cd81a4fb3d1a85509bbb1080ee6401 Mon Sep 17 00:00:00 2001 From: Zacharias Luiten Date: Thu, 19 Jul 2018 15:02:57 +0200 Subject: [PATCH 084/294] [HttpKernel] Fixed invalid REMOTE_ADDR in inline subrequest when configuring trusted proxy with subnet --- Fragment/InlineFragmentRenderer.php | 14 ++++++++++++-- Tests/Fragment/InlineFragmentRendererTest.php | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index d7d2e55a9e..31cfb0de09 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -122,8 +122,7 @@ protected function createSubRequest($uri, Request $request) // Do nothing } - $trustedProxies = Request::getTrustedProxies(); - $server['REMOTE_ADDR'] = $trustedProxies ? reset($trustedProxies) : '127.0.0.1'; + $server['REMOTE_ADDR'] = $this->resolveTrustedProxy(); unset($server['HTTP_IF_MODIFIED_SINCE']); unset($server['HTTP_IF_NONE_MATCH']); @@ -140,6 +139,17 @@ protected function createSubRequest($uri, Request $request) return $subRequest; } + private function resolveTrustedProxy() + { + if (!$trustedProxies = Request::getTrustedProxies()) { + return '127.0.0.1'; + } + + $firstTrustedProxy = reset($trustedProxies); + + return false !== ($i = strpos($firstTrustedProxy, '/')) ? substr($firstTrustedProxy, 0, $i) : $firstTrustedProxy; + } + /** * {@inheritdoc} */ diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index bb56536c58..481dcc7f4b 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -226,6 +226,25 @@ public function testFirstTrustedProxyIsSetAsRemote() Request::setTrustedProxies(array()); } + public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() + { + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + + Request::setTrustedProxies(array('1.1.1.1/24')); + + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); + + $request = Request::create('/'); + $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); + $strategy->render('/', $request); + + Request::setTrustedProxies(array()); + } + /** * Creates a Kernel expecting a request equals to $request * Allows delta in comparison in case REQUEST_TIME changed by 1 second. From 59cb60c63dbea55416842f3e006f66ccd15abd4e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 31 Jul 2018 14:39:31 +0200 Subject: [PATCH 085/294] [HttpKernel] fix trusted headers management in HttpCache and InlineFragmentRenderer --- Fragment/InlineFragmentRenderer.php | 29 +-- HttpCache/HttpCache.php | 21 +-- HttpCache/SubRequestHandler.php | 100 +++++++++++ Tests/Fragment/InlineFragmentRendererTest.php | 38 ++-- Tests/HttpCache/HttpCacheTest.php | 54 +++--- Tests/HttpCache/SubRequestHandlerTest.php | 168 ++++++++++++++++++ Tests/HttpCache/TestHttpKernel.php | 27 ++- 7 files changed, 345 insertions(+), 92 deletions(-) create mode 100644 HttpCache/SubRequestHandler.php create mode 100644 Tests/HttpCache/SubRequestHandlerTest.php diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index 31cfb0de09..712248578d 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; +use Symfony\Component\HttpKernel\HttpCache\SubRequestHandler; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -76,7 +77,7 @@ public function render($uri, Request $request, array $options = array()) $level = ob_get_level(); try { - return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false); + return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false); } catch (\Exception $e) { // we dispatch the exception event to trigger the logging // the response that comes back is simply ignored @@ -109,21 +110,6 @@ protected function createSubRequest($uri, Request $request) $cookies = $request->cookies->all(); $server = $request->server->all(); - // Override the arguments to emulate a sub-request. - // Sub-request object will point to localhost as client ip and real client ip - // will be included into trusted header for client ip - try { - if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { - $currentXForwardedFor = $request->headers->get($trustedHeaderName, ''); - - $server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp(); - } - } catch (\InvalidArgumentException $e) { - // Do nothing - } - - $server['REMOTE_ADDR'] = $this->resolveTrustedProxy(); - unset($server['HTTP_IF_MODIFIED_SINCE']); unset($server['HTTP_IF_NONE_MATCH']); @@ -139,17 +125,6 @@ protected function createSubRequest($uri, Request $request) return $subRequest; } - private function resolveTrustedProxy() - { - if (!$trustedProxies = Request::getTrustedProxies()) { - return '127.0.0.1'; - } - - $firstTrustedProxy = reset($trustedProxies); - - return false !== ($i = strpos($firstTrustedProxy, '/')) ? substr($firstTrustedProxy, 0, $i) : $firstTrustedProxy; - } - /** * {@inheritdoc} */ diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index de68eed942..f54c87aa4a 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -468,27 +468,8 @@ protected function forward(Request $request, $catch = false, Response $entry = n $this->surrogate->addSurrogateCapability($request); } - // modify the X-Forwarded-For header if needed - $forwardedFor = $request->headers->get('X-Forwarded-For'); - if ($forwardedFor) { - $request->headers->set('X-Forwarded-For', $forwardedFor.', '.$request->server->get('REMOTE_ADDR')); - } else { - $request->headers->set('X-Forwarded-For', $request->server->get('REMOTE_ADDR')); - } - - // fix the client IP address by setting it to 127.0.0.1 as HttpCache - // is always called from the same process as the backend. - $request->server->set('REMOTE_ADDR', '127.0.0.1'); - - // make sure HttpCache is a trusted proxy - if (!\in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { - $trustedProxies[] = '127.0.0.1'; - Request::setTrustedProxies($trustedProxies); - } - // always a "master" request (as the real master request can be in cache) - $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); - // FIXME: we probably need to also catch exceptions if raw === true + $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(), array(500, 502, 503, 504))) { diff --git a/HttpCache/SubRequestHandler.php b/HttpCache/SubRequestHandler.php new file mode 100644 index 0000000000..c050256025 --- /dev/null +++ b/HttpCache/SubRequestHandler.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\HttpCache; + +use Symfony\Component\HttpFoundation\IpUtils; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; + +/** + * @author Nicolas Grekas + * + * @internal + */ +class SubRequestHandler +{ + /** + * @return Response + */ + public static function handle(HttpKernelInterface $kernel, Request $request, $type, $catch) + { + // save global state related to trusted headers and proxies + $trustedProxies = Request::getTrustedProxies(); + $trustedHeaders = array( + Request::HEADER_FORWARDED => Request::getTrustedHeaderName(Request::HEADER_FORWARDED), + Request::HEADER_CLIENT_IP => Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP), + Request::HEADER_CLIENT_HOST => Request::getTrustedHeaderName(Request::HEADER_CLIENT_HOST), + Request::HEADER_CLIENT_PROTO => Request::getTrustedHeaderName(Request::HEADER_CLIENT_PROTO), + Request::HEADER_CLIENT_PORT => Request::getTrustedHeaderName(Request::HEADER_CLIENT_PORT), + ); + + // remove untrusted values + $remoteAddr = $request->server->get('REMOTE_ADDR'); + if (!IpUtils::checkIp($remoteAddr, $trustedProxies)) { + foreach (array_filter($trustedHeaders) as $name) { + $request->headers->remove($name); + } + } + + // compute trusted values, taking any trusted proxies into account + $trustedIps = array(); + $trustedValues = array(); + foreach (array_reverse($request->getClientIps()) as $ip) { + $trustedIps[] = $ip; + $trustedValues[] = sprintf('for="%s"', $ip); + } + if ($ip !== $remoteAddr) { + $trustedIps[] = $remoteAddr; + $trustedValues[] = sprintf('for="%s"', $remoteAddr); + } + + // set trusted values, reusing as much as possible the global trusted settings + if ($name = $trustedHeaders[Request::HEADER_FORWARDED]) { + $trustedValues[0] .= sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); + $request->headers->set($name, implode(', ', $trustedValues)); + } + if ($name = $trustedHeaders[Request::HEADER_CLIENT_IP]) { + $request->headers->set($name, implode(', ', $trustedIps)); + } + if (!$name && !$trustedHeaders[Request::HEADER_FORWARDED]) { + $request->headers->set('X-Forwarded-For', implode(', ', $trustedIps)); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_FORWARDED_FOR'); + } + + // fix the client IP address by setting it to 127.0.0.1, + // which is the core responsibility of this method + $request->server->set('REMOTE_ADDR', '127.0.0.1'); + + // ensure 127.0.0.1 is set as trusted proxy + if (!IpUtils::checkIp('127.0.0.1', $trustedProxies)) { + Request::setTrustedProxies(array_merge($trustedProxies, array('127.0.0.1'))); + } + + try { + $e = null; + $response = $kernel->handle($request, $type, $catch); + } catch (\Throwable $e) { + } catch (\Exception $e) { + } + + // restore global state + Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaders[Request::HEADER_CLIENT_IP]); + Request::setTrustedProxies($trustedProxies); + + if (null !== $e) { + throw $e; + } + + return $response; + } +} diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 481dcc7f4b..a955da20aa 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -26,12 +26,16 @@ class InlineFragmentRendererTest extends TestCase protected function setUp() { - $this->originalTrustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP); + $this->originalTrustedHeaderNames = array( + Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP), + Request::getTrustedHeaderName(Request::HEADER_FORWARDED), + ); } protected function tearDown() { - Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $this->originalTrustedHeaderName); + Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $this->originalTrustedHeaderNames[0]); + Request::setTrustedHeaderName(Request::HEADER_FORWARDED, $this->originalTrustedHeaderNames[1]); } public function testRender() @@ -55,7 +59,7 @@ public function testRenderWithObjectsAsAttributes() $subRequest = Request::create('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller'); $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $subRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); @@ -83,8 +87,12 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController( public function testRenderWithTrustedHeaderDisabled() { Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, ''); + Request::setTrustedHeaderName(Request::HEADER_FORWARDED, ''); - $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/'))); + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); } @@ -168,11 +176,10 @@ public function testESIHeaderIsKeptInSubrequest() { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } + $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); @@ -194,10 +201,8 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled() public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() { $expectedSubRequest = Request::create('/'); - if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - } + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*')); @@ -208,12 +213,9 @@ public function testFirstTrustedProxyIsSetAsRemote() { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); - - if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); - } + $expectedSubRequest->server->set('REMOTE_ADDR', '127.0.0.1'); + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); Request::setTrustedProxies(array('1.1.1.1')); @@ -230,9 +232,9 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); - $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); + $expectedSubRequest->server->set('REMOTE_ADDR', '127.0.0.1'); $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); Request::setTrustedProxies(array('1.1.1.1/24')); diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 7231fc1c8e..102d7644ed 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -1303,20 +1303,29 @@ public function testClientIpIsAlwaysLocalhostForForwardedRequests() $this->setNextResponse(); $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); - $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); + $that = $this; + $this->kernel->assert(function ($backendRequest) use ($that) { + $that->assertSame('127.0.0.1', $backendRequest->server->get('REMOTE_ADDR')); + }); } /** * @dataProvider getTrustedProxyData */ - public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected) + public function testHttpCacheIsSetAsATrustedProxy(array $existing) { Request::setTrustedProxies($existing); $this->setNextResponse(); $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); + $this->assertSame($existing, Request::getTrustedProxies()); - $this->assertEquals($expected, Request::getTrustedProxies()); + $that = $this; + $existing = array_unique(array_merge($existing, array('127.0.0.1'))); + $this->kernel->assert(function ($backendRequest) use ($existing, $that) { + $that->assertSame($existing, Request::getTrustedProxies()); + $that->assertsame('10.0.0.1', $backendRequest->getClientIp()); + }); Request::setTrustedProxies(array()); } @@ -1324,45 +1333,42 @@ public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expect public function getTrustedProxyData() { return array( - array(array(), array('127.0.0.1')), - array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')), - array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')), + array(array()), + array(array('10.0.0.2')), + array(array('10.0.0.2', '127.0.0.1')), ); } /** - * @dataProvider getXForwardedForData + * @dataProvider getForwardedData */ - public function testXForwarderForHeaderForForwardedRequests($xForwardedFor, $expected) + public function testForwarderHeaderForForwardedRequests($forwarded, $expected) { $this->setNextResponse(); $server = array('REMOTE_ADDR' => '10.0.0.1'); - if (false !== $xForwardedFor) { - $server['HTTP_X_FORWARDED_FOR'] = $xForwardedFor; + if (null !== $forwarded) { + Request::setTrustedProxies($server); + $server['HTTP_FORWARDED'] = $forwarded; } $this->request('GET', '/', $server); - $this->assertEquals($expected, $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); + $that = $this; + $this->kernel->assert(function ($backendRequest) use ($expected, $that) { + $that->assertSame($expected, $backendRequest->headers->get('Forwarded')); + }); + + Request::setTrustedProxies(array()); } - public function getXForwardedForData() + public function getForwardedData() { return array( - array(false, '10.0.0.1'), - array('10.0.0.2', '10.0.0.2, 10.0.0.1'), - array('10.0.0.2, 10.0.0.3', '10.0.0.2, 10.0.0.3, 10.0.0.1'), + array(null, 'for="10.0.0.1";host="localhost";proto=http'), + array('for=10.0.0.2', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.1"'), + array('for=10.0.0.2, for=10.0.0.3', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.3", for="10.0.0.1"'), ); } - public function testXForwarderForHeaderForPassRequests() - { - $this->setNextResponse(); - $server = array('REMOTE_ADDR' => '10.0.0.1'); - $this->request('POST', '/', $server); - - $this->assertEquals('10.0.0.1', $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); - } - public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses() { $time = \DateTime::createFromFormat('U', time()); diff --git a/Tests/HttpCache/SubRequestHandlerTest.php b/Tests/HttpCache/SubRequestHandlerTest.php new file mode 100644 index 0000000000..395bc06445 --- /dev/null +++ b/Tests/HttpCache/SubRequestHandlerTest.php @@ -0,0 +1,168 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\HttpCache; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpCache\SubRequestHandler; +use Symfony\Component\HttpKernel\HttpKernelInterface; + +class SubRequestHandlerTest extends TestCase +{ + private static $globalState; + + protected function setUp() + { + self::$globalState = $this->getGlobalState(); + } + + protected function tearDown() + { + foreach (self::$globalState[1] as $key => $name) { + Request::setTrustedHeaderName($key, $name); + } + Request::setTrustedProxies(self::$globalState[0]); + } + + public function testTrustedHeadersAreKept() + { + Request::setTrustedProxies(array('10.0.0.1')); + $globalState = $this->getGlobalState(); + + $request = Request::create('/'); + $request->server->set('REMOTE_ADDR', '10.0.0.1'); + $request->headers->set('X-Forwarded-For', '10.0.0.2'); + $request->headers->set('X-Forwarded-Host', 'Good'); + $request->headers->set('X-Forwarded-Port', '1234'); + $request->headers->set('X-Forwarded-Proto', 'https'); + + $that = $this; + $kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) use ($that) { + $that->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); + $that->assertSame('10.0.0.2', $request->getClientIp()); + $that->assertSame('Good', $request->headers->get('X-Forwarded-Host')); + $that->assertSame('1234', $request->headers->get('X-Forwarded-Port')); + $that->assertSame('https', $request->headers->get('X-Forwarded-Proto')); + }); + + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + + $this->assertSame($globalState, $this->getGlobalState()); + } + + public function testUntrustedHeadersAreRemoved() + { + $request = Request::create('/'); + $request->server->set('REMOTE_ADDR', '10.0.0.1'); + $request->headers->set('X-Forwarded-For', '10.0.0.2'); + $request->headers->set('X-Forwarded-Host', 'Evil'); + $request->headers->set('X-Forwarded-Port', '1234'); + $request->headers->set('X-Forwarded-Proto', 'http'); + $request->headers->set('Forwarded', 'Evil2'); + + $that = $this; + $kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) use ($that) { + $that->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); + $that->assertSame('10.0.0.1', $request->getClientIp()); + $that->assertFalse($request->headers->has('X-Forwarded-Host')); + $that->assertFalse($request->headers->has('X-Forwarded-Port')); + $that->assertFalse($request->headers->has('X-Forwarded-Proto')); + $that->assertSame('for="10.0.0.1";host="localhost";proto=http', $request->headers->get('Forwarded')); + }); + + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + + $this->assertSame(self::$globalState, $this->getGlobalState()); + } + + public function testTrustedForwardedHeader() + { + Request::setTrustedProxies(array('10.0.0.1')); + $globalState = $this->getGlobalState(); + + $request = Request::create('/'); + $request->server->set('REMOTE_ADDR', '10.0.0.1'); + $request->headers->set('Forwarded', 'for="10.0.0.2";host="foo.bar";proto=https'); + $request->headers->set('X-Forwarded-Host', 'foo.bar'); + $request->headers->set('X-Forwarded-Proto', 'https'); + + $that = $this; + $kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) use ($that) { + $that->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); + $that->assertSame('10.0.0.2', $request->getClientIp()); + $that->assertSame('foo.bar', $request->getHttpHost()); + $that->assertSame('https', $request->getScheme()); + $that->assertSame(443, $request->getPort()); + }); + + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + + $this->assertSame($globalState, $this->getGlobalState()); + } + + public function testTrustedXForwardedForHeader() + { + Request::setTrustedProxies(array('10.0.0.1')); + $globalState = $this->getGlobalState(); + + $request = Request::create('/'); + $request->server->set('REMOTE_ADDR', '10.0.0.1'); + $request->headers->set('X-Forwarded-For', '10.0.0.2'); + $request->headers->set('X-Forwarded-Host', 'foo.bar'); + $request->headers->set('X-Forwarded-Proto', 'https'); + + $that = $this; + $kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) use ($that) { + $that->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR')); + $that->assertSame('10.0.0.2', $request->getClientIp()); + $that->assertSame('foo.bar', $request->getHttpHost()); + $that->assertSame('https', $request->getScheme()); + }); + + SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true); + + $this->assertSame($globalState, $this->getGlobalState()); + } + + private function getGlobalState() + { + return array( + Request::getTrustedProxies(), + array( + Request::HEADER_FORWARDED => Request::getTrustedHeaderName(Request::HEADER_FORWARDED), + Request::HEADER_CLIENT_IP => Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP), + Request::HEADER_CLIENT_HOST => Request::getTrustedHeaderName(Request::HEADER_CLIENT_HOST), + Request::HEADER_CLIENT_PROTO => Request::getTrustedHeaderName(Request::HEADER_CLIENT_PROTO), + Request::HEADER_CLIENT_PORT => Request::getTrustedHeaderName(Request::HEADER_CLIENT_PORT), + ), + ); + } +} + +class TestSubRequestHandlerKernel implements HttpKernelInterface +{ + private $assertCallback; + + public function __construct(\Closure $assertCallback) + { + $this->assertCallback = $assertCallback; + } + + public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) + { + $assertCallback = $this->assertCallback; + $assertCallback($request, $type, $catch); + + return new Response(); + } +} diff --git a/Tests/HttpCache/TestHttpKernel.php b/Tests/HttpCache/TestHttpKernel.php index 198eafd2bf..429708416d 100644 --- a/Tests/HttpCache/TestHttpKernel.php +++ b/Tests/HttpCache/TestHttpKernel.php @@ -34,19 +34,40 @@ public function __construct($body, $status, $headers, \Closure $customizer = nul $this->status = $status; $this->headers = $headers; $this->customizer = $customizer; + $this->trustedHeadersReflector = new \ReflectionProperty('Symfony\Component\HttpFoundation\Request', 'trustedHeaders'); + $this->trustedHeadersReflector->setAccessible(true); parent::__construct(new EventDispatcher(), $this); } - public function getBackendRequest() + public function assert(\Closure $callback) { - return $this->backendRequest; + $trustedConfig = array(Request::getTrustedProxies(), $this->trustedHeadersReflector->getValue()); + + list($trustedProxies, $trustedHeaders, $backendRequest) = $this->backendRequest; + Request::setTrustedProxies($trustedProxies); + $this->trustedHeadersReflector->setValue(null, $trustedHeaders); + + try { + $e = null; + $callback($backendRequest); + } catch (\Throwable $e) { + } catch (\Exception $e) { + } + + list($trustedProxies, $trustedHeaders) = $trustedConfig; + Request::setTrustedProxies($trustedProxies); + $this->trustedHeadersReflector->setValue(null, $trustedHeaders); + + if (null !== $e) { + throw $e; + } } public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) { $this->catch = $catch; - $this->backendRequest = $request; + $this->backendRequest = array($request::getTrustedProxies(), $this->trustedHeadersReflector->getValue(), $request); return parent::handle($request, $type, $catch); } From 3ee21e3eb52327514d1fc754d1e0c9c85bceeb3a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 1 Aug 2018 16:12:31 +0200 Subject: [PATCH 086/294] updated VERSION for 2.8.44 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index e07787699b..f9b22f7700 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.44-DEV'; + const VERSION = '2.8.44'; const VERSION_ID = 20844; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 44; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From a5a5f3c297e89122700b87664c4cb57f3330e9a1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 1 Aug 2018 16:46:30 +0200 Subject: [PATCH 087/294] bumped Symfony version to 2.8.45 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f9b22f7700..32a9057834 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.44'; - const VERSION_ID = 20844; + const VERSION = '2.8.45-DEV'; + const VERSION_ID = 20845; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 44; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 45; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 8e84cc498f0ffecfbabdea78b87828fd66189544 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 1 Aug 2018 16:47:47 +0200 Subject: [PATCH 088/294] updated VERSION for 3.4.14 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0093048618..0684f22a03 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.14-DEV'; + const VERSION = '3.4.14'; const VERSION_ID = 30414; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 14; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 59e68a6840549f6b7d534a85df1dd1b76b813c26 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 1 Aug 2018 16:55:31 +0200 Subject: [PATCH 089/294] bumped Symfony version to 3.4.15 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0684f22a03..0f4eeeb58a 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.14'; - const VERSION_ID = 30414; + const VERSION = '3.4.15-DEV'; + const VERSION_ID = 30415; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 14; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 15; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 480dd83a159c8fd631fac35bf9cf4d1daddf5be2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 22 Aug 2018 17:17:35 +0200 Subject: [PATCH 090/294] [HttpKernel] fix forwarding trusted headers as server parameters --- HttpCache/SubRequestHandler.php | 10 +++++++--- Tests/Fragment/InlineFragmentRendererTest.php | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/HttpCache/SubRequestHandler.php b/HttpCache/SubRequestHandler.php index c050256025..21928c1a58 100644 --- a/HttpCache/SubRequestHandler.php +++ b/HttpCache/SubRequestHandler.php @@ -43,6 +43,7 @@ public static function handle(HttpKernelInterface $kernel, Request $request, $ty if (!IpUtils::checkIp($remoteAddr, $trustedProxies)) { foreach (array_filter($trustedHeaders) as $name) { $request->headers->remove($name); + $request->server->remove('HTTP_'.strtoupper(str_replace('-', '_', $name))); } } @@ -61,13 +62,16 @@ public static function handle(HttpKernelInterface $kernel, Request $request, $ty // set trusted values, reusing as much as possible the global trusted settings if ($name = $trustedHeaders[Request::HEADER_FORWARDED]) { $trustedValues[0] .= sprintf(';host="%s";proto=%s', $request->getHttpHost(), $request->getScheme()); - $request->headers->set($name, implode(', ', $trustedValues)); + $request->headers->set($name, $v = implode(', ', $trustedValues)); + $request->server->set('HTTP_'.strtoupper(str_replace('-', '_', $name)), $v); } if ($name = $trustedHeaders[Request::HEADER_CLIENT_IP]) { - $request->headers->set($name, implode(', ', $trustedIps)); + $request->headers->set($name, $v = implode(', ', $trustedIps)); + $request->server->set('HTTP_'.strtoupper(str_replace('-', '_', $name)), $v); } if (!$name && !$trustedHeaders[Request::HEADER_FORWARDED]) { - $request->headers->set('X-Forwarded-For', implode(', ', $trustedIps)); + $request->headers->set('X-Forwarded-For', $v = implode(', ', $trustedIps)); + $request->server->set('HTTP_X_FORWARDED_FOR', $v); Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X_FORWARDED_FOR'); } diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index a955da20aa..197a720439 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -60,6 +60,8 @@ public function testRenderWithObjectsAsAttributes() $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $subRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $subRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); @@ -91,6 +93,7 @@ public function testRenderWithTrustedHeaderDisabled() $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); @@ -178,8 +181,10 @@ public function testESIHeaderIsKeptInSubrequest() $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); @@ -203,6 +208,8 @@ public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*')); @@ -216,6 +223,8 @@ public function testFirstTrustedProxyIsSetAsRemote() $expectedSubRequest->server->set('REMOTE_ADDR', '127.0.0.1'); $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); Request::setTrustedProxies(array('1.1.1.1')); @@ -235,6 +244,8 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() $expectedSubRequest->server->set('REMOTE_ADDR', '127.0.0.1'); $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); Request::setTrustedProxies(array('1.1.1.1/24')); From 5424d38f10dc62752e655740224681a478d9f5bb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 27 Aug 2018 19:33:38 +0200 Subject: [PATCH 091/294] updated VERSION for 2.8.45 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 32a9057834..276b2a1516 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.45-DEV'; + const VERSION = '2.8.45'; const VERSION_ID = 20845; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 45; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 00404ffa4ae576ec2e819330746ca7cb9d123d30 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 27 Aug 2018 19:44:28 +0200 Subject: [PATCH 092/294] bumped Symfony version to 2.8.46 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 276b2a1516..15425cdf92 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.45'; - const VERSION_ID = 20845; + const VERSION = '2.8.46-DEV'; + const VERSION_ID = 20846; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 45; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 46; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 2819693b25f480966cbfa13b651abccfed4871ca Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Aug 2018 08:06:12 +0200 Subject: [PATCH 093/294] updated VERSION for 3.4.15 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0f4eeeb58a..ac6471a8b9 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.15-DEV'; + const VERSION = '3.4.15'; const VERSION_ID = 30415; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 15; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 3e8b8e742dbabc0b2f2e9127993776e07c4b0f11 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Aug 2018 08:16:34 +0200 Subject: [PATCH 094/294] bumped Symfony version to 3.4.16 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ac6471a8b9..890bf47605 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.15'; - const VERSION_ID = 30415; + const VERSION = '3.4.16-DEV'; + const VERSION_ID = 30416; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 15; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 16; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 825d2137d5706a1571ef0b3d05d6659007fe024f Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Tue, 28 Aug 2018 18:06:40 +0200 Subject: [PATCH 095/294] [HttpKernel] Fix inheritdocs --- Bundle/Bundle.php | 32 +++++++++----------------------- Kernel.php | 2 +- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index c99862a10f..a1d9472d9b 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -35,23 +35,21 @@ abstract class Bundle implements BundleInterface protected $path; /** - * Boots the Bundle. + * {@inheritdoc} */ public function boot() { } /** - * Shutdowns the Bundle. + * {@inheritdoc} */ public function shutdown() { } /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. + * {@inheritdoc} * * This method can be overridden to register compilation passes, * other extensions, ... @@ -61,9 +59,7 @@ public function build(ContainerBuilder $container) } /** - * Sets the container. - * - * @param ContainerInterface|null $container A ContainerInterface instance or null + * {@inheritdoc} */ public function setContainer(ContainerInterface $container = null) { @@ -71,9 +67,7 @@ public function setContainer(ContainerInterface $container = null) } /** - * Returns the bundle's container extension. - * - * @return ExtensionInterface|null The container extension + * {@inheritdoc} * * @throws \LogicException */ @@ -110,9 +104,7 @@ public function getContainerExtension() } /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace + * {@inheritdoc} */ public function getNamespace() { @@ -122,9 +114,7 @@ public function getNamespace() } /** - * Gets the Bundle directory path. - * - * @return string The Bundle absolute path + * {@inheritdoc} */ public function getPath() { @@ -137,18 +127,14 @@ public function getPath() } /** - * Returns the bundle parent name. - * - * @return string|null The Bundle parent name it overrides or null if no parent + * {@inheritdoc} */ public function getParent() { } /** - * Returns the bundle name (the class short name). - * - * @return string The Bundle name + * {@inheritdoc} */ final public function getName() { diff --git a/Kernel.php b/Kernel.php index 15425cdf92..041b77bff9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -112,7 +112,7 @@ public function __clone() } /** - * Boots the current kernel. + * {@inheritdoc} */ public function boot() { From 2cb17cf742cdce88c71ddf57a29a359f0c5c20de Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 3 Sep 2018 16:40:22 +0200 Subject: [PATCH 096/294] [HttpKernel][FrameworkBundle] Fix escaping of serialized payloads passed to test clients --- Client.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Client.php b/Client.php index 49f0e4c169..2175b567a7 100644 --- a/Client.php +++ b/Client.php @@ -71,12 +71,12 @@ protected function doRequest($request) */ protected function getScript($request) { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); $r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader'); - $requirePath = str_replace("'", "\\'", $r->getFileName()); - $symfonyPath = str_replace("'", "\\'", \dirname(\dirname(\dirname(__DIR__)))); + $requirePath = var_export($r->getFileName(), true); + $symfonyPath = var_export(\dirname(\dirname(\dirname(__DIR__))), true); $errorReporting = error_reporting(); $code = <<addPrefix('Symfony', '$symfonyPath'); +\$loader->addPrefix('Symfony', $symfonyPath); \$loader->register(); -\$kernel = unserialize('$kernel'); -\$request = unserialize('$request'); +\$kernel = unserialize($kernel); +\$request = unserialize($request); EOF; return $code.$this->getHandleScript(); From a82d8a61cd043a7d94dc06d3ea858a1b0a0ecde6 Mon Sep 17 00:00:00 2001 From: Smaine Milianni Date: Thu, 9 Aug 2018 22:49:22 +0200 Subject: [PATCH 097/294] change baseUrl to basePath to fix wrong profiler url --- Debug/FileLinkFormatter.php | 2 +- Tests/Debug/FileLinkFormatterTest.php | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index 4d4ae9b003..b3c2595b0d 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -100,7 +100,7 @@ private function getFileLinkFormat() } return array( - $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, + $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat, $this->baseDir.\DIRECTORY_SEPARATOR, '', ); } diff --git a/Tests/Debug/FileLinkFormatterTest.php b/Tests/Debug/FileLinkFormatterTest.php index e14780ac68..5c93bd90e3 100644 --- a/Tests/Debug/FileLinkFormatterTest.php +++ b/Tests/Debug/FileLinkFormatterTest.php @@ -37,7 +37,6 @@ public function testWhenFileLinkFormatAndNoRequest() public function testWhenFileLinkFormatAndRequest() { $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php'; - $baseDir = __DIR__; $requestStack = new RequestStack(); $request = new Request(); $requestStack->push($request); @@ -56,12 +55,12 @@ public function testWhenNoFileLinkFormatAndRequest() $request->server->set('SERVER_NAME', 'www.example.org'); $request->server->set('SERVER_PORT', 80); - $request->server->set('SCRIPT_NAME', '/app.php'); - $request->server->set('SCRIPT_FILENAME', '/web/app.php'); - $request->server->set('REQUEST_URI', '/app.php/example'); + $request->server->set('SCRIPT_NAME', '/index.php'); + $request->server->set('SCRIPT_FILENAME', '/public/index.php'); + $request->server->set('REQUEST_URI', '/index.php/example'); $sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); - $this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); + $this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); } } From 6f010742c193e4baadb2f275fce3f2e7398732d0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 8 Sep 2018 14:44:02 +0200 Subject: [PATCH 098/294] Consistently throw exceptions on a single line --- Bundle/Bundle.php | 5 +---- Kernel.php | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index a1d9472d9b..11d93d7709 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -86,10 +86,7 @@ public function getContainerExtension() $expectedAlias = Container::underscore($basename); if ($expectedAlias != $extension->getAlias()) { - throw new \LogicException(sprintf( - 'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', - $expectedAlias, $extension->getAlias() - )); + throw new \LogicException(sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias())); } $this->extension = $extension; diff --git a/Kernel.php b/Kernel.php index 041b77bff9..4d5eb6a144 100644 --- a/Kernel.php +++ b/Kernel.php @@ -265,11 +265,7 @@ public function locateResource($name, $dir = null, $first = true) foreach ($bundles as $bundle) { if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) { if (null !== $resourceBundle) { - throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', - $file, - $resourceBundle, - $dir.'/'.$bundles[0]->getName().$overridePath - )); + throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', $file, $resourceBundle, $dir.'/'.$bundles[0]->getName().$overridePath)); } if ($first) { From 985978d2d5d5e6e7d1cfb02c1047a91abf6fd26f Mon Sep 17 00:00:00 2001 From: nicoweb Date: Sat, 8 Sep 2018 14:42:42 +0200 Subject: [PATCH 099/294] [Controller][ServiceValueResolver] Making method access case insensitive --- .../ArgumentResolver/ServiceValueResolver.php | 9 +++++++++ .../ServiceValueResolverTest.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Controller/ArgumentResolver/ServiceValueResolver.php b/Controller/ArgumentResolver/ServiceValueResolver.php index 7bc195f233..3294ec862e 100644 --- a/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/Controller/ArgumentResolver/ServiceValueResolver.php @@ -47,6 +47,10 @@ public function supports(Request $request, ArgumentMetadata $argument) $controller = ltrim($controller, '\\'); } + if (!$this->container->has($controller) && false !== $i = strrpos($controller, ':')) { + $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); + } + return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName()); } @@ -63,6 +67,11 @@ public function resolve(Request $request, ArgumentMetadata $argument) $controller = ltrim($controller, '\\'); } + if (!$this->container->has($controller)) { + $i = strrpos($controller, ':'); + $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); + } + yield $this->container->get($controller)->get($argument->getName()); } } diff --git a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index 7d34172ce3..f6a3689638 100644 --- a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -66,6 +66,24 @@ public function testExistingControllerWithATrailingBackSlash() $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); } + public function testExistingControllerWithMethodNameStartUppercase() + { + $resolver = new ServiceValueResolver(new ServiceLocator(array( + 'App\\Controller\\Mine::method' => function () { + return new ServiceLocator(array( + 'dummy' => function () { + return new DummyService(); + }, + )); + }, + ))); + $request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::Method')); + $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); + + $this->assertTrue($resolver->supports($request, $argument)); + $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + } + public function testControllerNameIsAnArray() { $resolver = new ServiceValueResolver(new ServiceLocator(array( From 0cbbe74c07670938299aa054a25aebff7dd94447 Mon Sep 17 00:00:00 2001 From: Mponos George Date: Fri, 14 Sep 2018 00:01:37 +0300 Subject: [PATCH 100/294] KernelInterface can return null container --- KernelInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KernelInterface.php b/KernelInterface.php index 18b128c296..670e0269db 100644 --- a/KernelInterface.php +++ b/KernelInterface.php @@ -139,7 +139,7 @@ public function getRootDir(); /** * Gets the current container. * - * @return ContainerInterface A ContainerInterface instance + * @return ContainerInterface|null A ContainerInterface instance or null when the Kernel is shutdown */ public function getContainer(); From 60cfeda85ae573fd1c0bd61ec81cf1efea485649 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 23 Sep 2018 16:32:19 +0200 Subject: [PATCH 101/294] [HttpFoundation][Security] forward locale and format to subrequests --- Fragment/InlineFragmentRenderer.php | 7 +++++++ Tests/Fragment/InlineFragmentRendererTest.php | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index 712248578d..13fc335624 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -122,6 +122,13 @@ protected function createSubRequest($uri, Request $request) $subRequest->setSession($session); } + if ($request->get('_format')) { + $subRequest->attributes->set('_format', $request->get('_format')); + } + if ($request->getDefaultLocale() !== $request->getLocale()) { + $subRequest->setLocale($request->getLocale()); + } + return $subRequest; } diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 197a720439..6cd2bf03ca 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -175,6 +175,26 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() $this->assertEquals('Foo', ob_get_clean()); } + public function testLocaleAndFormatAreIsKeptInSubrequest() + { + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->attributes->set('_format', 'foo'); + $expectedSubRequest->setLocale('fr'); + if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + } + $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); + + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); + + $request = Request::create('/'); + $request->attributes->set('_format', 'foo'); + $request->setLocale('fr'); + $strategy->render('/', $request); + } + public function testESIHeaderIsKeptInSubrequest() { $expectedSubRequest = Request::create('/'); From 90411d2ad577b883f2fc9de06c86dd564d9ac676 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 05:51:44 +0200 Subject: [PATCH 102/294] updated VERSION for 2.8.46 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4d5eb6a144..b6db6ee97c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.46-DEV'; + const VERSION = '2.8.46'; const VERSION_ID = 20846; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 46; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 875cb68418896852ad34da930ed05001fab6a227 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 06:05:12 +0200 Subject: [PATCH 103/294] bumped Symfony version to 2.8.47 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index b6db6ee97c..1a75787eaf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.46'; - const VERSION_ID = 20846; + const VERSION = '2.8.47-DEV'; + const VERSION_ID = 20847; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 46; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 47; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 934a5f006e334b2448452e168391d568b17e3ea3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 06:10:38 +0200 Subject: [PATCH 104/294] fixed tests --- Tests/Fragment/InlineFragmentRendererTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 75987605e3..231d4eb508 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -194,7 +194,7 @@ public function testLocaleAndFormatAreIsKeptInSubrequest() $expectedSubRequest = Request::create('/'); $expectedSubRequest->attributes->set('_format', 'foo'); $expectedSubRequest->setLocale('fr'); - if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { + if (Request::HEADER_CLIENT_IP & Request::getTrustedHeaderSet()) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } From 387d76c492ebc1546fc168f5a640e1946fd1395b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 06:36:53 +0200 Subject: [PATCH 105/294] fixed tests --- Tests/Fragment/InlineFragmentRendererTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 231d4eb508..80f9cd2b53 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -194,7 +194,7 @@ public function testLocaleAndFormatAreIsKeptInSubrequest() $expectedSubRequest = Request::create('/'); $expectedSubRequest->attributes->set('_format', 'foo'); $expectedSubRequest->setLocale('fr'); - if (Request::HEADER_CLIENT_IP & Request::getTrustedHeaderSet()) { + if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } From 3b269202b8843276b1ff320175893c71c706d9cb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 06:53:52 +0200 Subject: [PATCH 106/294] updated VERSION for 3.4.16 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index ee2529a9e8..820198028c 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.16-DEV'; + const VERSION = '3.4.16'; const VERSION_ID = 30416; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 16; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 08913a52dbac4f2155631a3d22c8dda1e4f21458 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 30 Sep 2018 07:04:55 +0200 Subject: [PATCH 107/294] bumped Symfony version to 3.4.17 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 820198028c..f001134324 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.16'; - const VERSION_ID = 30416; + const VERSION = '3.4.17-DEV'; + const VERSION_ID = 30417; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 16; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 17; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 3385cd3c6b8bfa1816dad49676c1e9e1a1bbbc43 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Tue, 2 Oct 2018 00:12:00 -0300 Subject: [PATCH 108/294] [CS] Enforces null type hint on last position in phpDocs --- Config/FileLocator.php | 2 +- Profiler/MongoDbProfilerStorage.php | 2 +- Profiler/Profile.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Config/FileLocator.php b/Config/FileLocator.php index fb1f913bdf..c047ba3dac 100644 --- a/Config/FileLocator.php +++ b/Config/FileLocator.php @@ -26,7 +26,7 @@ class FileLocator extends BaseFileLocator /** * @param KernelInterface $kernel A KernelInterface instance - * @param null|string $path The path the global resource directory + * @param string|null $path The path the global resource directory * @param array $paths An array of paths where to look for resources */ public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) diff --git a/Profiler/MongoDbProfilerStorage.php b/Profiler/MongoDbProfilerStorage.php index 22b309cd6f..19970f9b72 100644 --- a/Profiler/MongoDbProfilerStorage.php +++ b/Profiler/MongoDbProfilerStorage.php @@ -235,7 +235,7 @@ private function getProfile(array $data) /** * @param string $dsn * - * @return null|array Array($server, $database, $collection) + * @return array|null Array($server, $database, $collection) */ private function parseDsn($dsn) { diff --git a/Profiler/Profile.php b/Profiler/Profile.php index 5ebaae4f8d..1f2796d537 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -92,7 +92,7 @@ public function getParent() /** * Returns the parent token. * - * @return null|string The parent token + * @return string|null The parent token */ public function getParentToken() { From ecbff80581c45f4c24d81d6b5e793ab781d055fd Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Tue, 2 Oct 2018 00:08:26 -0300 Subject: [PATCH 109/294] [CS] Remove unused variables passed to closures --- Tests/HttpCache/HttpCacheTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index 102d7644ed..ccbe412e81 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -964,8 +964,7 @@ public function testUsesCacheToRespondToHeadRequestsWhenFresh() public function testSendsNoContentWhenFresh() { $time = \DateTime::createFromFormat('U', time()); - $that = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) { + $this->setNextResponse(200, array(), '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)); }); From a0944a9a1d8845da724236cde9a310964acadb1c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Oct 2018 14:03:34 +0200 Subject: [PATCH 110/294] updated VERSION for 3.4.17 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f001134324..a285911dd5 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.17-DEV'; + const VERSION = '3.4.17'; const VERSION_ID = 30417; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 17; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 0b98e0b82c4004c23f28024036275323c99f1a4f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Oct 2018 14:49:59 +0200 Subject: [PATCH 111/294] bumped Symfony version to 3.4.18 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a285911dd5..2e9d751091 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.17'; - const VERSION_ID = 30417; + const VERSION = '3.4.18-DEV'; + const VERSION_ID = 30418; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 17; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 18; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From fd1c5a8d4376ddbb45f0c6dbaacb430d8d342dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Mon, 29 Oct 2018 20:09:12 +0100 Subject: [PATCH 112/294] Fix ini_get() for boolean values --- DataCollector/ConfigDataCollector.php | 8 ++++---- Tests/DataCollector/ConfigDataCollectorTest.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 8d8ea1a3e3..851875c155 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -63,10 +63,10 @@ public function collect(Request $request, Response $response, \Exception $except 'php_version' => PHP_VERSION, 'xdebug_enabled' => \extension_loaded('xdebug'), 'eaccel_enabled' => \extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), - 'apc_enabled' => \extension_loaded('apc') && ini_get('apc.enabled'), - 'xcache_enabled' => \extension_loaded('xcache') && ini_get('xcache.cacher'), - 'wincache_enabled' => \extension_loaded('wincache') && ini_get('wincache.ocenabled'), - 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && ini_get('opcache.enable'), + 'apc_enabled' => \extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), + 'xcache_enabled' => \extension_loaded('xcache') && filter_var(ini_get('xcache.cacher'), FILTER_VALIDATE_BOOLEAN), + 'wincache_enabled' => \extension_loaded('wincache') && filter_var(ini_get('wincache.ocenabled'), FILTER_VALIDATE_BOOLEAN), + 'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), 'bundles' => array(), 'sapi_name' => \PHP_SAPI, ); diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index 0ac4d3cfbc..6f30cc93fe 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -45,13 +45,13 @@ public function testCollect() // if else clause because we don't know it if (((\extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) || - (\extension_loaded('apc') && ini_get('apc.enabled')) + (\extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) || - (\extension_loaded('Zend OPcache') && ini_get('opcache.enable')) + (\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) || - (\extension_loaded('xcache') && ini_get('xcache.cacher')) + (\extension_loaded('xcache') && filter_var(ini_get('xcache.cacher'), FILTER_VALIDATE_BOOLEAN)) || - (\extension_loaded('wincache') && ini_get('wincache.ocenabled')))) { + (\extension_loaded('wincache') && filter_var(ini_get('wincache.ocenabled'), FILTER_VALIDATE_BOOLEAN)))) { $this->assertTrue($c->hasAccelerator()); } else { $this->assertFalse($c->hasAccelerator()); From eec90b42102c48ae741a0a78b2494f43233c52d9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 31 Oct 2018 10:26:14 +0100 Subject: [PATCH 113/294] fix merge --- Tests/DataCollector/ConfigDataCollectorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index ed614357e1..3f51b13ce9 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -39,8 +39,8 @@ public function testCollect() $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()); } } From 10b941cef0cd380d8be62772e4882568ec320a71 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Nov 2018 10:53:57 +0100 Subject: [PATCH 114/294] updated VERSION for 2.8.47 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1a75787eaf..e8c3182b4a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.47-DEV'; + const VERSION = '2.8.47'; const VERSION_ID = 20847; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; const RELEASE_VERSION = 47; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 31717d49f2a55979c86a8b9ef3cff4cb374c90ff Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Nov 2018 11:02:24 +0100 Subject: [PATCH 115/294] bumped Symfony version to 2.8.48 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index e8c3182b4a..e91c1d7d47 100644 --- a/Kernel.php +++ b/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.47'; - const VERSION_ID = 20847; + const VERSION = '2.8.48-DEV'; + const VERSION_ID = 20848; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 47; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 48; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From 4bf0be7c7fe63eff6a5eae2f21c83e77e31a56fb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Nov 2018 11:03:02 +0100 Subject: [PATCH 116/294] updated VERSION for 3.4.18 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 2e9d751091..f0137c6842 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.18-DEV'; + const VERSION = '3.4.18'; const VERSION_ID = 30418; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 18; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From bb6c5a64e97614867c4d5dd9f4899ec3ee936169 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Nov 2018 12:10:01 +0100 Subject: [PATCH 117/294] bumped Symfony version to 3.4.19 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f0137c6842..6b80158cf2 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.18'; - const VERSION_ID = 30418; + const VERSION = '3.4.19-DEV'; + const VERSION_ID = 30419; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 18; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 19; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 9df15e4bce3251904ef28eed09fe21b6beb8c12a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 1 Nov 2018 16:20:35 +0100 Subject: [PATCH 118/294] [VarDumper] fix dump of closures created from callables --- DataCollector/RequestDataCollector.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index e415833cc3..2501b93210 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -380,12 +380,27 @@ protected function parseController($controller) if ($controller instanceof \Closure) { $r = new \ReflectionFunction($controller); - return array( + $controller = array( 'class' => $r->getName(), 'method' => null, 'file' => $r->getFileName(), 'line' => $r->getStartLine(), ); + + if (false !== strpos($r->name, '{closure}')) { + return $controller; + } + $controller['method'] = $r->name; + + if ($class = $r->getClosureScopeClass()) { + $controller['class'] = $class; + } elseif ($class = $r->getClosureThis()) { + $controller['class'] = \get_class($class); + } else { + return $r->name; + } + + return $controller; } if (\is_object($controller)) { From e9c36683a132cfe1278108f9fcd4b9e3e50da692 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Sun, 11 Nov 2018 10:03:27 +0100 Subject: [PATCH 119/294] [Fwb][EventDispatcher][HttpKernel] Fix getClosureScopeClass usage to describe callables --- DataCollector/RequestDataCollector.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 2501b93210..10492e4465 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -393,9 +393,7 @@ protected function parseController($controller) $controller['method'] = $r->name; if ($class = $r->getClosureScopeClass()) { - $controller['class'] = $class; - } elseif ($class = $r->getClosureThis()) { - $controller['class'] = \get_class($class); + $controller['class'] = $class->name; } else { return $r->name; } From df2df800b674af47858ae89e513d8adf2628080f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 11 Nov 2018 12:11:22 +0100 Subject: [PATCH 120/294] Bump phpunit XSD version to 5.2 Some attributes being used in the phpunit configuration files, namely failOnRisky and failOnWarning were introduced in phpunit 5.2.0. The Composer configuration shows that tests should run with old versions of phpunit, but phpunit only validates the configuration against the XSD since phpunit 7.2.0. These changes can be tested as follows: wget http://schema.phpunit.de/5.2/phpunit.xsd xargs xmllint --schema phpunit.xsd 1>/dev/null find src -name phpunit.xml.dist| xargs xmllint --schema phpunit.xsd 1>/dev/null See https://github.com/sebastianbergmann/phpunit/commit/7e06a82806be004cbfd30a02d92162e9ed4abc7c See https://github.com/symfony/symfony/blob/46e3745a03e199e64cc0fcf3284a96b5a25dcee9/composer.json#L98 --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e0de769dd7..3fc07707f2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ Date: Sun, 18 Nov 2018 22:25:02 +0100 Subject: [PATCH 121/294] [cs] correct invalid @param types --- EventListener/ExceptionListener.php | 2 +- HttpCache/HttpCache.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index f033e452d6..16de178169 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -112,7 +112,7 @@ protected function logException(\Exception $exception, $message) * @param \Exception $exception The thrown exception * @param Request $request The original request * - * @return Request $request The cloned request + * @return Request The cloned request */ protected function duplicateRequest(\Exception $exception, Request $request) { diff --git a/HttpCache/HttpCache.php b/HttpCache/HttpCache.php index f54c87aa4a..1ccef00563 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -93,7 +93,7 @@ public function __construct(HttpKernelInterface $kernel, StoreInterface $store, /** * Gets the current store. * - * @return StoreInterface $store A StoreInterface instance + * @return StoreInterface A StoreInterface instance */ public function getStore() { From 78528325d90e5ad54a6e9eca750fe176932bc4fa Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 26 Nov 2018 15:04:48 +0100 Subject: [PATCH 122/294] updated VERSION for 3.4.19 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6b80158cf2..bfc961f505 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.19-DEV'; + const VERSION = '3.4.19'; const VERSION_ID = 30419; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 19; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 1013ff260e102801a6d298a66884d72b4fac56e6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 26 Nov 2018 15:50:31 +0100 Subject: [PATCH 123/294] bumped Symfony version to 3.4.20 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index bfc961f505..375e26ee0f 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.19'; - const VERSION_ID = 30419; + const VERSION = '3.4.20-DEV'; + const VERSION_ID = 30420; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 19; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 20; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From c489f901e595ee4b056951822f0b43b59b42d2f7 Mon Sep 17 00:00:00 2001 From: Shrey Puranik Date: Thu, 29 Nov 2018 08:43:48 +0000 Subject: [PATCH 124/294] Update HttpKernel.php Adding docblock to varToString method in HttpKernel Class --- HttpKernel.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HttpKernel.php b/HttpKernel.php index 36c673093b..f34d9b3225 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -263,6 +263,9 @@ private function handleException(\Exception $e, $request, $type) } } + /** + * Returns a human-readable string for the specified variable. + */ private function varToString($var) { if (\is_object($var)) { From 31f20eb6e00467ae85501dd98770aef17cd9aba7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 6 Dec 2018 14:59:33 +0000 Subject: [PATCH 125/294] updated VERSION for 3.4.20 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 375e26ee0f..faea3086e5 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.20-DEV'; + const VERSION = '3.4.20'; const VERSION_ID = 30420; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 20; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 3333793845d98c98d407fd061900bcc4af4539a5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 6 Dec 2018 15:57:52 +0000 Subject: [PATCH 126/294] bumped Symfony version to 3.4.21 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index faea3086e5..8635c2dfc4 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.20'; - const VERSION_ID = 30420; + const VERSION = '3.4.21-DEV'; + const VERSION_ID = 30421; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 20; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 21; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 50fe33a9e0cfa09531f2f3caa331e68ba0bdef5b Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Fri, 14 Dec 2018 10:32:06 +0100 Subject: [PATCH 127/294] Renamed test controller from Controller to TestController so it doesn't show up in the IDE autocomplete. --- Tests/HttpKernelTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 4b9ec69d1e..239865a861 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -200,7 +200,7 @@ public function testHandleWhenTheControllerIsAClosure() public function testHandleWhenTheControllerIsAnObjectWithInvoke() { $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, new Controller()); + $kernel = $this->getHttpKernel($dispatcher, new TestController()); $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); } @@ -216,7 +216,7 @@ public function testHandleWhenTheControllerIsAFunction() public function testHandleWhenTheControllerIsAnArray() { $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, array(new Controller(), 'controller')); + $kernel = $this->getHttpKernel($dispatcher, array(new TestController(), 'controller')); $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); } @@ -224,7 +224,7 @@ public function testHandleWhenTheControllerIsAnArray() public function testHandleWhenTheControllerIsAStaticArray() { $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\Controller', 'staticcontroller')); + $kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\TestController', 'staticcontroller')); $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); } @@ -381,7 +381,7 @@ private function assertResponseEquals(Response $expected, Response $actual) } } -class Controller +class TestController { public function __invoke() { From 6145fe4bd64c0188f13c85a5abfefbcd7fe59e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20S=C3=A9verin?= Date: Tue, 18 Dec 2018 13:59:24 +0000 Subject: [PATCH 128/294] Allow running PHPUnit with "xdebug.scream" ON Since https://github.com/symfony/symfony/pull/25733 the Kernel attempts to unlink the legacy container while being built. This throws an error if the file did not exist, for example on a clean install, on the build, which is then silenced. That's fine on production systems, but on our build we have enabled "xdebug.scream" in order to visualise every errors, which basically un-silences the errors. I believe there should not be a need to silence anything on a usual, clean usage of the system. Making this `unlink` conditional fixes it. Could you please approve and merge this PR? Thanks --- Kernel.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index 8635c2dfc4..3d28967ed0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -862,7 +862,10 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container $fs->dumpFile($dir.$file, $code); @chmod($dir.$file, 0666 & ~umask()); } - @unlink(\dirname($dir.$file).'.legacy'); + $legacyFile = \dirname($dir.$file).'.legacy'; + if (file_exists($legacyFile)) { + @unlink($legacyFile); + } $cache->write($rootCode, $container->getResources()); } From 6338fd89f1c30bb384efcdc5463cbd08bed28209 Mon Sep 17 00:00:00 2001 From: George Mponos Date: Sat, 22 Dec 2018 21:54:00 +0200 Subject: [PATCH 129/294] [Tests] Change to willThrowException --- Tests/EventListener/TranslatorListenerTest.php | 4 ++-- Tests/Fragment/HIncludeFragmentRendererTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/EventListener/TranslatorListenerTest.php b/Tests/EventListener/TranslatorListenerTest.php index 23b833177a..c1d56ec85d 100644 --- a/Tests/EventListener/TranslatorListenerTest.php +++ b/Tests/EventListener/TranslatorListenerTest.php @@ -47,7 +47,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() $this->translator ->expects($this->at(0)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->translator ->expects($this->at(1)) ->method('setLocale') @@ -84,7 +84,7 @@ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() $this->translator ->expects($this->at(0)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); $this->translator ->expects($this->at(1)) ->method('setLocale') diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index 10fbccf0fa..e3926708c1 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -80,7 +80,7 @@ public function testRenderWithDefaultText() $engine->expects($this->once()) ->method('exists') ->with('default') - ->will($this->throwException(new \InvalidArgumentException())); + ->willThrowException(new \InvalidArgumentException()); // only default $strategy = new HIncludeFragmentRenderer($engine); @@ -93,7 +93,7 @@ public function testRenderWithEngineAndDefaultText() $engine->expects($this->once()) ->method('exists') ->with('loading...') - ->will($this->throwException(new \RuntimeException())); + ->willThrowException(new \RuntimeException()); // only default $strategy = new HIncludeFragmentRenderer($engine); From a56cfb7670fbce76947695b522c3f98d841e376b Mon Sep 17 00:00:00 2001 From: Zan Baldwin Date: Mon, 24 Dec 2018 12:22:50 +0000 Subject: [PATCH 130/294] [HttpKernel] Correctly Render Signed URIs Containing Fragments Rebuild the URL with the computed hash instead of appending it onto the end of the URI, preventing incorrect formatting when dealing with URIs containing fragments. --- Tests/Fragment/EsiFragmentRendererTest.php | 2 +- Tests/Fragment/HIncludeFragmentRendererTest.php | 2 +- Tests/Fragment/SsiFragmentRendererTest.php | 2 +- Tests/UriSignerTest.php | 16 ++++++++++++++-- UriSigner.php | 7 ++++--- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Tests/Fragment/EsiFragmentRendererTest.php b/Tests/Fragment/EsiFragmentRendererTest.php index 00d796d520..51e5756203 100644 --- a/Tests/Fragment/EsiFragmentRendererTest.php +++ b/Tests/Fragment/EsiFragmentRendererTest.php @@ -72,7 +72,7 @@ public function testRenderControllerReference() $altReference = new ControllerReference('alt_controller', array(), array()); $this->assertEquals( - '', + '', $strategy->render($reference, $request, array('alt' => $altReference))->getContent() ); } diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index e3926708c1..68f8ded4e9 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -32,7 +32,7 @@ public function testRenderWithControllerAndSigner() { $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); + $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); } public function testRenderWithUri() diff --git a/Tests/Fragment/SsiFragmentRendererTest.php b/Tests/Fragment/SsiFragmentRendererTest.php index f725803118..ff98fd2616 100644 --- a/Tests/Fragment/SsiFragmentRendererTest.php +++ b/Tests/Fragment/SsiFragmentRendererTest.php @@ -51,7 +51,7 @@ public function testRenderControllerReference() $altReference = new ControllerReference('alt_controller', array(), array()); $this->assertEquals( - '', + '', $strategy->render($reference, $request, array('alt' => $altReference))->getContent() ); } diff --git a/Tests/UriSignerTest.php b/Tests/UriSignerTest.php index 84ec19f70d..9b7fe08a99 100644 --- a/Tests/UriSignerTest.php +++ b/Tests/UriSignerTest.php @@ -21,7 +21,8 @@ public function testSign() $signer = new UriSigner('foobar'); $this->assertContains('?_hash=', $signer->sign('http://example.com/foo')); - $this->assertContains('&_hash=', $signer->sign('http://example.com/foo?foo=bar')); + $this->assertContains('?_hash=', $signer->sign('http://example.com/foo?foo=bar')); + $this->assertContains('&foo=', $signer->sign('http://example.com/foo?foo=bar')); } public function testCheck() @@ -45,7 +46,7 @@ public function testCheckWithDifferentArgSeparator() $signer = new UriSigner('foobar'); $this->assertSame( - 'http://example.com/foo?baz=bay&foo=bar&_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D', + 'http://example.com/foo?_hash=rIOcC%2FF3DoEGo%2FvnESjSp7uU9zA9S%2F%2BOLhxgMexoPUM%3D&baz=bay&foo=bar', $signer->sign('http://example.com/foo?foo=bar&baz=bay') ); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); @@ -61,4 +62,15 @@ public function testCheckWithDifferentParameter() ); $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); } + + public function testSignerWorksWithFragments() + { + $signer = new UriSigner('foobar'); + + $this->assertSame( + 'http://example.com/foo?_hash=EhpAUyEobiM3QTrKxoLOtQq5IsWyWedoXDPqIjzNj5o%3D&bar=foo&foo=bar#foobar', + $signer->sign('http://example.com/foo?bar=foo&foo=bar#foobar') + ); + $this->assertTrue($signer->check($signer->sign('http://example.com/foo?bar=foo&foo=bar#foobar'))); + } } diff --git a/UriSigner.php b/UriSigner.php index 28459b4ecd..63d1a0856f 100644 --- a/UriSigner.php +++ b/UriSigner.php @@ -51,8 +51,9 @@ public function sign($uri) } $uri = $this->buildUrl($url, $params); + $params[$this->parameter] = $this->computeHash($uri); - return $uri.(false === strpos($uri, '?') ? '?' : '&').$this->parameter.'='.$this->computeHash($uri); + return $this->buildUrl($url, $params); } /** @@ -75,7 +76,7 @@ public function check($uri) return false; } - $hash = urlencode($params[$this->parameter]); + $hash = $params[$this->parameter]; unset($params[$this->parameter]); return $this->computeHash($this->buildUrl($url, $params)) === $hash; @@ -83,7 +84,7 @@ public function check($uri) private function computeHash($uri) { - return urlencode(base64_encode(hash_hmac('sha256', $uri, $this->secret, true))); + return base64_encode(hash_hmac('sha256', $uri, $this->secret, true)); } private function buildUrl(array $url, array $params = array()) From e110b9db82d34a45cff358582ecf28a4a1eaa4c9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 28 Dec 2018 12:28:01 +0100 Subject: [PATCH 131/294] Fixed minor typos --- DependencyInjection/AddAnnotatedClassesToCachePass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 645e8f30ff..4e59123d19 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -63,7 +63,7 @@ public function process(ContainerBuilder $container) * @param array $patterns The class patterns to expand * @param array $classes The existing classes to match against the patterns * - * @return array A list of classes derivated from the patterns + * @return array A list of classes derived from the patterns */ private function expandClasses(array $patterns, array $classes) { From 4f3674fd26dc0dedde727a7360eb7c8a3abdabb5 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 1 Jan 2019 14:42:07 +0100 Subject: [PATCH 132/294] update year in license files --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 21d7fb9e2f..a677f43763 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2018 Fabien Potencier +Copyright (c) 2004-2019 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 0d6f086e6ae0aa490970e9e07500ec1415298794 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 4 Jan 2019 14:48:06 +0100 Subject: [PATCH 133/294] remove no longer needed PHP version checks --- Tests/DataCollector/DumpDataCollectorTest.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index fd5ea11e72..341ddc6d8d 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -125,11 +125,8 @@ public function testFlushNothingWhenDataDumperIsProvided() $collector->dump($data); $line = __LINE__ - 1; $output = preg_replace("/\033\[[^m]*m/", '', ob_get_clean()); - if (\PHP_VERSION_ID >= 50400) { - $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output); - } else { - $this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", $output); - } + + $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", $output); ob_start(); $collector->__destruct(); From 60bd9d7444ca436e131c347d78ec039dd99a34b4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 6 Jan 2019 16:53:59 +0100 Subject: [PATCH 134/294] updated VERSION for 3.4.21 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 3d28967ed0..f70e246d46 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.21-DEV'; + const VERSION = '3.4.21'; const VERSION_ID = 30421; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 21; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 259efacd9fcb8903379569545a6f65c430799707 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 6 Jan 2019 17:15:41 +0100 Subject: [PATCH 135/294] bumped Symfony version to 3.4.22 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f70e246d46..bb546d3c51 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.21'; - const VERSION_ID = 30421; + const VERSION = '3.4.22-DEV'; + const VERSION_ID = 30422; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 21; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 22; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From f1b8a42c935d68b820d73ebd3a8e0988739f5595 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 16 Jan 2019 10:39:14 +0100 Subject: [PATCH 136/294] switched array() to [] --- Bundle/Bundle.php | 2 +- CacheClearer/ChainCacheClearer.php | 2 +- CacheClearer/Psr6CacheClearer.php | 4 +- CacheWarmer/CacheWarmerAggregate.php | 6 +- Client.php | 4 +- Config/EnvParametersResource.php | 8 +- Config/FileLocator.php | 2 +- Controller/ArgumentResolver.php | 8 +- Controller/ContainerControllerResolver.php | 2 +- Controller/ControllerReference.php | 6 +- Controller/ControllerResolver.php | 6 +- .../ArgumentMetadataFactory.php | 2 +- DataCollector/ConfigDataCollector.php | 8 +- DataCollector/DataCollector.php | 6 +- DataCollector/DumpDataCollector.php | 24 +- DataCollector/EventDataCollector.php | 10 +- DataCollector/ExceptionDataCollector.php | 6 +- DataCollector/LoggerDataCollector.php | 48 +-- DataCollector/MemoryDataCollector.php | 4 +- DataCollector/RequestDataCollector.php | 42 +-- DataCollector/RouterDataCollector.php | 4 +- DataCollector/TimeDataCollector.php | 8 +- DataCollector/Util/ValueExporter.php | 2 +- Debug/FileLinkFormatter.php | 10 +- .../AddAnnotatedClassesToCachePass.php | 12 +- DependencyInjection/Extension.php | 4 +- DependencyInjection/FragmentRendererPass.php | 2 +- .../LazyLoadingFragmentHandler.php | 8 +- .../MergeExtensionConfigurationPass.php | 2 +- ...RegisterControllerArgumentLocatorsPass.php | 14 +- DependencyInjection/ResettableServicePass.php | 2 +- EventListener/AbstractSessionListener.php | 12 +- EventListener/AbstractTestSessionListener.php | 8 +- EventListener/AddRequestFormatsListener.php | 2 +- EventListener/DebugHandlersListener.php | 4 +- EventListener/DumpListener.php | 4 +- EventListener/ExceptionListener.php | 14 +- EventListener/FragmentListener.php | 8 +- EventListener/LocaleListener.php | 8 +- EventListener/ProfilerListener.php | 8 +- EventListener/ResponseListener.php | 4 +- EventListener/RouterListener.php | 14 +- EventListener/SaveSessionListener.php | 6 +- EventListener/StreamedResponseListener.php | 6 +- EventListener/SurrogateListener.php | 4 +- EventListener/TranslatorListener.php | 8 +- EventListener/ValidateRequestListener.php | 10 +- Exception/AccessDeniedHttpException.php | 2 +- Exception/BadRequestHttpException.php | 2 +- Exception/ConflictHttpException.php | 2 +- Exception/GoneHttpException.php | 2 +- Exception/HttpException.php | 2 +- Exception/LengthRequiredHttpException.php | 2 +- Exception/MethodNotAllowedHttpException.php | 2 +- Exception/NotAcceptableHttpException.php | 2 +- Exception/NotFoundHttpException.php | 2 +- Exception/PreconditionFailedHttpException.php | 2 +- .../PreconditionRequiredHttpException.php | 2 +- Exception/ServiceUnavailableHttpException.php | 4 +- Exception/TooManyRequestsHttpException.php | 4 +- Exception/UnauthorizedHttpException.php | 2 +- .../UnprocessableEntityHttpException.php | 2 +- .../UnsupportedMediaTypeHttpException.php | 2 +- .../AbstractSurrogateFragmentRenderer.php | 2 +- Fragment/FragmentHandler.php | 6 +- Fragment/FragmentRendererInterface.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 4 +- Fragment/InlineFragmentRenderer.php | 8 +- HttpCache/AbstractSurrogate.php | 12 +- HttpCache/Esi.php | 2 +- HttpCache/HttpCache.php | 30 +- HttpCache/ResponseCacheStrategy.php | 4 +- HttpCache/Ssi.php | 2 +- HttpCache/Store.php | 20 +- HttpCache/SubRequestHandler.php | 14 +- HttpKernel.php | 2 +- Kernel.php | 60 +-- Log/Logger.php | 10 +- Profiler/FileProfilerStorage.php | 16 +- Profiler/Profile.php | 14 +- Profiler/Profiler.php | 8 +- Tests/CacheClearer/ChainCacheClearerTest.php | 2 +- Tests/CacheClearer/Psr6CacheClearerTest.php | 6 +- .../CacheWarmer/CacheWarmerAggregateTest.php | 8 +- Tests/ClientTest.php | 20 +- Tests/Config/EnvParametersResourceTest.php | 8 +- .../ServiceValueResolverTest.php | 54 +-- Tests/Controller/ArgumentResolverTest.php | 78 ++-- .../ContainerControllerResolverTest.php | 28 +- Tests/Controller/ControllerResolverTest.php | 76 ++-- .../ArgumentMetadataFactoryTest.php | 52 +-- .../DataCollector/ConfigDataCollectorTest.php | 2 +- Tests/DataCollector/DataCollectorTest.php | 2 +- Tests/DataCollector/DumpDataCollectorTest.php | 18 +- .../DataCollector/LoggerDataCollectorTest.php | 88 ++--- .../DataCollector/MemoryDataCollectorTest.php | 32 +- .../RequestDataCollectorTest.php | 96 ++--- Tests/Debug/TraceableEventDispatcherTest.php | 10 +- .../AddAnnotatedClassesToCachePassTest.php | 80 ++-- ...ontrollerArgumentValueResolverPassTest.php | 20 +- .../FragmentRendererPassTest.php | 10 +- .../MergeExtensionConfigurationPassTest.php | 4 +- ...sterControllerArgumentLocatorsPassTest.php | 74 ++-- ...mptyControllerArgumentLocatorsPassTest.php | 30 +- .../ResettableServicePassTest.php | 22 +- .../ServicesResetterTest.php | 6 +- .../FilterControllerArgumentsEventTest.php | 4 +- .../AddRequestFormatsListenerTest.php | 6 +- .../DebugHandlersListenerTest.php | 26 +- Tests/EventListener/DumpListenerTest.php | 4 +- Tests/EventListener/ExceptionListenerTest.php | 10 +- Tests/EventListener/FragmentListenerTest.php | 8 +- Tests/EventListener/LocaleListenerTest.php | 4 +- Tests/EventListener/ResponseListenerTest.php | 8 +- Tests/EventListener/RouterListenerTest.php | 24 +- Tests/EventListener/SessionListenerTest.php | 2 +- Tests/EventListener/SurrogateListenerTest.php | 6 +- .../EventListener/TestSessionListenerTest.php | 18 +- .../ValidateRequestListenerTest.php | 6 +- Tests/Exception/HttpExceptionTest.php | 22 +- .../MethodNotAllowedHttpExceptionTest.php | 6 +- .../ServiceUnavailableHttpExceptionTest.php | 2 +- .../TooManyRequestsHttpExceptionTest.php | 2 +- .../UnauthorizedHttpExceptionTest.php | 2 +- Tests/Fixtures/123/Kernel123.php | 2 +- .../DataCollector/CloneVarDataCollector.php | 2 +- Tests/Fixtures/KernelForTest.php | 2 +- Tests/Fixtures/KernelWithoutBundles.php | 2 +- Tests/Fixtures/TestEventDispatcher.php | 4 +- Tests/Fragment/EsiFragmentRendererTest.php | 16 +- Tests/Fragment/FragmentHandlerTest.php | 8 +- .../Fragment/HIncludeFragmentRendererTest.php | 20 +- Tests/Fragment/InlineFragmentRendererTest.php | 64 ++-- .../Fragment/RoutableFragmentRendererTest.php | 26 +- Tests/Fragment/SsiFragmentRendererTest.php | 10 +- Tests/HttpCache/EsiTest.php | 6 +- Tests/HttpCache/HttpCacheTest.php | 348 +++++++++--------- Tests/HttpCache/HttpCacheTestCase.php | 16 +- Tests/HttpCache/SsiTest.php | 6 +- Tests/HttpCache/StoreTest.php | 50 +-- Tests/HttpCache/SubRequestHandlerTest.php | 10 +- Tests/HttpCache/TestHttpKernel.php | 8 +- Tests/HttpCache/TestMultipleHttpKernel.php | 10 +- Tests/HttpKernelTest.php | 46 +-- Tests/KernelTest.php | 148 ++++---- Tests/Log/LoggerTest.php | 70 ++-- Tests/Logger.php | 38 +- Tests/Profiler/FileProfilerStorageTest.php | 6 +- Tests/Profiler/ProfilerTest.php | 2 +- Tests/TestHttpKernel.php | 4 +- UriSigner.php | 6 +- 151 files changed, 1278 insertions(+), 1278 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index f42895a733..62b86ca7fd 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -166,7 +166,7 @@ public function registerCommands(Application $application) } $class = $ns.'\\'.$file->getBasename('.php'); if ($this->container) { - $commandIds = $this->container->hasParameter('console.command.ids') ? $this->container->getParameter('console.command.ids') : array(); + $commandIds = $this->container->hasParameter('console.command.ids') ? $this->container->getParameter('console.command.ids') : []; $alias = 'console.command.'.strtolower(str_replace('\\', '_', $class)); if (isset($commandIds[$alias]) || $this->container->has($alias)) { continue; diff --git a/CacheClearer/ChainCacheClearer.php b/CacheClearer/ChainCacheClearer.php index 8ee4275b16..f82ada5c4b 100644 --- a/CacheClearer/ChainCacheClearer.php +++ b/CacheClearer/ChainCacheClearer.php @@ -27,7 +27,7 @@ class ChainCacheClearer implements CacheClearerInterface * * @param array $clearers The initial clearers */ - public function __construct($clearers = array()) + public function __construct($clearers = []) { $this->clearers = $clearers; } diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index d413d2c9d6..42add5a686 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -18,9 +18,9 @@ */ class Psr6CacheClearer implements CacheClearerInterface { - private $pools = array(); + private $pools = []; - public function __construct(array $pools = array()) + public function __construct(array $pools = []) { $this->pools = $pools; } diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index ca3911ed5f..eca4e6aede 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -20,11 +20,11 @@ */ class CacheWarmerAggregate implements CacheWarmerInterface { - protected $warmers = array(); + protected $warmers = []; protected $optionalsEnabled = false; private $triggerDeprecation = false; - public function __construct($warmers = array()) + public function __construct($warmers = []) { foreach ($warmers as $warmer) { $this->add($warmer); @@ -70,7 +70,7 @@ 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); - $this->warmers = array(); + $this->warmers = []; foreach ($warmers as $warmer) { $this->add($warmer); } diff --git a/Client.php b/Client.php index 324710bb8a..958c4c81f9 100644 --- a/Client.php +++ b/Client.php @@ -39,7 +39,7 @@ class Client extends BaseClient * @param History $history A History instance to store the browser history * @param CookieJar $cookieJar A CookieJar instance to store the cookies */ - public function __construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null) + public function __construct(HttpKernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null) { // These class properties must be set before calling the parent constructor, as it may depend on it. $this->kernel = $kernel; @@ -159,7 +159,7 @@ protected function filterRequest(DomRequest $request) */ protected function filterFiles(array $files) { - $filtered = array(); + $filtered = []; foreach ($files as $key => $value) { if (\is_array($value)) { $filtered[$key] = $this->filterFiles($value); diff --git a/Config/EnvParametersResource.php b/Config/EnvParametersResource.php index f8d2a72b2a..a5be98ee81 100644 --- a/Config/EnvParametersResource.php +++ b/Config/EnvParametersResource.php @@ -54,7 +54,7 @@ public function __toString() */ public function getResource() { - return array('prefix' => $this->prefix, 'variables' => $this->variables); + return ['prefix' => $this->prefix, 'variables' => $this->variables]; } /** @@ -67,13 +67,13 @@ public function isFresh($timestamp) public function serialize() { - return serialize(array('prefix' => $this->prefix, 'variables' => $this->variables)); + return serialize(['prefix' => $this->prefix, 'variables' => $this->variables]); } public function unserialize($serialized) { if (\PHP_VERSION_ID >= 70000) { - $unserialized = unserialize($serialized, array('allowed_classes' => false)); + $unserialized = unserialize($serialized, ['allowed_classes' => false]); } else { $unserialized = unserialize($serialized); } @@ -84,7 +84,7 @@ public function unserialize($serialized) private function findVariables() { - $variables = array(); + $variables = []; foreach ($_SERVER as $key => $value) { if (0 === strpos($key, $this->prefix)) { diff --git a/Config/FileLocator.php b/Config/FileLocator.php index c047ba3dac..fd5c8a32c1 100644 --- a/Config/FileLocator.php +++ b/Config/FileLocator.php @@ -29,7 +29,7 @@ class FileLocator extends BaseFileLocator * @param string|null $path The path the global resource directory * @param array $paths An array of paths where to look for resources */ - public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) + public function __construct(KernelInterface $kernel, $path = null, array $paths = []) { $this->kernel = $kernel; if (null !== $path) { diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index fc316920c7..fc6f969a9e 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -34,7 +34,7 @@ final class ArgumentResolver implements ArgumentResolverInterface */ private $argumentValueResolvers; - public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, $argumentValueResolvers = array()) + public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFactory = null, $argumentValueResolvers = []) { $this->argumentMetadataFactory = $argumentMetadataFactory ?: new ArgumentMetadataFactory(); $this->argumentValueResolvers = $argumentValueResolvers ?: self::getDefaultArgumentValueResolvers(); @@ -45,7 +45,7 @@ public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFa */ public function getArguments(Request $request, $controller) { - $arguments = array(); + $arguments = []; foreach ($this->argumentMetadataFactory->createArgumentMetadata($controller) as $metadata) { foreach ($this->argumentValueResolvers as $resolver) { @@ -83,12 +83,12 @@ public function getArguments(Request $request, $controller) public static function getDefaultArgumentValueResolvers() { - return array( + return [ new RequestAttributeValueResolver(), new RequestValueResolver(), new SessionValueResolver(), new DefaultValueResolver(), new VariadicValueResolver(), - ); + ]; } } diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index bc53e94bef..b08877da93 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -77,7 +77,7 @@ protected function createController($controller) $service = $this->container->get($controller); if (null !== $method) { - return array($service, $method); + return [$service, $method]; } if (!method_exists($service, '__invoke')) { diff --git a/Controller/ControllerReference.php b/Controller/ControllerReference.php index fae4e7fa44..e1e9c813ea 100644 --- a/Controller/ControllerReference.php +++ b/Controller/ControllerReference.php @@ -27,15 +27,15 @@ class ControllerReference { public $controller; - public $attributes = array(); - public $query = array(); + public $attributes = []; + public $query = []; /** * @param string $controller The controller name * @param array $attributes An array of parameters to add to the Request attributes * @param array $query An array of parameters to add to the Request query string */ - public function __construct($controller, array $attributes = array(), array $query = array()) + public function __construct($controller, array $attributes = [], array $query = []) { $this->controller = $controller; $this->attributes = $attributes; diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 6d898e7831..50413ce4ed 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -129,7 +129,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete @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 = array(); + $arguments = []; foreach ($parameters as $param) { if (array_key_exists($param->name, $attributes)) { if ($this->supportsVariadic && $param->isVariadic() && \is_array($attributes[$param->name])) { @@ -180,7 +180,7 @@ protected function createController($controller) throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } - return array($this->instantiateController($class), $method); + return [$this->instantiateController($class), $method]; } /** @@ -233,7 +233,7 @@ private function getControllerError($callable) $collection = get_class_methods($controller); - $alternatives = array(); + $alternatives = []; foreach ($collection as $item) { $lev = levenshtein($method, $item); diff --git a/ControllerMetadata/ArgumentMetadataFactory.php b/ControllerMetadata/ArgumentMetadataFactory.php index b46be7e8b7..fa48d0cc11 100644 --- a/ControllerMetadata/ArgumentMetadataFactory.php +++ b/ControllerMetadata/ArgumentMetadataFactory.php @@ -47,7 +47,7 @@ public function __construct() */ public function createArgumentMetadata($controller) { - $arguments = array(); + $arguments = []; if (\is_array($controller)) { $reflection = new \ReflectionMethod($controller[0], $controller[1]); diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index abfd939f5f..626c1cc695 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -54,7 +54,7 @@ public function setKernel(KernelInterface $kernel = null) */ public function collect(Request $request, Response $response, \Exception $exception = null) { - $this->data = array( + $this->data = [ 'app_name' => $this->name, 'app_version' => $this->version, 'token' => $response->headers->get('X-Debug-Token'), @@ -70,9 +70,9 @@ public function collect(Request $request, Response $response, \Exception $except '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), - 'bundles' => array(), + 'bundles' => [], 'sapi_name' => \PHP_SAPI, - ); + ]; if (isset($this->kernel)) { foreach ($this->kernel->getBundles() as $name => $bundle) { @@ -98,7 +98,7 @@ public function collect(Request $request, Response $response, \Exception $except */ public function reset() { - $this->data = array(); + $this->data = []; } public function lateCollect() diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 6d1a822e47..de19678a30 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -28,7 +28,7 @@ */ abstract class DataCollector implements DataCollectorInterface, \Serializable { - protected $data = array(); + protected $data = []; /** * @var ValueExporter @@ -111,7 +111,7 @@ protected function varToString($var) */ protected function getCasters() { - return array( + return [ '*' => function ($v, array $a, Stub $s, $isNested) { if (!$v instanceof Stub) { foreach ($a as $k => $v) { @@ -123,6 +123,6 @@ protected function getCasters() return $a; }, - ); + ]; } } diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 7e2430c4ba..27197226de 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -49,12 +49,12 @@ public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $this->dumperIsInjected = null !== $dumper; // All clones share these properties by reference: - $this->rootRefs = array( + $this->rootRefs = [ &$this->data, &$this->dataCount, &$this->isCollected, &$this->clonesCount, - ); + ]; } public function __clone() @@ -103,7 +103,7 @@ public function dump(Data $data) if ($src) { $src = explode("\n", $src); - $fileExcerpt = array(); + $fileExcerpt = []; for ($i = max($line - 3, 1), $max = min($line + 3, \count($src)); $i <= $max; ++$i) { $fileExcerpt[] = ''.$this->htmlEncode($src[$i - 1]).''; @@ -153,7 +153,7 @@ public function collect(Request $request, Response $response, \Exception $except ) { if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) { $this->dumper = new HtmlDumper('php://output', $this->charset); - $this->dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat)); + $this->dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { $this->dumper = new CliDumper('php://output', $this->charset); } @@ -169,7 +169,7 @@ public function reset() if ($this->stopwatch) { $this->stopwatch->reset(); } - $this->data = array(); + $this->data = []; $this->dataCount = 0; $this->isCollected = true; $this->clonesCount = 0; @@ -185,7 +185,7 @@ public function serialize() $this->data[] = $this->fileLinkFormat; $this->data[] = $this->charset; $ser = serialize($this->data); - $this->data = array(); + $this->data = []; $this->dataCount = 0; $this->isCollected = true; if (!$this->dumperIsInjected) { @@ -215,11 +215,11 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) if ('html' === $format) { $dumper = new HtmlDumper($data, $this->charset); - $dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat)); + $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format)); } - $dumps = array(); + $dumps = []; foreach ($this->data as $dump) { $dumper->dump($dump['data']->withMaxDepth($maxDepthLimit)->withMaxItemsPerDepth($maxItemsPerDepth)); @@ -250,9 +250,9 @@ public function __destruct() --$i; } - if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true) && stripos($h[$i], 'html')) { + if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) { $this->dumper = new HtmlDumper('php://output', $this->charset); - $this->dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat)); + $this->dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { $this->dumper = new CliDumper('php://output', $this->charset); } @@ -262,7 +262,7 @@ public function __destruct() $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']); } - $this->data = array(); + $this->data = []; $this->dataCount = 0; } } @@ -276,7 +276,7 @@ private function doDump($data, $name, $file, $line) $s = $this->style('meta', '%s'); $f = strip_tags($this->style('', $file)); $name = strip_tags($this->style('', $name)); - if ($fmt && $link = \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line)) { + if ($fmt && $link = \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line)) { $name = sprintf(''.$s.'', strip_tags($this->style('', $link)), $f, $name); } else { $name = sprintf(''.$s.'', $f, $name); diff --git a/DataCollector/EventDataCollector.php b/DataCollector/EventDataCollector.php index 81076fd726..78e9e29198 100644 --- a/DataCollector/EventDataCollector.php +++ b/DataCollector/EventDataCollector.php @@ -38,15 +38,15 @@ public function __construct(EventDispatcherInterface $dispatcher = null) */ public function collect(Request $request, Response $response, \Exception $exception = null) { - $this->data = array( - 'called_listeners' => array(), - 'not_called_listeners' => array(), - ); + $this->data = [ + 'called_listeners' => [], + 'not_called_listeners' => [], + ]; } public function reset() { - $this->data = array(); + $this->data = []; if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { if (!method_exists($this->dispatcher, 'reset')) { diff --git a/DataCollector/ExceptionDataCollector.php b/DataCollector/ExceptionDataCollector.php index 7a25f14921..c76e7f45bd 100644 --- a/DataCollector/ExceptionDataCollector.php +++ b/DataCollector/ExceptionDataCollector.php @@ -28,9 +28,9 @@ class ExceptionDataCollector extends DataCollector public function collect(Request $request, Response $response, \Exception $exception = null) { if (null !== $exception) { - $this->data = array( + $this->data = [ 'exception' => FlattenException::create($exception), - ); + ]; } } @@ -39,7 +39,7 @@ public function collect(Request $request, Response $response, \Exception $except */ public function reset() { - $this->data = array(); + $this->data = []; } /** diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 97b8a8620c..1d95b8b566 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -55,7 +55,7 @@ public function reset() if ($this->logger && method_exists($this->logger, 'clear')) { $this->logger->clear(); } - $this->data = array(); + $this->data = []; } /** @@ -79,12 +79,12 @@ public function lateCollect() */ public function getLogs() { - return isset($this->data['logs']) ? $this->data['logs'] : array(); + return isset($this->data['logs']) ? $this->data['logs'] : []; } public function getPriorities() { - return isset($this->data['priorities']) ? $this->data['priorities'] : array(); + return isset($this->data['priorities']) ? $this->data['priorities'] : []; } public function countErrors() @@ -109,7 +109,7 @@ public function countScreams() public function getCompilerLogs() { - return isset($this->data['compiler_logs']) ? $this->data['compiler_logs'] : array(); + return isset($this->data['compiler_logs']) ? $this->data['compiler_logs'] : []; } /** @@ -123,13 +123,13 @@ public function getName() private function getContainerDeprecationLogs() { if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Deprecations.log')) { - return array(); + return []; } $bootTime = filemtime($file); - $logs = array(); + $logs = []; foreach (unserialize(file_get_contents($file)) as $log) { - $log['context'] = array('exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])); + $log['context'] = ['exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])]; $log['timestamp'] = $bootTime; $log['priority'] = 100; $log['priorityName'] = 'DEBUG'; @@ -145,17 +145,17 @@ private function getContainerDeprecationLogs() private function getContainerCompilerLogs() { if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Compiler.log')) { - return array(); + return []; } - $logs = array(); + $logs = []; 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 = array('Unknown Compiler Pass', implode(': ', $log)); + $log = ['Unknown Compiler Pass', implode(': ', $log)]; } - $logs[$log[0]][] = array('message' => $log[1]); + $logs[$log[0]][] = ['message' => $log[1]]; } return $logs; @@ -163,8 +163,8 @@ private function getContainerCompilerLogs() private function sanitizeLogs($logs) { - $sanitizedLogs = array(); - $silencedLogs = array(); + $sanitizedLogs = []; + $silencedLogs = []; foreach ($logs as $log) { if (!$this->isSilencedOrDeprecationErrorLog($log)) { @@ -183,10 +183,10 @@ private function sanitizeLogs($logs) $silencedLogs[$h] = true; if (!isset($sanitizedLogs[$message])) { - $sanitizedLogs[$message] = $log + array( + $sanitizedLogs[$message] = $log + [ 'errorCount' => 0, 'scream' => true, - ); + ]; } $sanitizedLogs[$message]['errorCount'] += $exception->count; @@ -198,10 +198,10 @@ private function sanitizeLogs($logs) if (isset($sanitizedLogs[$errorId])) { ++$sanitizedLogs[$errorId]['errorCount']; } else { - $log += array( + $log += [ 'errorCount' => 1, 'scream' => false, - ); + ]; $sanitizedLogs[$errorId] = $log; } @@ -222,7 +222,7 @@ private function isSilencedOrDeprecationErrorLog(array $log) return true; } - if ($exception instanceof \ErrorException && \in_array($exception->getSeverity(), array(E_DEPRECATED, E_USER_DEPRECATED), true)) { + if ($exception instanceof \ErrorException && \in_array($exception->getSeverity(), [E_DEPRECATED, E_USER_DEPRECATED], true)) { return true; } @@ -231,23 +231,23 @@ private function isSilencedOrDeprecationErrorLog(array $log) private function computeErrorsCount(array $containerDeprecationLogs) { - $silencedLogs = array(); - $count = array( + $silencedLogs = []; + $count = [ 'error_count' => $this->logger->countErrors(), 'deprecation_count' => 0, 'warning_count' => 0, 'scream_count' => 0, - 'priorities' => array(), - ); + 'priorities' => [], + ]; foreach ($this->logger->getLogs() as $log) { if (isset($count['priorities'][$log['priority']])) { ++$count['priorities'][$log['priority']]['count']; } else { - $count['priorities'][$log['priority']] = array( + $count['priorities'][$log['priority']] = [ 'count' => 1, 'name' => $log['priorityName'], - ); + ]; } if ('WARNING' === $log['priorityName']) { ++$count['warning_count']; diff --git a/DataCollector/MemoryDataCollector.php b/DataCollector/MemoryDataCollector.php index 310b2f91a5..7a6e1c0646 100644 --- a/DataCollector/MemoryDataCollector.php +++ b/DataCollector/MemoryDataCollector.php @@ -39,10 +39,10 @@ public function collect(Request $request, Response $response, \Exception $except */ public function reset() { - $this->data = array( + $this->data = [ 'memory' => 0, 'memory_limit' => $this->convertToBytes(ini_get('memory_limit')), - ); + ]; } /** diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 10492e4465..671865aa16 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -38,7 +38,7 @@ public function __construct() public function collect(Request $request, Response $response, \Exception $exception = null) { // attributes are serialized and as they can be anything, they need to be converted to strings. - $attributes = array(); + $attributes = []; $route = ''; foreach ($request->attributes->all() as $key => $value) { if ('_route' === $key) { @@ -57,10 +57,10 @@ public function collect(Request $request, Response $response, \Exception $except $content = false; } - $sessionMetadata = array(); - $sessionAttributes = array(); + $sessionMetadata = []; + $sessionAttributes = []; $session = null; - $flashes = array(); + $flashes = []; if ($request->hasSession()) { $session = $request->getSession(); if ($session->isStarted()) { @@ -74,12 +74,12 @@ public function collect(Request $request, Response $response, \Exception $except $statusCode = $response->getStatusCode(); - $responseCookies = array(); + $responseCookies = []; foreach ($response->headers->getCookies() as $cookie) { $responseCookies[$cookie->getName()] = $cookie; } - $this->data = array( + $this->data = [ 'method' => $request->getMethod(), 'format' => $request->getRequestFormat(), 'content' => $content, @@ -101,7 +101,7 @@ public function collect(Request $request, Response $response, \Exception $except 'path_info' => $request->getPathInfo(), 'controller' => 'n/a', 'locale' => $request->getLocale(), - ); + ]; if (isset($this->data['request_headers']['php-auth-pw'])) { $this->data['request_headers']['php-auth-pw'] = '******'; @@ -138,14 +138,14 @@ public function collect(Request $request, Response $response, \Exception $except if ($response->isRedirect()) { $response->headers->setCookie(new Cookie( 'sf_redirect', - json_encode(array( + json_encode([ 'token' => $response->headers->get('x-debug-token'), 'route' => $request->attributes->get('_route', 'n/a'), 'method' => $request->getMethod(), 'controller' => $this->parseController($request->attributes->get('_controller')), 'status_code' => $statusCode, 'status_text' => Response::$statusTexts[(int) $statusCode], - )) + ]) )); } @@ -159,7 +159,7 @@ public function lateCollect() public function reset() { - $this->data = array(); + $this->data = []; $this->controllers = new \SplObjectStorage(); } @@ -284,7 +284,7 @@ public function getIdentifier() */ public function getRouteParams() { - return isset($this->data['request_attributes']['_route_params']) ? $this->data['request_attributes']['_route_params']->getValue() : array(); + return isset($this->data['request_attributes']['_route_params']) ? $this->data['request_attributes']['_route_params']->getValue() : []; } /** @@ -327,10 +327,10 @@ public function onKernelResponse(FilterResponseEvent $event) public static function getSubscribedEvents() { - return array( + return [ KernelEvents::CONTROLLER => 'onKernelController', KernelEvents::RESPONSE => 'onKernelResponse', - ); + ]; } /** @@ -358,21 +358,21 @@ protected function parseController($controller) try { $r = new \ReflectionMethod($controller[0], $controller[1]); - return array( + return [ 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFileName(), 'line' => $r->getStartLine(), - ); + ]; } catch (\ReflectionException $e) { if (\is_callable($controller)) { // using __call or __callStatic - return array( + return [ 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => 'n/a', 'line' => 'n/a', - ); + ]; } } } @@ -380,12 +380,12 @@ protected function parseController($controller) if ($controller instanceof \Closure) { $r = new \ReflectionFunction($controller); - $controller = array( + $controller = [ 'class' => $r->getName(), 'method' => null, 'file' => $r->getFileName(), 'line' => $r->getStartLine(), - ); + ]; if (false !== strpos($r->name, '{closure}')) { return $controller; @@ -404,12 +404,12 @@ protected function parseController($controller) if (\is_object($controller)) { $r = new \ReflectionClass($controller); - return array( + return [ 'class' => $r->getName(), 'method' => null, 'file' => $r->getFileName(), 'line' => $r->getStartLine(), - ); + ]; } return \is_string($controller) ? $controller : 'n/a'; diff --git a/DataCollector/RouterDataCollector.php b/DataCollector/RouterDataCollector.php index 481747b3c8..432dc3618f 100644 --- a/DataCollector/RouterDataCollector.php +++ b/DataCollector/RouterDataCollector.php @@ -54,11 +54,11 @@ public function reset() { $this->controllers = new \SplObjectStorage(); - $this->data = array( + $this->data = [ 'redirect' => false, 'url' => null, 'route' => null, - ); + ]; } protected function guessRoute(Request $request, $controller) diff --git a/DataCollector/TimeDataCollector.php b/DataCollector/TimeDataCollector.php index e489d77598..99149ab0be 100644 --- a/DataCollector/TimeDataCollector.php +++ b/DataCollector/TimeDataCollector.php @@ -43,11 +43,11 @@ public function collect(Request $request, Response $response, \Exception $except $startTime = $request->server->get('REQUEST_TIME_FLOAT'); } - $this->data = array( + $this->data = [ 'token' => $response->headers->get('X-Debug-Token'), 'start_time' => $startTime * 1000, - 'events' => array(), - ); + 'events' => [], + ]; } /** @@ -55,7 +55,7 @@ public function collect(Request $request, Response $response, \Exception $except */ public function reset() { - $this->data = array(); + $this->data = []; if (null !== $this->stopwatch) { $this->stopwatch->reset(); diff --git a/DataCollector/Util/ValueExporter.php b/DataCollector/Util/ValueExporter.php index e30b3a5029..36570b4d5f 100644 --- a/DataCollector/Util/ValueExporter.php +++ b/DataCollector/Util/ValueExporter.php @@ -50,7 +50,7 @@ public function exportValue($value, $depth = 1, $deep = false) $indent = str_repeat(' ', $depth); - $a = array(); + $a = []; foreach ($value as $k => $v) { if (\is_array($v)) { $deep = true; diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index b3c2595b0d..8a4aa62b74 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 = array(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; @@ -55,7 +55,7 @@ public function format($file, $line) } } - return strtr($fmt[0], array('%f' => $file, '%l' => $line)); + return strtr($fmt[0], ['%f' => $file, '%l' => $line]); } return false; @@ -69,7 +69,7 @@ public function serialize() public function unserialize($serialized) { if (\PHP_VERSION_ID >= 70000) { - $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); + $this->fileLinkFormat = unserialize($serialized, ['allowed_classes' => false]); } else { $this->fileLinkFormat = unserialize($serialized); } @@ -99,10 +99,10 @@ private function getFileLinkFormat() return; } - return array( + return [ $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat, $this->baseDir.\DIRECTORY_SEPARATOR, '', - ); + ]; } } } diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 4e59123d19..8bb03bd0c7 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -36,8 +36,8 @@ public function __construct(Kernel $kernel) */ public function process(ContainerBuilder $container) { - $classes = array(); - $annotatedClasses = array(); + $classes = []; + $annotatedClasses = []; foreach ($container->getExtensions() as $extension) { if ($extension instanceof Extension) { if (\PHP_VERSION_ID < 70000) { @@ -67,7 +67,7 @@ public function process(ContainerBuilder $container) */ private function expandClasses(array $patterns, array $classes) { - $expanded = array(); + $expanded = []; // Explicit classes declared in the patterns are returned directly foreach ($patterns as $key => $pattern) { @@ -93,7 +93,7 @@ private function expandClasses(array $patterns, array $classes) private function getClassesInComposerClassMaps() { - $classes = array(); + $classes = []; foreach (spl_autoload_functions() as $function) { if (!\is_array($function)) { @@ -114,14 +114,14 @@ private function getClassesInComposerClassMaps() private function patternsToRegexps($patterns) { - $regexps = array(); + $regexps = []; foreach ($patterns as $pattern) { // Escape user input $regex = preg_quote(ltrim($pattern, '\\')); // Wildcards * and ** - $regex = strtr($regex, array('\\*\\*' => '.*?', '\\*' => '[^\\\\]*?')); + $regex = strtr($regex, ['\\*\\*' => '.*?', '\\*' => '[^\\\\]*?']); // If this class does not end by a slash, anchor the end if ('\\' !== substr($regex, -1)) { diff --git a/DependencyInjection/Extension.php b/DependencyInjection/Extension.php index a382c15d67..ec69392e53 100644 --- a/DependencyInjection/Extension.php +++ b/DependencyInjection/Extension.php @@ -20,8 +20,8 @@ */ abstract class Extension extends BaseExtension { - private $classes = array(); - private $annotatedClasses = array(); + private $classes = []; + private $annotatedClasses = []; /** * Gets the classes to cache. diff --git a/DependencyInjection/FragmentRendererPass.php b/DependencyInjection/FragmentRendererPass.php index 06a39c8bc0..a15fbaa172 100644 --- a/DependencyInjection/FragmentRendererPass.php +++ b/DependencyInjection/FragmentRendererPass.php @@ -45,7 +45,7 @@ public function process(ContainerBuilder $container) } $definition = $container->getDefinition($this->handlerService); - $renderers = array(); + $renderers = []; foreach ($container->findTaggedServiceIds($this->rendererTag, true) as $id => $tags) { $def = $container->getDefinition($id); $class = $container->getParameterBag()->resolveValue($def->getClass()); diff --git a/DependencyInjection/LazyLoadingFragmentHandler.php b/DependencyInjection/LazyLoadingFragmentHandler.php index 00b05959cf..1722ef58b1 100644 --- a/DependencyInjection/LazyLoadingFragmentHandler.php +++ b/DependencyInjection/LazyLoadingFragmentHandler.php @@ -26,8 +26,8 @@ class LazyLoadingFragmentHandler extends FragmentHandler /** * @deprecated since version 3.3, to be removed in 4.0 */ - private $rendererIds = array(); - private $initialized = array(); + private $rendererIds = []; + private $initialized = []; /** * @param ContainerInterface $container A container @@ -38,7 +38,7 @@ public function __construct(ContainerInterface $container, RequestStack $request { $this->container = $container; - parent::__construct($requestStack, array(), $debug); + parent::__construct($requestStack, [], $debug); } /** @@ -59,7 +59,7 @@ public function addRendererService($name, $renderer) /** * {@inheritdoc} */ - public function render($uri, $renderer = 'inline', array $options = array()) + public function render($uri, $renderer = 'inline', array $options = []) { // BC 3.x, to be removed in 4.0 if (isset($this->rendererIds[$renderer])) { diff --git a/DependencyInjection/MergeExtensionConfigurationPass.php b/DependencyInjection/MergeExtensionConfigurationPass.php index 1dbf7f7bee..83e1b758de 100644 --- a/DependencyInjection/MergeExtensionConfigurationPass.php +++ b/DependencyInjection/MergeExtensionConfigurationPass.php @@ -32,7 +32,7 @@ public function process(ContainerBuilder $container) { foreach ($this->extensions as $extension) { if (!\count($container->getExtensionConfig($extension))) { - $container->loadFromExtension($extension, array()); + $container->loadFromExtension($extension, []); } } diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index cb05f6fbeb..d021c6ee8a 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -47,7 +47,7 @@ public function process(ContainerBuilder $container) } $parameterBag = $container->getParameterBag(); - $controllers = array(); + $controllers = []; foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) { $def = $container->getDefinition($id); @@ -70,14 +70,14 @@ public function process(ContainerBuilder $container) $isContainerAware = $r->implementsInterface(ContainerAwareInterface::class) || is_subclass_of($class, AbstractController::class); // get regular public methods - $methods = array(); - $arguments = array(); + $methods = []; + $arguments = []; foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $r) { if ('setContainer' === $r->name && $isContainerAware) { continue; } if (!$r->isConstructor() && !$r->isDestructor() && !$r->isAbstract()) { - $methods[strtolower($r->name)] = array($r, $r->getParameters()); + $methods[strtolower($r->name)] = [$r, $r->getParameters()]; } } @@ -87,7 +87,7 @@ public function process(ContainerBuilder $container) $autowire = true; continue; } - foreach (array('action', 'argument', 'id') as $k) { + 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)); } @@ -117,7 +117,7 @@ public function process(ContainerBuilder $container) /** @var \ReflectionMethod $r */ // create a per-method map of argument-names to service/type-references - $args = array(); + $args = []; foreach ($parameters as $p) { /** @var \ReflectionParameter $p */ $type = $target = ProxyHelper::getTypeHint($r, $p, true); @@ -141,7 +141,7 @@ public function process(ContainerBuilder $container) continue; } - $binding->setValues(array($bindingValue, $bindingId, true)); + $binding->setValues([$bindingValue, $bindingId, true]); $args[$p->name] = $bindingValue; continue; diff --git a/DependencyInjection/ResettableServicePass.php b/DependencyInjection/ResettableServicePass.php index 29433a6d5b..28136be625 100644 --- a/DependencyInjection/ResettableServicePass.php +++ b/DependencyInjection/ResettableServicePass.php @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container) return; } - $services = $methods = array(); + $services = $methods = []; foreach ($container->findTaggedServiceIds($this->tagName, true) as $id => $tags) { $services[$id] = new Reference($id, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE); diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 41187d4125..aee5d6f88f 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -26,7 +26,7 @@ */ abstract class AbstractSessionListener implements EventSubscriberInterface { - private $sessionUsageStack = array(); + private $sessionUsageStack = []; public function onKernelRequest(GetResponseEvent $event) { @@ -74,12 +74,12 @@ public function onFinishRequest(FinishRequestEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 128), + return [ + KernelEvents::REQUEST => ['onKernelRequest', 128], // low priority to come after regular response listeners, same as SaveSessionListener - KernelEvents::RESPONSE => array('onKernelResponse', -1000), - KernelEvents::FINISH_REQUEST => array('onFinishRequest'), - ); + KernelEvents::RESPONSE => ['onKernelResponse', -1000], + KernelEvents::FINISH_REQUEST => ['onFinishRequest'], + ]; } /** diff --git a/EventListener/AbstractTestSessionListener.php b/EventListener/AbstractTestSessionListener.php index cb5da50bd0..714b315a32 100644 --- a/EventListener/AbstractTestSessionListener.php +++ b/EventListener/AbstractTestSessionListener.php @@ -85,10 +85,10 @@ public function onKernelResponse(FilterResponseEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('onKernelRequest', 192), - KernelEvents::RESPONSE => array('onKernelResponse', -128), - ); + return [ + KernelEvents::REQUEST => ['onKernelRequest', 192], + KernelEvents::RESPONSE => ['onKernelResponse', -128], + ]; } /** diff --git a/EventListener/AddRequestFormatsListener.php b/EventListener/AddRequestFormatsListener.php index 5ec528417c..68d806af01 100644 --- a/EventListener/AddRequestFormatsListener.php +++ b/EventListener/AddRequestFormatsListener.php @@ -45,6 +45,6 @@ public function onKernelRequest(GetResponseEvent $event) */ public static function getSubscribedEvents() { - return array(KernelEvents::REQUEST => array('onKernelRequest', 1)); + return [KernelEvents::REQUEST => ['onKernelRequest', 1]]; } } diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index 04137c7468..77f9e2f618 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -145,10 +145,10 @@ public function configure(Event $event = null) public static function getSubscribedEvents() { - $events = array(KernelEvents::REQUEST => array('configure', 2048)); + $events = [KernelEvents::REQUEST => ['configure', 2048]]; if ('cli' === \PHP_SAPI && \defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) { - $events[ConsoleEvents::COMMAND] = array('configure', 2048); + $events[ConsoleEvents::COMMAND] = ['configure', 2048]; } return $events; diff --git a/EventListener/DumpListener.php b/EventListener/DumpListener.php index de19e13113..2f47d1068c 100644 --- a/EventListener/DumpListener.php +++ b/EventListener/DumpListener.php @@ -46,10 +46,10 @@ public function configure() public static function getSubscribedEvents() { if (!class_exists(ConsoleEvents::class)) { - return array(); + return []; } // Register early to have a working dump() as early as possible - return array(ConsoleEvents::COMMAND => array('configure', 1024)); + return [ConsoleEvents::COMMAND => ['configure', 1024]]; } } diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index 71de60434d..67db029af1 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -84,9 +84,9 @@ public function onKernelException(GetResponseForExceptionEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::EXCEPTION => array('onKernelException', -128), - ); + return [ + KernelEvents::EXCEPTION => ['onKernelException', -128], + ]; } /** @@ -99,9 +99,9 @@ protected function logException(\Exception $exception, $message) { if (null !== $this->logger) { if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) { - $this->logger->critical($message, array('exception' => $exception)); + $this->logger->critical($message, ['exception' => $exception]); } else { - $this->logger->error($message, array('exception' => $exception)); + $this->logger->error($message, ['exception' => $exception]); } } } @@ -116,11 +116,11 @@ protected function logException(\Exception $exception, $message) */ protected function duplicateRequest(\Exception $exception, Request $request) { - $attributes = array( + $attributes = [ '_controller' => $this->controller, 'exception' => FlattenException::create($exception), 'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null, - ); + ]; $request = $request->duplicate(null, null, $attributes); $request->setMethod('GET'); diff --git a/EventListener/FragmentListener.php b/EventListener/FragmentListener.php index 574d7c05c9..1333120e2d 100644 --- a/EventListener/FragmentListener.php +++ b/EventListener/FragmentListener.php @@ -70,7 +70,7 @@ public function onKernelRequest(GetResponseEvent $event) parse_str($request->query->get('_path', ''), $attributes); $request->attributes->add($attributes); - $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes)); + $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', []), $attributes)); $request->query->remove('_path'); } @@ -92,8 +92,8 @@ protected function validateRequest(Request $request) public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 48)), - ); + return [ + KernelEvents::REQUEST => [['onKernelRequest', 48]], + ]; } } diff --git a/EventListener/LocaleListener.php b/EventListener/LocaleListener.php index ed0236efc8..c7e32dbb23 100644 --- a/EventListener/LocaleListener.php +++ b/EventListener/LocaleListener.php @@ -74,10 +74,10 @@ private function setRouterContext(Request $request) public static function getSubscribedEvents() { - return array( + return [ // must be registered after the Router to have access to the _locale - KernelEvents::REQUEST => array(array('onKernelRequest', 16)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); + KernelEvents::REQUEST => [['onKernelRequest', 16]], + KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]], + ]; } } diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index 2e54a92f08..5304b8097b 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -119,10 +119,10 @@ public function onKernelTerminate(PostResponseEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', -100), + return [ + KernelEvents::RESPONSE => ['onKernelResponse', -100], KernelEvents::EXCEPTION => 'onKernelException', - KernelEvents::TERMINATE => array('onKernelTerminate', -1024), - ); + KernelEvents::TERMINATE => ['onKernelTerminate', -1024], + ]; } } diff --git a/EventListener/ResponseListener.php b/EventListener/ResponseListener.php index f24784527b..43527b7ffc 100644 --- a/EventListener/ResponseListener.php +++ b/EventListener/ResponseListener.php @@ -49,8 +49,8 @@ public function onKernelResponse(FilterResponseEvent $event) public static function getSubscribedEvents() { - return array( + return [ KernelEvents::RESPONSE => 'onKernelResponse', - ); + ]; } } diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index ab5c86cdd0..378327b574 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -118,12 +118,12 @@ public function onKernelRequest(GetResponseEvent $event) } if (null !== $this->logger) { - $this->logger->info('Matched route "{route}".', array( + $this->logger->info('Matched route "{route}".', [ 'route' => isset($parameters['_route']) ? $parameters['_route'] : 'n/a', 'route_parameters' => $parameters, 'request_uri' => $request->getUri(), 'method' => $request->getMethod(), - )); + ]); } $request->attributes->add($parameters); @@ -157,11 +157,11 @@ public function onKernelException(GetResponseForExceptionEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 32)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - KernelEvents::EXCEPTION => array('onKernelException', -64), - ); + return [ + KernelEvents::REQUEST => [['onKernelRequest', 32]], + KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]], + KernelEvents::EXCEPTION => ['onKernelException', -64], + ]; } private function createWelcomeResponse() diff --git a/EventListener/SaveSessionListener.php b/EventListener/SaveSessionListener.php index 36809b59af..5901200a70 100644 --- a/EventListener/SaveSessionListener.php +++ b/EventListener/SaveSessionListener.php @@ -58,9 +58,9 @@ public function onKernelResponse(FilterResponseEvent $event) public static function getSubscribedEvents() { - return array( + return [ // low priority but higher than StreamedResponseListener - KernelEvents::RESPONSE => array(array('onKernelResponse', -1000)), - ); + KernelEvents::RESPONSE => [['onKernelResponse', -1000]], + ]; } } diff --git a/EventListener/StreamedResponseListener.php b/EventListener/StreamedResponseListener.php index 2c616b9182..895176a931 100644 --- a/EventListener/StreamedResponseListener.php +++ b/EventListener/StreamedResponseListener.php @@ -42,8 +42,8 @@ public function onKernelResponse(FilterResponseEvent $event) public static function getSubscribedEvents() { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', -1024), - ); + return [ + KernelEvents::RESPONSE => ['onKernelResponse', -1024], + ]; } } diff --git a/EventListener/SurrogateListener.php b/EventListener/SurrogateListener.php index 6343533857..0fddddde42 100644 --- a/EventListener/SurrogateListener.php +++ b/EventListener/SurrogateListener.php @@ -58,8 +58,8 @@ public function onKernelResponse(FilterResponseEvent $event) public static function getSubscribedEvents() { - return array( + return [ KernelEvents::RESPONSE => 'onKernelResponse', - ); + ]; } } diff --git a/EventListener/TranslatorListener.php b/EventListener/TranslatorListener.php index 2a5fc71280..0f506061a6 100644 --- a/EventListener/TranslatorListener.php +++ b/EventListener/TranslatorListener.php @@ -51,11 +51,11 @@ public function onKernelFinishRequest(FinishRequestEvent $event) public static function getSubscribedEvents() { - return array( + return [ // must be registered after the Locale listener - KernelEvents::REQUEST => array(array('onKernelRequest', 10)), - KernelEvents::FINISH_REQUEST => array(array('onKernelFinishRequest', 0)), - ); + KernelEvents::REQUEST => [['onKernelRequest', 10]], + KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]], + ]; } private function setLocale(Request $request) diff --git a/EventListener/ValidateRequestListener.php b/EventListener/ValidateRequestListener.php index a33853f727..2e921869b9 100644 --- a/EventListener/ValidateRequestListener.php +++ b/EventListener/ValidateRequestListener.php @@ -44,10 +44,10 @@ public function onKernelRequest(GetResponseEvent $event) */ public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('onKernelRequest', 256), - ), - ); + return [ + KernelEvents::REQUEST => [ + ['onKernelRequest', 256], + ], + ]; } } diff --git a/Exception/AccessDeniedHttpException.php b/Exception/AccessDeniedHttpException.php index 3941884266..05fe7c4a40 100644 --- a/Exception/AccessDeniedHttpException.php +++ b/Exception/AccessDeniedHttpException.php @@ -24,6 +24,6 @@ class AccessDeniedHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(403, $message, $previous, array(), $code); + parent::__construct(403, $message, $previous, [], $code); } } diff --git a/Exception/BadRequestHttpException.php b/Exception/BadRequestHttpException.php index c28d83739c..683ef1a99e 100644 --- a/Exception/BadRequestHttpException.php +++ b/Exception/BadRequestHttpException.php @@ -23,6 +23,6 @@ class BadRequestHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(400, $message, $previous, array(), $code); + parent::__construct(400, $message, $previous, [], $code); } } diff --git a/Exception/ConflictHttpException.php b/Exception/ConflictHttpException.php index 79f24f2e56..aaf258a07d 100644 --- a/Exception/ConflictHttpException.php +++ b/Exception/ConflictHttpException.php @@ -23,6 +23,6 @@ class ConflictHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(409, $message, $previous, array(), $code); + parent::__construct(409, $message, $previous, [], $code); } } diff --git a/Exception/GoneHttpException.php b/Exception/GoneHttpException.php index 84e6915df7..f855ba02c8 100644 --- a/Exception/GoneHttpException.php +++ b/Exception/GoneHttpException.php @@ -23,6 +23,6 @@ class GoneHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(410, $message, $previous, array(), $code); + parent::__construct(410, $message, $previous, [], $code); } } diff --git a/Exception/HttpException.php b/Exception/HttpException.php index e8e3760583..809d29e6e3 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($statusCode, $message = null, \Exception $previous = null, array $headers = array(), $code = 0) + public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = [], $code = 0) { $this->statusCode = $statusCode; $this->headers = $headers; diff --git a/Exception/LengthRequiredHttpException.php b/Exception/LengthRequiredHttpException.php index 645efe87d7..8ad08f4208 100644 --- a/Exception/LengthRequiredHttpException.php +++ b/Exception/LengthRequiredHttpException.php @@ -23,6 +23,6 @@ class LengthRequiredHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(411, $message, $previous, array(), $code); + parent::__construct(411, $message, $previous, [], $code); } } diff --git a/Exception/MethodNotAllowedHttpException.php b/Exception/MethodNotAllowedHttpException.php index e308a5fee2..f256ef8615 100644 --- a/Exception/MethodNotAllowedHttpException.php +++ b/Exception/MethodNotAllowedHttpException.php @@ -24,7 +24,7 @@ class MethodNotAllowedHttpException extends HttpException */ public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0) { - $headers = array('Allow' => strtoupper(implode(', ', $allow))); + $headers = ['Allow' => strtoupper(implode(', ', $allow))]; parent::__construct(405, $message, $previous, $headers, $code); } diff --git a/Exception/NotAcceptableHttpException.php b/Exception/NotAcceptableHttpException.php index 097a13fd9b..a48bbe70eb 100644 --- a/Exception/NotAcceptableHttpException.php +++ b/Exception/NotAcceptableHttpException.php @@ -23,6 +23,6 @@ class NotAcceptableHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(406, $message, $previous, array(), $code); + parent::__construct(406, $message, $previous, [], $code); } } diff --git a/Exception/NotFoundHttpException.php b/Exception/NotFoundHttpException.php index 878173cc7b..01a5bd080c 100644 --- a/Exception/NotFoundHttpException.php +++ b/Exception/NotFoundHttpException.php @@ -23,6 +23,6 @@ class NotFoundHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(404, $message, $previous, array(), $code); + parent::__construct(404, $message, $previous, [], $code); } } diff --git a/Exception/PreconditionFailedHttpException.php b/Exception/PreconditionFailedHttpException.php index 9f13a624cc..3cf33f988a 100644 --- a/Exception/PreconditionFailedHttpException.php +++ b/Exception/PreconditionFailedHttpException.php @@ -23,6 +23,6 @@ class PreconditionFailedHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(412, $message, $previous, array(), $code); + parent::__construct(412, $message, $previous, [], $code); } } diff --git a/Exception/PreconditionRequiredHttpException.php b/Exception/PreconditionRequiredHttpException.php index 9d0a36d7d3..a2512c5c1b 100644 --- a/Exception/PreconditionRequiredHttpException.php +++ b/Exception/PreconditionRequiredHttpException.php @@ -25,6 +25,6 @@ class PreconditionRequiredHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(428, $message, $previous, array(), $code); + parent::__construct(428, $message, $previous, [], $code); } } diff --git a/Exception/ServiceUnavailableHttpException.php b/Exception/ServiceUnavailableHttpException.php index b2767c3fd5..52ce75132f 100644 --- a/Exception/ServiceUnavailableHttpException.php +++ b/Exception/ServiceUnavailableHttpException.php @@ -24,9 +24,9 @@ class ServiceUnavailableHttpException extends HttpException */ public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0) { - $headers = array(); + $headers = []; if ($retryAfter) { - $headers = array('Retry-After' => $retryAfter); + $headers = ['Retry-After' => $retryAfter]; } parent::__construct(503, $message, $previous, $headers, $code); diff --git a/Exception/TooManyRequestsHttpException.php b/Exception/TooManyRequestsHttpException.php index 7d8a803323..d313f7ead8 100644 --- a/Exception/TooManyRequestsHttpException.php +++ b/Exception/TooManyRequestsHttpException.php @@ -26,9 +26,9 @@ class TooManyRequestsHttpException extends HttpException */ public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0) { - $headers = array(); + $headers = []; if ($retryAfter) { - $headers = array('Retry-After' => $retryAfter); + $headers = ['Retry-After' => $retryAfter]; } parent::__construct(429, $message, $previous, $headers, $code); diff --git a/Exception/UnauthorizedHttpException.php b/Exception/UnauthorizedHttpException.php index 05ac875c55..d945df2bc8 100644 --- a/Exception/UnauthorizedHttpException.php +++ b/Exception/UnauthorizedHttpException.php @@ -24,7 +24,7 @@ class UnauthorizedHttpException extends HttpException */ public function __construct($challenge, $message = null, \Exception $previous = null, $code = 0) { - $headers = array('WWW-Authenticate' => $challenge); + $headers = ['WWW-Authenticate' => $challenge]; parent::__construct(401, $message, $previous, $headers, $code); } diff --git a/Exception/UnprocessableEntityHttpException.php b/Exception/UnprocessableEntityHttpException.php index 01b8b8465a..2263a31253 100644 --- a/Exception/UnprocessableEntityHttpException.php +++ b/Exception/UnprocessableEntityHttpException.php @@ -23,6 +23,6 @@ class UnprocessableEntityHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(422, $message, $previous, array(), $code); + parent::__construct(422, $message, $previous, [], $code); } } diff --git a/Exception/UnsupportedMediaTypeHttpException.php b/Exception/UnsupportedMediaTypeHttpException.php index 6913504e83..75f844ab57 100644 --- a/Exception/UnsupportedMediaTypeHttpException.php +++ b/Exception/UnsupportedMediaTypeHttpException.php @@ -23,6 +23,6 @@ class UnsupportedMediaTypeHttpException extends HttpException */ public function __construct($message = null, \Exception $previous = null, $code = 0) { - parent::__construct(415, $message, $previous, array(), $code); + parent::__construct(415, $message, $previous, [], $code); } } diff --git a/Fragment/AbstractSurrogateFragmentRenderer.php b/Fragment/AbstractSurrogateFragmentRenderer.php index 3c8934ff89..430486e549 100644 --- a/Fragment/AbstractSurrogateFragmentRenderer.php +++ b/Fragment/AbstractSurrogateFragmentRenderer.php @@ -59,7 +59,7 @@ public function __construct(SurrogateInterface $surrogate = null, FragmentRender * * @see Symfony\Component\HttpKernel\HttpCache\SurrogateInterface */ - public function render($uri, Request $request, array $options = array()) + public function render($uri, Request $request, array $options = []) { if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) { if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) { diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index f11db73dc9..f40da0018b 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -29,7 +29,7 @@ class FragmentHandler { private $debug; - private $renderers = array(); + private $renderers = []; private $requestStack; /** @@ -37,7 +37,7 @@ class FragmentHandler * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances * @param bool $debug Whether the debug mode is enabled or not */ - public function __construct(RequestStack $requestStack, array $renderers = array(), $debug = false) + public function __construct(RequestStack $requestStack, array $renderers = [], $debug = false) { $this->requestStack = $requestStack; foreach ($renderers as $renderer) { @@ -70,7 +70,7 @@ public function addRenderer(FragmentRendererInterface $renderer) * @throws \InvalidArgumentException when the renderer does not exist * @throws \LogicException when no master request is being handled */ - public function render($uri, $renderer = 'inline', array $options = array()) + public function render($uri, $renderer = 'inline', array $options = []) { if (!isset($options['ignore_errors'])) { $options['ignore_errors'] = !$this->debug; diff --git a/Fragment/FragmentRendererInterface.php b/Fragment/FragmentRendererInterface.php index bcf4e9944a..8e454a01a6 100644 --- a/Fragment/FragmentRendererInterface.php +++ b/Fragment/FragmentRendererInterface.php @@ -31,7 +31,7 @@ interface FragmentRendererInterface * * @return Response A Response instance */ - public function render($uri, Request $request, array $options = array()); + public function render($uri, Request $request, array $options = []); /** * Gets the name of the strategy. diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index f7150c1979..a0abc05881 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -81,7 +81,7 @@ public function hasTemplating() * * id: An optional hx:include tag id attribute * * attributes: An optional array of hx:include tag attributes */ - public function render($uri, Request $request, array $options = array()) + public function render($uri, Request $request, array $options = []) { if ($uri instanceof ControllerReference) { if (null === $this->signer) { @@ -102,7 +102,7 @@ public function render($uri, Request $request, array $options = array()) $content = $template; } - $attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : array(); + $attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : []; if (isset($options['id']) && $options['id']) { $attributes['id'] = $options['id']; } diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index 13fc335624..73defb9d3e 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -43,7 +43,7 @@ public function __construct(HttpKernelInterface $kernel, EventDispatcherInterfac * * * alt: an alternative URI to render in case of an error */ - public function render($uri, Request $request, array $options = array()) + public function render($uri, Request $request, array $options = []) { $reference = null; if ($uri instanceof ControllerReference) { @@ -54,10 +54,10 @@ public function render($uri, Request $request, array $options = array()) // want that as we want to preserve objects (so we manually set Request attributes // below instead) $attributes = $reference->attributes; - $reference->attributes = array(); + $reference->attributes = []; // The request format and locale might have been overridden by the user - foreach (array('_format', '_locale') as $key) { + foreach (['_format', '_locale'] as $key) { if (isset($attributes[$key])) { $reference->attributes[$key] = $attributes[$key]; } @@ -113,7 +113,7 @@ protected function createSubRequest($uri, Request $request) unset($server['HTTP_IF_MODIFIED_SINCE']); unset($server['HTTP_IF_NONE_MATCH']); - $subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server); + $subRequest = Request::create($uri, 'get', [], $cookies, [], $server); if ($request->headers->has('Surrogate-Capability')) { $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability')); } diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 3b2d5f262c..8918a30570 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -24,16 +24,16 @@ abstract class AbstractSurrogate implements SurrogateInterface { protected $contentTypes; - protected $phpEscapeMap = array( - array('', '', '', ''), - ); + protected $phpEscapeMap = [ + ['', '', '', ''], + ]; /** * @param array $contentTypes An array of content-type that should be parsed for Surrogate information * (default: text/html, text/xml, application/xhtml+xml, and application/xml) */ - public function __construct(array $contentTypes = array('text/html', 'text/xml', 'application/xhtml+xml', 'application/xml')) + public function __construct(array $contentTypes = ['text/html', 'text/xml', 'application/xhtml+xml', 'application/xml']) { $this->contentTypes = $contentTypes; } @@ -90,7 +90,7 @@ public function needsParsing(Response $response) */ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) { - $subRequest = Request::create($uri, Request::METHOD_GET, array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all()); + $subRequest = Request::create($uri, Request::METHOD_GET, [], $cache->getRequest()->cookies->all(), [], $cache->getRequest()->server->all()); try { $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 69134c71a1..dc62990b40 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -85,7 +85,7 @@ public function process(Request $request, Response $response) $i = 1; while (isset($chunks[$i])) { - $options = array(); + $options = []; 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/HttpCache.php b/HttpCache/HttpCache.php index ebc5ba6868..daaa928fa3 100644 --- a/HttpCache/HttpCache.php +++ b/HttpCache/HttpCache.php @@ -32,8 +32,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface private $request; private $surrogate; private $surrogateCacheStrategy; - private $options = array(); - private $traces = array(); + private $options = []; + private $traces = []; /** * Constructor. @@ -70,24 +70,24 @@ class HttpCache implements HttpKernelInterface, TerminableInterface * This setting is overridden by the stale-if-error HTTP Cache-Control extension * (see RFC 5861). */ - public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = array()) + public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = []) { $this->store = $store; $this->kernel = $kernel; $this->surrogate = $surrogate; // needed in case there is a fatal error because the backend is too slow to respond - register_shutdown_function(array($this->store, 'cleanup')); + register_shutdown_function([$this->store, 'cleanup']); - $this->options = array_merge(array( + $this->options = array_merge([ 'debug' => false, 'default_ttl' => 0, - 'private_headers' => array('Authorization', 'Cookie'), + 'private_headers' => ['Authorization', 'Cookie'], 'allow_reload' => false, 'allow_revalidate' => false, 'stale_while_revalidate' => 2, 'stale_if_error' => 60, - ), $options); + ], $options); } /** @@ -117,7 +117,7 @@ public function getTraces() */ public function getLog() { - $log = array(); + $log = []; foreach ($this->traces as $request => $traces) { $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); } @@ -164,7 +164,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ { // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->traces = array(); + $this->traces = []; // Keep a clone of the original request for surrogates so they can access it. // We must clone here to get a separate instance because the application will modify the request during // the application flow (we know it always does because we do ourselves by setting REMOTE_ADDR to 127.0.0.1 @@ -175,7 +175,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ } } - $this->traces[$this->getTraceKey($request)] = array(); + $this->traces[$this->getTraceKey($request)] = []; if (!$request->isMethodSafe(false)) { $response = $this->invalidate($request, $catch); @@ -260,9 +260,9 @@ protected function invalidate(Request $request, $catch = false) $this->store->invalidate($request); // As per the RFC, invalidate Location and Content-Location URLs if present - foreach (array('Location', 'Content-Location') as $header) { + foreach (['Location', 'Content-Location'] as $header) { if ($uri = $response->headers->get($header)) { - $subRequest = Request::create($uri, 'get', array(), array(), array(), $request->server->all()); + $subRequest = Request::create($uri, 'get', [], [], [], $request->server->all()); $this->store->invalidate($subRequest); } @@ -357,7 +357,7 @@ protected function validate(Request $request, Response $entry, $catch = false) // Add our cached etag validator to the environment. // We keep the etags from the client to handle the case when the client // has a different private valid entry which is not cached here. - $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array(); + $cachedEtags = $entry->getEtag() ? [$entry->getEtag()] : []; $requestEtags = $request->getETags(); if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) { $subRequest->headers->set('if_none_match', implode(', ', $etags)); @@ -377,7 +377,7 @@ protected function validate(Request $request, Response $entry, $catch = false) $entry = clone $entry; $entry->headers->remove('Date'); - foreach (array('Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified') as $name) { + foreach (['Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified'] as $name) { if ($response->headers->has($name)) { $entry->headers->set($name, $response->headers->get($name)); } @@ -448,7 +448,7 @@ protected function forward(Request $request, $catch = false, Response $entry = n $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(), array(500, 502, 503, 504))) { + if (null !== $entry && \in_array($response->getStatusCode(), [500, 502, 503, 504])) { if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { $age = $this->options['stale_if_error']; } diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 672cc893fe..168e9564b0 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -30,8 +30,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface { private $cacheable = true; private $embeddedResponses = 0; - private $ttls = array(); - private $maxAges = array(); + private $ttls = []; + private $maxAges = []; private $isNotCacheableResponseEmbedded = false; /** diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 58df176019..eaaa230b50 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -70,7 +70,7 @@ public function process(Request $request, Response $response) $i = 1; while (isset($chunks[$i])) { - $options = array(); + $options = []; 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 990091d065..ffd4f01aea 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -40,7 +40,7 @@ public function __construct($root) throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); - $this->locks = array(); + $this->locks = []; } /** @@ -54,7 +54,7 @@ public function cleanup() fclose($lock); } - $this->locks = array(); + $this->locks = []; } /** @@ -192,11 +192,11 @@ public function write(Request $request, Response $response) } // read existing cache entries, remove non-varying, and add this one to the list - $entries = array(); + $entries = []; $vary = $response->headers->get('vary'); foreach ($this->getMetadata($key) as $entry) { if (!isset($entry[1]['vary'][0])) { - $entry[1]['vary'] = array(''); + $entry[1]['vary'] = ['']; } if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { @@ -207,7 +207,7 @@ public function write(Request $request, Response $response) $headers = $this->persistResponse($response); unset($headers['age']); - array_unshift($entries, array($storedEnv, $headers)); + array_unshift($entries, [$storedEnv, $headers]); if (false === $this->save($key, serialize($entries))) { throw new \RuntimeException('Unable to store the metadata.'); @@ -236,13 +236,13 @@ public function invalidate(Request $request) $modified = false; $key = $this->getCacheKey($request); - $entries = array(); + $entries = []; foreach ($this->getMetadata($key) as $entry) { $response = $this->restoreResponse($entry[1]); if ($response->isFresh()) { $response->expire(); $modified = true; - $entries[] = array($entry[0], $this->persistResponse($response)); + $entries[] = [$entry[0], $this->persistResponse($response)]; } else { $entries[] = $entry; } @@ -293,7 +293,7 @@ private function requestsMatch($vary, $env1, $env2) private function getMetadata($key) { if (!$entries = $this->load($key)) { - return array(); + return []; } return unserialize($entries); @@ -464,7 +464,7 @@ private function persistRequest(Request $request) private function persistResponse(Response $response) { $headers = $response->headers->all(); - $headers['X-Status'] = array($response->getStatusCode()); + $headers['X-Status'] = [$response->getStatusCode()]; return $headers; } @@ -483,7 +483,7 @@ private function restoreResponse($headers, $body = null) unset($headers['X-Status']); if (null !== $body) { - $headers['X-Body-File'] = array($body); + $headers['X-Body-File'] = [$body]; } return new Response($body, $status, $headers); diff --git a/HttpCache/SubRequestHandler.php b/HttpCache/SubRequestHandler.php index 9649072c16..a701b23546 100644 --- a/HttpCache/SubRequestHandler.php +++ b/HttpCache/SubRequestHandler.php @@ -33,22 +33,22 @@ public static function handle(HttpKernelInterface $kernel, Request $request, $ty $trustedHeaderSet = Request::getTrustedHeaderSet(); if (\method_exists(Request::class, 'getTrustedHeaderName')) { Request::setTrustedProxies($trustedProxies, -1); - $trustedHeaders = array( + $trustedHeaders = [ Request::HEADER_FORWARDED => Request::getTrustedHeaderName(Request::HEADER_FORWARDED, false), Request::HEADER_X_FORWARDED_FOR => Request::getTrustedHeaderName(Request::HEADER_X_FORWARDED_FOR, false), Request::HEADER_X_FORWARDED_HOST => Request::getTrustedHeaderName(Request::HEADER_X_FORWARDED_HOST, false), Request::HEADER_X_FORWARDED_PROTO => Request::getTrustedHeaderName(Request::HEADER_X_FORWARDED_PROTO, false), Request::HEADER_X_FORWARDED_PORT => Request::getTrustedHeaderName(Request::HEADER_X_FORWARDED_PORT, false), - ); + ]; Request::setTrustedProxies($trustedProxies, $trustedHeaderSet); } else { - $trustedHeaders = array( + $trustedHeaders = [ Request::HEADER_FORWARDED => 'FORWARDED', Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', - ); + ]; } // remove untrusted values @@ -63,8 +63,8 @@ public static function handle(HttpKernelInterface $kernel, Request $request, $ty } // compute trusted values, taking any trusted proxies into account - $trustedIps = array(); - $trustedValues = array(); + $trustedIps = []; + $trustedValues = []; foreach (array_reverse($request->getClientIps()) as $ip) { $trustedIps[] = $ip; $trustedValues[] = sprintf('for="%s"', $ip); @@ -95,7 +95,7 @@ public static function handle(HttpKernelInterface $kernel, Request $request, $ty // ensure 127.0.0.1 is set as trusted proxy if (!IpUtils::checkIp('127.0.0.1', $trustedProxies)) { - Request::setTrustedProxies(array_merge($trustedProxies, array('127.0.0.1')), Request::getTrustedHeaderSet()); + Request::setTrustedProxies(array_merge($trustedProxies, ['127.0.0.1']), Request::getTrustedHeaderSet()); } try { diff --git a/HttpKernel.php b/HttpKernel.php index f34d9b3225..1e19923eb7 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -273,7 +273,7 @@ private function varToString($var) } if (\is_array($var)) { - $a = array(); + $a = []; foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); } diff --git a/Kernel.php b/Kernel.php index bb546d3c51..66a3fba2e1 100644 --- a/Kernel.php +++ b/Kernel.php @@ -50,7 +50,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl /** * @var BundleInterface[] */ - protected $bundles = array(); + protected $bundles = []; protected $bundleMap; protected $container; @@ -271,7 +271,7 @@ public function locateResource($name, $dir = null, $first = true) $overridePath = substr($path, 9); $resourceBundle = null; $bundles = $this->getBundle($bundleName, false, true); - $files = array(); + $files = []; foreach ($bundles as $bundle) { if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) { @@ -395,7 +395,7 @@ public function loadClassCache($name = 'classes', $extension = '.php') @trigger_error(__METHOD__.'() is deprecated since Symfony 3.3, to be removed in 4.0.', E_USER_DEPRECATED); } - $this->loadClassCache = array($name, $extension); + $this->loadClassCache = [$name, $extension]; } /** @@ -481,9 +481,9 @@ protected function doLoadClassCache($name, $extension) protected function initializeBundles() { // init bundles - $this->bundles = array(); - $topMostBundles = array(); - $directChildren = array(); + $this->bundles = []; + $topMostBundles = []; + $directChildren = []; foreach ($this->registerBundles() as $bundle) { $name = $bundle->getName(); @@ -515,10 +515,10 @@ protected function initializeBundles() } // inheritance - $this->bundleMap = array(); + $this->bundleMap = []; foreach ($topMostBundles as $name => $bundle) { - $bundleMap = array($bundle); - $hierarchy = array($name); + $bundleMap = [$bundle]; + $hierarchy = [$name]; while (isset($directChildren[$name])) { $name = $directChildren[$name]; @@ -598,7 +598,7 @@ protected function initializeContainer() } if ($this->debug) { - $collectedLogs = array(); + $collectedLogs = []; $previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL'); $previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { @@ -620,14 +620,14 @@ protected function initializeContainer() } } - $collectedLogs[$message] = array( + $collectedLogs[$message] = [ 'type' => $type, 'message' => $message, 'file' => $file, 'line' => $line, 'trace' => $backtrace, 'count' => 1, - ); + ]; }); } @@ -664,7 +664,7 @@ protected function initializeContainer() // Because concurrent requests might still be using them, // old container files are not removed immediately, // but on a next dump of the container. - static $legacyContainers = array(); + static $legacyContainers = []; $oldContainerDir = \dirname($oldContainer->getFileName()); $legacyContainers[$oldContainerDir.'.legacy'] = true; foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) { @@ -688,20 +688,20 @@ protected function initializeContainer() */ protected function getKernelParameters() { - $bundles = array(); - $bundlesMetadata = array(); + $bundles = []; + $bundlesMetadata = []; foreach ($this->bundles as $name => $bundle) { $bundles[$name] = \get_class($bundle); - $bundlesMetadata[$name] = array( + $bundlesMetadata[$name] = [ 'parent' => $bundle->getParent(), 'path' => $bundle->getPath(), 'namespace' => $bundle->getNamespace(), - ); + ]; } return array_merge( - array( + [ 'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir, 'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(), 'kernel.environment' => $this->environment, @@ -713,7 +713,7 @@ protected function getKernelParameters() 'kernel.bundles_metadata' => $bundlesMetadata, 'kernel.charset' => $this->getCharset(), 'kernel.container_class' => $this->getContainerClass(), - ), + ], $this->getEnvParameters(false) ); } @@ -733,7 +733,7 @@ protected function getEnvParameters() @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 = array(); + $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); @@ -753,7 +753,7 @@ protected function getEnvParameters() */ protected function buildContainer() { - foreach (array('cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) { + 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)); @@ -782,7 +782,7 @@ protected function buildContainer() */ protected function prepareContainer(ContainerBuilder $container) { - $extensions = array(); + $extensions = []; foreach ($this->bundles as $bundle) { if ($extension = $bundle->getContainerExtension()) { $container->registerExtension($extension); @@ -844,7 +844,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container $dumper->setProxyDumper(new ProxyDumper()); } - $content = $dumper->dump(array( + $content = $dumper->dump([ 'class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), @@ -852,7 +852,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container 'debug' => $this->debug, 'inline_class_loader_parameter' => \PHP_VERSION_ID >= 70000 && !$this->loadClassCache && !class_exists(ClassCollectionLoader::class, false) ? 'container.dumper.inline_class_loader' : null, 'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(), - )); + ]); $rootCode = array_pop($content); $dir = \dirname($cache->getPath()).'/'; @@ -878,7 +878,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container protected function getContainerLoader(ContainerInterface $container) { $locator = new FileLocator($this); - $resolver = new LoaderResolver(array( + $resolver = new LoaderResolver([ new XmlFileLoader($container, $locator), new YamlFileLoader($container, $locator), new IniFileLoader($container, $locator), @@ -886,7 +886,7 @@ protected function getContainerLoader(ContainerInterface $container) new GlobFileLoader($container, $locator), new DirectoryLoader($container, $locator), new ClosureLoader($container), - )); + ]); return new DelegatingLoader($resolver); } @@ -930,8 +930,8 @@ public static function stripComments($source) } // replace multiple new lines with a single newline - $rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]); - } elseif (\in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + $rawChunk .= preg_replace(['/\n{2,}/S'], "\n", $token[1]); + } elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { $ignoreSpace = true; } else { $rawChunk .= $token[1]; @@ -956,13 +956,13 @@ public static function stripComments($source) public function serialize() { - return serialize(array($this->environment, $this->debug)); + return serialize([$this->environment, $this->debug]); } public function unserialize($data) { if (\PHP_VERSION_ID >= 70000) { - list($environment, $debug) = unserialize($data, array('allowed_classes' => false)); + list($environment, $debug) = unserialize($data, ['allowed_classes' => false]); } else { list($environment, $debug) = unserialize($data); } diff --git a/Log/Logger.php b/Log/Logger.php index ca54d22f75..6cfc759490 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -22,7 +22,7 @@ */ class Logger extends AbstractLogger { - private static $levels = array( + private static $levels = [ LogLevel::DEBUG => 0, LogLevel::INFO => 1, LogLevel::NOTICE => 2, @@ -31,7 +31,7 @@ class Logger extends AbstractLogger LogLevel::CRITICAL => 5, LogLevel::ALERT => 6, LogLevel::EMERGENCY => 7, - ); + ]; private $minLevelIndex; private $formatter; @@ -57,7 +57,7 @@ public function __construct($minLevel = null, $output = 'php://stderr', callable } $this->minLevelIndex = self::$levels[$minLevel]; - $this->formatter = $formatter ?: array($this, 'format'); + $this->formatter = $formatter ?: [$this, 'format']; if (false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); } @@ -66,7 +66,7 @@ public function __construct($minLevel = null, $output = 'php://stderr', callable /** * {@inheritdoc} */ - public function log($level, $message, array $context = array()) + public function log($level, $message, array $context = []) { if (!isset(self::$levels[$level])) { throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); @@ -90,7 +90,7 @@ public function log($level, $message, array $context = array()) private function format($level, $message, array $context) { if (false !== strpos($message, '{')) { - $replacements = array(); + $replacements = []; foreach ($context as $key => $val) { if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) { $replacements["{{$key}}"] = $val; diff --git a/Profiler/FileProfilerStorage.php b/Profiler/FileProfilerStorage.php index 8bb57cf30c..810e2fe6f2 100644 --- a/Profiler/FileProfilerStorage.php +++ b/Profiler/FileProfilerStorage.php @@ -54,13 +54,13 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null, $st $file = $this->getIndexFilename(); if (!file_exists($file)) { - return array(); + return []; } $file = fopen($file, 'r'); fseek($file, 0, SEEK_END); - $result = array(); + $result = []; while (\count($result) < $limit && $line = $this->readLineFromFile($file)) { $values = str_getcsv($line); list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values; @@ -78,7 +78,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null, $st continue; } - $result[$csvToken] = array( + $result[$csvToken] = [ 'token' => $csvToken, 'ip' => $csvIp, 'method' => $csvMethod, @@ -86,7 +86,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null, $st 'time' => $csvTime, 'parent' => $csvParent, 'status_code' => $csvStatusCode, - ); + ]; } fclose($file); @@ -151,7 +151,7 @@ public function write(Profile $profile) }, $profile->getChildren())); // Store profile - $data = array( + $data = [ 'token' => $profileToken, 'parent' => $parentToken, 'children' => $childrenToken, @@ -161,7 +161,7 @@ public function write(Profile $profile) 'url' => $profile->getUrl(), 'time' => $profile->getTime(), 'status_code' => $profile->getStatusCode(), - ); + ]; if (false === file_put_contents($file, serialize($data))) { return false; @@ -173,7 +173,7 @@ public function write(Profile $profile) return false; } - fputcsv($file, array( + fputcsv($file, [ $profile->getToken(), $profile->getIp(), $profile->getMethod(), @@ -181,7 +181,7 @@ public function write(Profile $profile) $profile->getTime(), $profile->getParentToken(), $profile->getStatusCode(), - )); + ]); fclose($file); } diff --git a/Profiler/Profile.php b/Profiler/Profile.php index 9216f09e2b..c4490bc7a6 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -25,7 +25,7 @@ class Profile /** * @var DataCollectorInterface[] */ - private $collectors = array(); + private $collectors = []; private $ip; private $method; @@ -41,7 +41,7 @@ class Profile /** * @var Profile[] */ - private $children = array(); + private $children = []; /** * @param string $token The token @@ -74,7 +74,7 @@ public function getToken() /** * Sets the parent token. */ - public function setParent(Profile $parent) + public function setParent(self $parent) { $this->parent = $parent; } @@ -204,7 +204,7 @@ public function getChildren() */ public function setChildren(array $children) { - $this->children = array(); + $this->children = []; foreach ($children as $child) { $this->addChild($child); } @@ -213,7 +213,7 @@ public function setChildren(array $children) /** * Adds the child token. */ - public function addChild(Profile $child) + public function addChild(self $child) { $this->children[] = $child; $child->setParent($this); @@ -254,7 +254,7 @@ public function getCollectors() */ public function setCollectors(array $collectors) { - $this->collectors = array(); + $this->collectors = []; foreach ($collectors as $collector) { $this->addCollector($collector); } @@ -282,6 +282,6 @@ public function hasCollector($name) public function __sleep() { - return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'); + return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode']; } } diff --git a/Profiler/Profiler.php b/Profiler/Profiler.php index f252da4766..edf6cb8330 100644 --- a/Profiler/Profiler.php +++ b/Profiler/Profiler.php @@ -30,7 +30,7 @@ class Profiler /** * @var DataCollectorInterface[] */ - private $collectors = array(); + private $collectors = []; private $logger; private $initiallyEnabled = true; @@ -103,7 +103,7 @@ public function saveProfile(Profile $profile) } if (!($ret = $this->storage->write($profile)) && null !== $this->logger) { - $this->logger->warning('Unable to store the profiler information.', array('configured_storage' => \get_class($this->storage))); + $this->logger->warning('Unable to store the profiler information.', ['configured_storage' => \get_class($this->storage)]); } return $ret; @@ -198,9 +198,9 @@ public function all() * * @param DataCollectorInterface[] $collectors An array of collectors */ - public function set(array $collectors = array()) + public function set(array $collectors = []) { - $this->collectors = array(); + $this->collectors = []; foreach ($collectors as $collector) { $this->add($collector); } diff --git a/Tests/CacheClearer/ChainCacheClearerTest.php b/Tests/CacheClearer/ChainCacheClearerTest.php index ec2ecff948..a7093dfc9d 100644 --- a/Tests/CacheClearer/ChainCacheClearerTest.php +++ b/Tests/CacheClearer/ChainCacheClearerTest.php @@ -35,7 +35,7 @@ public function testInjectClearersInConstructor() ->expects($this->once()) ->method('clear'); - $chainClearer = new ChainCacheClearer(array($clearer)); + $chainClearer = new ChainCacheClearer([$clearer]); $chainClearer->clear(self::$cacheDir); } diff --git a/Tests/CacheClearer/Psr6CacheClearerTest.php b/Tests/CacheClearer/Psr6CacheClearerTest.php index b3bed4e87f..297ede6a36 100644 --- a/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -24,7 +24,7 @@ public function testClearPoolsInjectedInConstructor() ->expects($this->once()) ->method('clear'); - (new Psr6CacheClearer(array('pool' => $pool)))->clear(''); + (new Psr6CacheClearer(['pool' => $pool]))->clear(''); } public function testClearPool() @@ -34,7 +34,7 @@ public function testClearPool() ->expects($this->once()) ->method('clear'); - (new Psr6CacheClearer(array('pool' => $pool)))->clearPool('pool'); + (new Psr6CacheClearer(['pool' => $pool]))->clearPool('pool'); } /** @@ -62,7 +62,7 @@ public function testClearPoolsInjectedByAdder() ->expects($this->once()) ->method('clear'); - $clearer = new Psr6CacheClearer(array('pool1' => $pool1)); + $clearer = new Psr6CacheClearer(['pool1' => $pool1]); $clearer->addPool($pool2); $clearer->clear(''); } diff --git a/Tests/CacheWarmer/CacheWarmerAggregateTest.php b/Tests/CacheWarmer/CacheWarmerAggregateTest.php index ba159124c9..de15c6f30c 100644 --- a/Tests/CacheWarmer/CacheWarmerAggregateTest.php +++ b/Tests/CacheWarmer/CacheWarmerAggregateTest.php @@ -34,7 +34,7 @@ public function testInjectWarmersUsingConstructor() $warmer ->expects($this->once()) ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(array($warmer)); + $aggregate = new CacheWarmerAggregate([$warmer]); $aggregate->warmUp(self::$cacheDir); } @@ -62,7 +62,7 @@ public function testInjectWarmersUsingSetWarmers() ->expects($this->once()) ->method('warmUp'); $aggregate = new CacheWarmerAggregate(); - $aggregate->setWarmers(array($warmer)); + $aggregate->setWarmers([$warmer]); $aggregate->warmUp(self::$cacheDir); } @@ -76,7 +76,7 @@ public function testWarmupDoesCallWarmupOnOptionalWarmersWhenEnableOptionalWarme ->expects($this->once()) ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(array($warmer)); + $aggregate = new CacheWarmerAggregate([$warmer]); $aggregate->enableOptionalWarmers(); $aggregate->warmUp(self::$cacheDir); } @@ -92,7 +92,7 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa ->expects($this->never()) ->method('warmUp'); - $aggregate = new CacheWarmerAggregate(array($warmer)); + $aggregate = new CacheWarmerAggregate([$warmer]); $aggregate->warmUp(self::$cacheDir); } diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index 5af2730868..ac1c55ad54 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -70,7 +70,7 @@ public function testFilterResponseConvertsCookies() $response->headers->setCookie($cookie2 = new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true)); $domResponse = $m->invoke($client, $response); $this->assertSame((string) $cookie1, $domResponse->getHeader('Set-Cookie')); - $this->assertSame(array((string) $cookie1, (string) $cookie2), $domResponse->getHeader('Set-Cookie', false)); + $this->assertSame([(string) $cookie1, (string) $cookie2], $domResponse->getHeader('Set-Cookie', false)); } public function testFilterResponseSupportsStreamedResponses() @@ -99,14 +99,14 @@ public function testUploadedFile() $kernel = new TestHttpKernel(); $client = new Client($kernel); - $files = array( - array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => 1, 'error' => UPLOAD_ERR_OK), + $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), - ); + ]; $file = null; foreach ($files as $file) { - $client->request('POST', '/', array(), array('foo' => $file)); + $client->request('POST', '/', [], ['foo' => $file]); $files = $client->getRequest()->files->all(); @@ -131,9 +131,9 @@ public function testUploadedFileWhenNoFileSelected() $kernel = new TestHttpKernel(); $client = new Client($kernel); - $file = array('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', '/', array(), array('foo' => $file)); + $client->request('POST', '/', [], ['foo' => $file]); $files = $client->getRequest()->files->all(); @@ -150,8 +150,8 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true)) - ->setMethods(array('getSize')) + ->setConstructorArgs([$source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true]) + ->setMethods(['getSize']) ->getMock() ; @@ -160,7 +160,7 @@ public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() ->will($this->returnValue(INF)) ; - $client->request('POST', '/', array(), array($file)); + $client->request('POST', '/', [], [$file]); $files = $client->getRequest()->files->all(); diff --git a/Tests/Config/EnvParametersResourceTest.php b/Tests/Config/EnvParametersResourceTest.php index 986e05d8b8..a1bf529572 100644 --- a/Tests/Config/EnvParametersResourceTest.php +++ b/Tests/Config/EnvParametersResourceTest.php @@ -25,10 +25,10 @@ class EnvParametersResourceTest extends TestCase protected function setUp() { - $this->initialEnv = array( + $this->initialEnv = [ $this->prefix.'1' => 'foo', $this->prefix.'2' => 'bar', - ); + ]; foreach ($this->initialEnv as $key => $value) { $_SERVER[$key] = $value; @@ -49,7 +49,7 @@ protected function tearDown() public function testGetResource() { $this->assertSame( - array('prefix' => $this->prefix, 'variables' => $this->initialEnv), + ['prefix' => $this->prefix, 'variables' => $this->initialEnv], $this->resource->getResource(), '->getResource() returns the resource' ); @@ -58,7 +58,7 @@ public function testGetResource() public function testToString() { $this->assertSame( - serialize(array('prefix' => $this->prefix, 'variables' => $this->initialEnv)), + serialize(['prefix' => $this->prefix, 'variables' => $this->initialEnv]), (string) $this->resource ); } diff --git a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index f6a3689638..2c43e5b1ba 100644 --- a/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -21,86 +21,86 @@ class ServiceValueResolverTest extends TestCase { public function testDoNotSupportWhenControllerDoNotExists() { - $resolver = new ServiceValueResolver(new ServiceLocator(array())); + $resolver = new ServiceValueResolver(new ServiceLocator([])); $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); - $request = $this->requestWithAttributes(array('_controller' => 'my_controller')); + $request = $this->requestWithAttributes(['_controller' => 'my_controller']); $this->assertFalse($resolver->supports($request, $argument)); } public function testExistingController() { - $resolver = new ServiceValueResolver(new ServiceLocator(array( + $resolver = new ServiceValueResolver(new ServiceLocator([ 'App\\Controller\\Mine::method' => function () { - return new ServiceLocator(array( + return new ServiceLocator([ 'dummy' => function () { return new DummyService(); }, - )); + ]); }, - ))); + ])); - $request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::method')); + $request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::method']); $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); $this->assertTrue($resolver->supports($request, $argument)); - $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + $this->assertYieldEquals([new DummyService()], $resolver->resolve($request, $argument)); } public function testExistingControllerWithATrailingBackSlash() { - $resolver = new ServiceValueResolver(new ServiceLocator(array( + $resolver = new ServiceValueResolver(new ServiceLocator([ 'App\\Controller\\Mine::method' => function () { - return new ServiceLocator(array( + return new ServiceLocator([ 'dummy' => function () { return new DummyService(); }, - )); + ]); }, - ))); + ])); - $request = $this->requestWithAttributes(array('_controller' => '\\App\\Controller\\Mine::method')); + $request = $this->requestWithAttributes(['_controller' => '\\App\\Controller\\Mine::method']); $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); $this->assertTrue($resolver->supports($request, $argument)); - $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + $this->assertYieldEquals([new DummyService()], $resolver->resolve($request, $argument)); } public function testExistingControllerWithMethodNameStartUppercase() { - $resolver = new ServiceValueResolver(new ServiceLocator(array( + $resolver = new ServiceValueResolver(new ServiceLocator([ 'App\\Controller\\Mine::method' => function () { - return new ServiceLocator(array( + return new ServiceLocator([ 'dummy' => function () { return new DummyService(); }, - )); + ]); }, - ))); - $request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::Method')); + ])); + $request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::Method']); $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); $this->assertTrue($resolver->supports($request, $argument)); - $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + $this->assertYieldEquals([new DummyService()], $resolver->resolve($request, $argument)); } public function testControllerNameIsAnArray() { - $resolver = new ServiceValueResolver(new ServiceLocator(array( + $resolver = new ServiceValueResolver(new ServiceLocator([ 'App\\Controller\\Mine::method' => function () { - return new ServiceLocator(array( + return new ServiceLocator([ 'dummy' => function () { return new DummyService(); }, - )); + ]); }, - ))); + ])); - $request = $this->requestWithAttributes(array('_controller' => array('App\\Controller\\Mine', 'method'))); + $request = $this->requestWithAttributes(['_controller' => ['App\\Controller\\Mine', 'method']]); $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); $this->assertTrue($resolver->supports($request, $argument)); - $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + $this->assertYieldEquals([new DummyService()], $resolver->resolve($request, $argument)); } private function requestWithAttributes(array $attributes) @@ -116,7 +116,7 @@ private function requestWithAttributes(array $attributes) private function assertYieldEquals(array $expected, \Generator $generator) { - $args = array(); + $args = []; foreach ($generator as $arg) { $args[] = $arg; } diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index 729b90b2f6..8c900fb92c 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -40,33 +40,33 @@ public static function setUpBeforeClass() public function testDefaultState() { $this->assertEquals(self::$resolver, new ArgumentResolver()); - $this->assertNotEquals(self::$resolver, new ArgumentResolver(null, array(new RequestAttributeValueResolver()))); + $this->assertNotEquals(self::$resolver, new ArgumentResolver(null, [new RequestAttributeValueResolver()])); } public function testGetArguments() { $request = Request::create('/'); $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerWithFoo'); + $controller = [new self(), 'controllerWithFoo']; - $this->assertEquals(array('foo'), self::$resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); + $this->assertEquals(['foo'], self::$resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); } public function testGetArgumentsReturnsEmptyArrayWhenNoArguments() { $request = Request::create('/'); - $controller = array(new self(), 'controllerWithoutArguments'); + $controller = [new self(), 'controllerWithoutArguments']; - $this->assertEquals(array(), self::$resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); + $this->assertEquals([], self::$resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); } public function testGetArgumentsUsesDefaultValue() { $request = Request::create('/'); $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerWithFooAndDefaultBar'); + $controller = [new self(), 'controllerWithFooAndDefaultBar']; - $this->assertEquals(array('foo', null), self::$resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); + $this->assertEquals(['foo', null], self::$resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); } public function testGetArgumentsOverrideDefaultValueByRequestAttribute() @@ -74,9 +74,9 @@ public function testGetArgumentsOverrideDefaultValueByRequestAttribute() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', 'bar'); - $controller = array(new self(), 'controllerWithFooAndDefaultBar'); + $controller = [new self(), 'controllerWithFooAndDefaultBar']; - $this->assertEquals(array('foo', 'bar'), self::$resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); + $this->assertEquals(['foo', 'bar'], self::$resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); } public function testGetArgumentsFromClosure() @@ -85,7 +85,7 @@ public function testGetArgumentsFromClosure() $request->attributes->set('foo', 'foo'); $controller = function ($foo) {}; - $this->assertEquals(array('foo'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo'], self::$resolver->getArguments($request, $controller)); } public function testGetArgumentsUsesDefaultValueFromClosure() @@ -94,7 +94,7 @@ public function testGetArgumentsUsesDefaultValueFromClosure() $request->attributes->set('foo', 'foo'); $controller = function ($foo, $bar = 'bar') {}; - $this->assertEquals(array('foo', 'bar'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'bar'], self::$resolver->getArguments($request, $controller)); } public function testGetArgumentsFromInvokableObject() @@ -103,12 +103,12 @@ public function testGetArgumentsFromInvokableObject() $request->attributes->set('foo', 'foo'); $controller = new self(); - $this->assertEquals(array('foo', null), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', null], self::$resolver->getArguments($request, $controller)); // Test default bar overridden by request attribute $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'bar'], self::$resolver->getArguments($request, $controller)); } public function testGetArgumentsFromFunctionName() @@ -118,7 +118,7 @@ public function testGetArgumentsFromFunctionName() $request->attributes->set('foobar', 'foobar'); $controller = __NAMESPACE__.'\controller_function'; - $this->assertEquals(array('foo', 'foobar'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'foobar'], self::$resolver->getArguments($request, $controller)); } public function testGetArgumentsFailsOnUnresolvedValue() @@ -126,7 +126,7 @@ public function testGetArgumentsFailsOnUnresolvedValue() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('foobar', 'foobar'); - $controller = array(new self(), 'controllerWithFooBarFoobar'); + $controller = [new self(), 'controllerWithFooBarFoobar']; try { self::$resolver->getArguments($request, $controller); @@ -139,17 +139,17 @@ public function testGetArgumentsFailsOnUnresolvedValue() public function testGetArgumentsInjectsRequest() { $request = Request::create('/'); - $controller = array(new self(), 'controllerWithRequest'); + $controller = [new self(), 'controllerWithRequest']; - $this->assertEquals(array($request), self::$resolver->getArguments($request, $controller), '->getArguments() injects the request'); + $this->assertEquals([$request], self::$resolver->getArguments($request, $controller), '->getArguments() injects the request'); } public function testGetArgumentsInjectsExtendingRequest() { $request = ExtendingRequest::create('/'); - $controller = array(new self(), 'controllerWithExtendingRequest'); + $controller = [new self(), 'controllerWithExtendingRequest']; - $this->assertEquals(array($request), self::$resolver->getArguments($request, $controller), '->getArguments() injects the request when extended'); + $this->assertEquals([$request], self::$resolver->getArguments($request, $controller), '->getArguments() injects the request when extended'); } /** @@ -159,10 +159,10 @@ public function testGetVariadicArguments() { $request = Request::create('/'); $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', array('foo', 'bar')); - $controller = array(new VariadicController(), 'action'); + $request->attributes->set('bar', ['foo', 'bar']); + $controller = [new VariadicController(), 'action']; - $this->assertEquals(array('foo', 'foo', 'bar'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'foo', 'bar'], self::$resolver->getArguments($request, $controller)); } /** @@ -174,7 +174,7 @@ public function testGetVariadicArgumentsWithoutArrayInRequest() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', 'foo'); - $controller = array(new VariadicController(), 'action'); + $controller = [new VariadicController(), 'action']; self::$resolver->getArguments($request, $controller); } @@ -187,7 +187,7 @@ public function testGetArgumentWithoutArray() { $factory = new ArgumentMetadataFactory(); $valueResolver = $this->getMockBuilder(ArgumentValueResolverInterface::class)->getMock(); - $resolver = new ArgumentResolver($factory, array($valueResolver)); + $resolver = new ArgumentResolver($factory, [$valueResolver]); $valueResolver->expects($this->any())->method('supports')->willReturn(true); $valueResolver->expects($this->any())->method('resolve')->willReturn('foo'); @@ -195,7 +195,7 @@ public function testGetArgumentWithoutArray() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', 'foo'); - $controller = array($this, 'controllerWithFooAndDefaultBar'); + $controller = [$this, 'controllerWithFooAndDefaultBar']; $resolver->getArguments($request, $controller); } @@ -205,7 +205,7 @@ public function testGetArgumentWithoutArray() public function testIfExceptionIsThrownWhenMissingAnArgument() { $request = Request::create('/'); - $controller = array($this, 'controllerWithFoo'); + $controller = [$this, 'controllerWithFoo']; self::$resolver->getArguments($request, $controller); } @@ -219,9 +219,9 @@ public function testGetNullableArguments() $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', new \stdClass()); $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); + $controller = [new NullableController(), 'action']; - $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], self::$resolver->getArguments($request, $controller)); } /** @@ -231,9 +231,9 @@ public function testGetNullableArgumentsWithDefaults() { $request = Request::create('/'); $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); + $controller = [new NullableController(), 'action']; - $this->assertEquals(array(null, null, 'value', 'mandatory'), self::$resolver->getArguments($request, $controller)); + $this->assertEquals([null, null, 'value', 'mandatory'], self::$resolver->getArguments($request, $controller)); } public function testGetSessionArguments() @@ -241,9 +241,9 @@ public function testGetSessionArguments() $session = new Session(new MockArraySessionStorage()); $request = Request::create('/'); $request->setSession($session); - $controller = array($this, 'controllerWithSession'); + $controller = [$this, 'controllerWithSession']; - $this->assertEquals(array($session), self::$resolver->getArguments($request, $controller)); + $this->assertEquals([$session], self::$resolver->getArguments($request, $controller)); } public function testGetSessionArgumentsWithExtendedSession() @@ -251,9 +251,9 @@ public function testGetSessionArgumentsWithExtendedSession() $session = new ExtendingSession(new MockArraySessionStorage()); $request = Request::create('/'); $request->setSession($session); - $controller = array($this, 'controllerWithExtendingSession'); + $controller = [$this, 'controllerWithExtendingSession']; - $this->assertEquals(array($session), self::$resolver->getArguments($request, $controller)); + $this->assertEquals([$session], self::$resolver->getArguments($request, $controller)); } public function testGetSessionArgumentsWithInterface() @@ -261,9 +261,9 @@ public function testGetSessionArgumentsWithInterface() $session = $this->getMockBuilder(SessionInterface::class)->getMock(); $request = Request::create('/'); $request->setSession($session); - $controller = array($this, 'controllerWithSessionInterface'); + $controller = [$this, 'controllerWithSessionInterface']; - $this->assertEquals(array($session), self::$resolver->getArguments($request, $controller)); + $this->assertEquals([$session], self::$resolver->getArguments($request, $controller)); } /** @@ -274,7 +274,7 @@ public function testGetSessionMissMatchWithInterface() $session = $this->getMockBuilder(SessionInterface::class)->getMock(); $request = Request::create('/'); $request->setSession($session); - $controller = array($this, 'controllerWithExtendingSession'); + $controller = [$this, 'controllerWithExtendingSession']; self::$resolver->getArguments($request, $controller); } @@ -287,7 +287,7 @@ public function testGetSessionMissMatchWithImplementation() $session = new Session(new MockArraySessionStorage()); $request = Request::create('/'); $request->setSession($session); - $controller = array($this, 'controllerWithExtendingSession'); + $controller = [$this, 'controllerWithExtendingSession']; self::$resolver->getArguments($request, $controller); } @@ -298,7 +298,7 @@ public function testGetSessionMissMatchWithImplementation() public function testGetSessionMissMatchOnNull() { $request = Request::create('/'); - $controller = array($this, 'controllerWithExtendingSession'); + $controller = [$this, 'controllerWithExtendingSession']; self::$resolver->getArguments($request, $controller); } diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 82407f5601..3f130db065 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -105,11 +105,11 @@ public function testNonInstantiableController() $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); - $request->attributes->set('_controller', array(NonInstantiableController::class, 'action')); + $request->attributes->set('_controller', [NonInstantiableController::class, 'action']); $controller = $resolver->getController($request); - $this->assertSame(array(NonInstantiableController::class, 'action'), $controller); + $this->assertSame([NonInstantiableController::class, 'action'], $controller); } /** @@ -134,12 +134,12 @@ public function testNonConstructController() $container->expects($this->atLeastOnce()) ->method('getRemovedIds') ->with() - ->will($this->returnValue(array(ImpossibleConstructController::class => true))) + ->will($this->returnValue([ImpossibleConstructController::class => true])) ; $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); - $request->attributes->set('_controller', array(ImpossibleConstructController::class, 'action')); + $request->attributes->set('_controller', [ImpossibleConstructController::class, 'action']); if (\PHP_VERSION_ID < 70100) { ErrorHandler::register(); @@ -172,11 +172,11 @@ public function testNonInstantiableControllerWithCorrespondingService() $resolver = $this->createControllerResolver(null, $container); $request = Request::create('/'); - $request->attributes->set('_controller', array(NonInstantiableController::class, 'action')); + $request->attributes->set('_controller', [NonInstantiableController::class, 'action']); $controller = $resolver->getController($request); - $this->assertSame(array($service, 'action'), $controller); + $this->assertSame([$service, 'action'], $controller); } /** @@ -195,7 +195,7 @@ public function testExceptionWhenUsingRemovedControllerService() $container->expects($this->atLeastOnce()) ->method('getRemovedIds') ->with() - ->will($this->returnValue(array('app.my_controller' => true))) + ->will($this->returnValue(['app.my_controller' => true])) ; $resolver = $this->createControllerResolver(null, $container); @@ -251,16 +251,16 @@ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionN public function getUndefinedControllers() { - return array( - array('foo', \LogicException::class, '/Controller not found: service "foo" does not exist\./'), - array('oof::bar', \InvalidArgumentException::class, '/Class "oof" does not exist\./'), - array('stdClass', \LogicException::class, '/Controller not found: service "stdClass" does not exist\./'), - array( + return [ + ['foo', \LogicException::class, '/Controller not found: service "foo" does not exist\./'], + ['oof::bar', \InvalidArgumentException::class, '/Class "oof" does not exist\./'], + ['stdClass', \LogicException::class, '/Controller not found: service "stdClass" does not exist\./'], + [ 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar', \InvalidArgumentException::class, '/.?[cC]ontroller(.*?) for URI "\/" is not callable\.( Expected method(.*) Available methods)?/', - ), - ); + ], + ]; } protected function createControllerResolver(LoggerInterface $logger = null, ContainerInterface $container = null) diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index 87f598d16d..728382ad2b 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -55,9 +55,9 @@ public function testGetControllerWithObjectAndMethod() $resolver = $this->createControllerResolver(); $request = Request::create('/'); - $request->attributes->set('_controller', array($this, 'controllerMethod1')); + $request->attributes->set('_controller', [$this, 'controllerMethod1']); $controller = $resolver->getController($request); - $this->assertSame(array($this, 'controllerMethod1'), $controller); + $this->assertSame([$this, 'controllerMethod1'], $controller); } public function testGetControllerWithClassAndMethod() @@ -65,9 +65,9 @@ public function testGetControllerWithClassAndMethod() $resolver = $this->createControllerResolver(); $request = Request::create('/'); - $request->attributes->set('_controller', array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4')); + $request->attributes->set('_controller', ['Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4']); $controller = $resolver->getController($request); - $this->assertSame(array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4'), $controller); + $this->assertSame(['Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest', 'controllerMethod4'], $controller); } public function testGetControllerWithObjectAndMethodAsString() @@ -132,16 +132,16 @@ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionN public function getUndefinedControllers() { - return array( - array(1, 'InvalidArgumentException', 'Unable to find controller "1".'), - array('foo', 'InvalidArgumentException', 'Unable to find controller "foo".'), - array('oof::bar', 'InvalidArgumentException', 'Class "oof" does not exist.'), - array('stdClass', 'InvalidArgumentException', 'Unable to find controller "stdClass".'), - array('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"?'), - array('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'), - array('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'), - array('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"'), - ); + return [ + [1, 'InvalidArgumentException', 'Unable to find controller "1".'], + ['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"'], + ]; } /** @@ -152,49 +152,49 @@ public function testGetArguments() $resolver = $this->createControllerResolver(); $request = Request::create('/'); - $controller = array(new self(), 'testGetArguments'); - $this->assertEquals(array(), $resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); + $controller = [new self(), 'testGetArguments']; + $this->assertEquals([], $resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments'); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerMethod1'); - $this->assertEquals(array('foo'), $resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); + $controller = [new self(), 'controllerMethod1']; + $this->assertEquals(['foo'], $resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method'); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); - $controller = array(new self(), 'controllerMethod2'); - $this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); + $controller = [new self(), 'controllerMethod2']; + $this->assertEquals(['foo', null], $resolver->getArguments($request, $controller), '->getArguments() uses default values if present'); $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); + $this->assertEquals(['foo', 'bar'], $resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes'); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $controller = function ($foo) {}; - $this->assertEquals(array('foo'), $resolver->getArguments($request, $controller)); + $this->assertEquals(['foo'], $resolver->getArguments($request, $controller)); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $controller = function ($foo, $bar = 'bar') {}; - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'bar'], $resolver->getArguments($request, $controller)); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $controller = new self(); - $this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', null], $resolver->getArguments($request, $controller)); $request->attributes->set('bar', 'bar'); - $this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'bar'], $resolver->getArguments($request, $controller)); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('foobar', 'foobar'); $controller = 'Symfony\Component\HttpKernel\Tests\Controller\some_controller_function'; - $this->assertEquals(array('foo', 'foobar'), $resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', 'foobar'], $resolver->getArguments($request, $controller)); $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('foobar', 'foobar'); - $controller = array(new self(), 'controllerMethod3'); + $controller = [new self(), 'controllerMethod3']; try { $resolver->getArguments($request, $controller); @@ -204,8 +204,8 @@ public function testGetArguments() } $request = Request::create('/'); - $controller = array(new self(), 'controllerMethod5'); - $this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request'); + $controller = [new self(), 'controllerMethod5']; + $this->assertEquals([$request], $resolver->getArguments($request, $controller), '->getArguments() injects the request'); } /** @@ -218,14 +218,14 @@ public function testGetVariadicArguments() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); - $request->attributes->set('bar', array('foo', 'bar')); - $controller = array(new VariadicController(), 'action'); - $this->assertEquals(array('foo', 'foo', 'bar'), $resolver->getArguments($request, $controller)); + $request->attributes->set('bar', ['foo', 'bar']); + $controller = [new VariadicController(), 'action']; + $this->assertEquals(['foo', 'foo', 'bar'], $resolver->getArguments($request, $controller)); } public function testCreateControllerCanReturnAnyCallable() { - $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(array('createController'))->getMock(); + $mock = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolver')->setMethods(['createController'])->getMock(); $mock->expects($this->once())->method('createController')->will($this->returnValue('Symfony\Component\HttpKernel\Tests\Controller\some_controller_function')); $request = Request::create('/'); @@ -242,7 +242,7 @@ public function testIfExceptionIsThrownWhenMissingAnArgument() $resolver = new ControllerResolver(); $request = Request::create('/'); - $controller = array($this, 'controllerMethod1'); + $controller = [$this, 'controllerMethod1']; $resolver->getArguments($request, $controller); } @@ -259,8 +259,8 @@ public function testGetNullableArguments() $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', new \stdClass()); $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); - $this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), $resolver->getArguments($request, $controller)); + $controller = [new NullableController(), 'action']; + $this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], $resolver->getArguments($request, $controller)); } /** @@ -273,8 +273,8 @@ public function testGetNullableArgumentsWithDefaults() $request = Request::create('/'); $request->attributes->set('mandatory', 'mandatory'); - $controller = array(new NullableController(), 'action'); - $this->assertEquals(array(null, null, 'value', 'mandatory'), $resolver->getArguments($request, $controller)); + $controller = [new NullableController(), 'action']; + $this->assertEquals([null, null, 'value', 'mandatory'], $resolver->getArguments($request, $controller)); } protected function createControllerResolver(LoggerInterface $logger = null) diff --git a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index bf0db5ad56..1c0c4648a0 100644 --- a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -33,55 +33,55 @@ protected function setUp() public function testSignature1() { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature1')); + $arguments = $this->factory->createArgumentMetadata([$this, 'signature1']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('foo', self::class, false, false, null), new ArgumentMetadata('bar', 'array', false, false, null), new ArgumentMetadata('baz', 'callable', false, false, null), - ), $arguments); + ], $arguments); } public function testSignature2() { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature2')); + $arguments = $this->factory->createArgumentMetadata([$this, 'signature2']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('foo', self::class, false, true, null, true), new ArgumentMetadata('bar', __NAMESPACE__.'\FakeClassThatDoesNotExist', false, true, null, true), new ArgumentMetadata('baz', 'Fake\ImportedAndFake', false, true, null, true), - ), $arguments); + ], $arguments); } public function testSignature3() { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature3')); + $arguments = $this->factory->createArgumentMetadata([$this, 'signature3']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('bar', __NAMESPACE__.'\FakeClassThatDoesNotExist', false, false, null), new ArgumentMetadata('baz', 'Fake\ImportedAndFake', false, false, null), - ), $arguments); + ], $arguments); } public function testSignature4() { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature4')); + $arguments = $this->factory->createArgumentMetadata([$this, 'signature4']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('foo', null, false, true, 'default'), new ArgumentMetadata('bar', null, false, true, 500), - new ArgumentMetadata('baz', null, false, true, array()), - ), $arguments); + new ArgumentMetadata('baz', null, false, true, []), + ], $arguments); } public function testSignature5() { - $arguments = $this->factory->createArgumentMetadata(array($this, 'signature5')); + $arguments = $this->factory->createArgumentMetadata([$this, 'signature5']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('foo', 'array', false, true, null, true), new ArgumentMetadata('bar', null, false, false, null), - ), $arguments); + ], $arguments); } /** @@ -89,12 +89,12 @@ public function testSignature5() */ public function testVariadicSignature() { - $arguments = $this->factory->createArgumentMetadata(array(new VariadicController(), 'action')); + $arguments = $this->factory->createArgumentMetadata([new VariadicController(), 'action']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('foo', null, false, false, null), new ArgumentMetadata('bar', null, true, false, null), - ), $arguments); + ], $arguments); } /** @@ -102,13 +102,13 @@ public function testVariadicSignature() */ public function testBasicTypesSignature() { - $arguments = $this->factory->createArgumentMetadata(array(new BasicTypesController(), 'action')); + $arguments = $this->factory->createArgumentMetadata([new BasicTypesController(), 'action']); - $this->assertEquals(array( + $this->assertEquals([ new ArgumentMetadata('foo', 'string', false, false, null), new ArgumentMetadata('bar', 'int', false, false, null), new ArgumentMetadata('baz', 'float', false, false, null), - ), $arguments); + ], $arguments); } /** @@ -116,14 +116,14 @@ public function testBasicTypesSignature() */ public function testNullableTypesSignature() { - $arguments = $this->factory->createArgumentMetadata(array(new NullableController(), 'action')); + $arguments = $this->factory->createArgumentMetadata([new NullableController(), 'action']); - $this->assertEquals(array( + $this->assertEquals([ 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), - ), $arguments); + ], $arguments); } private function signature1(self $foo, array $bar, callable $baz) @@ -138,7 +138,7 @@ private function signature3(FakeClassThatDoesNotExist $bar, ImportedAndFake $baz { } - private function signature4($foo = 'default', $bar = 500, $baz = array()) + private function signature4($foo = 'default', $bar = 500, $baz = []) { } diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index 3f51b13ce9..a858eabe15 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -57,7 +57,7 @@ public function registerBundles() public function getBundles() { - return array(); + return []; } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/Tests/DataCollector/DataCollectorTest.php b/Tests/DataCollector/DataCollectorTest.php index 54fd39e0d8..ae79a3c93c 100644 --- a/Tests/DataCollector/DataCollectorTest.php +++ b/Tests/DataCollector/DataCollectorTest.php @@ -30,7 +30,7 @@ public function testCloneVarStringWithScheme() public function testCloneVarExistingFilePath() { - $c = new CloneVarDataCollector(array($filePath = tempnam(sys_get_temp_dir(), 'clone_var_data_collector_'))); + $c = new CloneVarDataCollector([$filePath = tempnam(sys_get_temp_dir(), 'clone_var_data_collector_')]); $c->collect(new Request(), new Response()); $this->assertSame($filePath, $c->getData()[0]); diff --git a/Tests/DataCollector/DumpDataCollectorTest.php b/Tests/DataCollector/DumpDataCollectorTest.php index 341ddc6d8d..ebe50e378b 100644 --- a/Tests/DataCollector/DumpDataCollectorTest.php +++ b/Tests/DataCollector/DumpDataCollectorTest.php @@ -25,7 +25,7 @@ class DumpDataCollectorTest extends TestCase { public function testDump() { - $data = new Data(array(array(123))); + $data = new Data([[123]]); $collector = new DumpDataCollector(); @@ -40,15 +40,15 @@ public function testDump() $dump[0]['data'] = preg_replace('/^.*?
 "
123\n
\n", 'name' => 'DumpDataCollectorTest.php', 'file' => __FILE__, 'line' => $line, 'fileExcerpt' => false, - ), - ); + ], + ]; $this->assertEquals($xDump, $dump); $this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize()); @@ -58,7 +58,7 @@ public function testDump() public function testCollectDefault() { - $data = new Data(array(array(123))); + $data = new Data([[123]]); $collector = new DumpDataCollector(); @@ -76,7 +76,7 @@ public function testCollectDefault() public function testCollectHtml() { - $data = new Data(array(array(123))); + $data = new Data([[123]]); $collector = new DumpDataCollector(null, 'test://%f:%l'); @@ -104,7 +104,7 @@ public function testCollectHtml() public function testFlush() { - $data = new Data(array(array(456))); + $data = new Data([[456]]); $collector = new DumpDataCollector(); $collector->dump($data); $line = __LINE__ - 1; @@ -117,7 +117,7 @@ public function testFlush() public function testFlushNothingWhenDataDumperIsProvided() { - $data = new Data(array(array(456))); + $data = new Data([[456]]); $dumper = new CliDumper('php://output'); $collector = new DumpDataCollector(null, null, null, null, $dumper); diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index 3dec3bd7f8..90151ae44a 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -21,24 +21,24 @@ public function testCollectWithUnexpectedFormat() { $logger = $this ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') - ->setMethods(array('countErrors', 'getLogs', 'clear')) + ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('countErrors')->will($this->returnValue('foo')); - $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue(array())); + $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue([])); $c = new LoggerDataCollector($logger, __DIR__.'/'); $c->lateCollect(); $compilerLogs = $c->getCompilerLogs()->getValue('message'); - $this->assertSame(array( - array('message' => 'Removed service "Psr\Container\ContainerInterface"; reason: private alias.'), - array('message' => 'Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias.'), - ), $compilerLogs['Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass']); + $this->assertSame([ + ['message' => 'Removed service "Psr\Container\ContainerInterface"; reason: private alias.'], + ['message' => 'Removed service "Symfony\Component\DependencyInjection\ContainerInterface"; reason: private alias.'], + ], $compilerLogs['Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass']); - $this->assertSame(array( - array('message' => 'Some custom logging message'), - array('message' => 'With ending :'), - ), $compilerLogs['Unknown Compiler Pass']); + $this->assertSame([ + ['message' => 'Some custom logging message'], + ['message' => 'With ending :'], + ], $compilerLogs['Unknown Compiler Pass']); } /** @@ -48,7 +48,7 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount { $logger = $this ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') - ->setMethods(array('countErrors', 'getLogs', 'clear')) + ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb)); $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs)); @@ -62,7 +62,7 @@ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount $logs = array_map(function ($v) { if (isset($v['context']['exception'])) { $e = &$v['context']['exception']; - $e = isset($e["\0*\0message"]) ? array($e["\0*\0message"], $e["\0*\0severity"]) : array($e["\0Symfony\Component\Debug\Exception\SilencedErrorContext\0severity"]); + $e = isset($e["\0*\0message"]) ? [$e["\0*\0message"], $e["\0*\0severity"]] : [$e["\0Symfony\Component\Debug\Exception\SilencedErrorContext\0severity"]]; } return $v; @@ -80,7 +80,7 @@ public function testReset() { $logger = $this ->getMockBuilder('Symfony\Component\HttpKernel\Log\DebugLoggerInterface') - ->setMethods(array('countErrors', 'getLogs', 'clear')) + ->setMethods(['countErrors', 'getLogs', 'clear']) ->getMock(); $logger->expects($this->once())->method('clear'); @@ -90,55 +90,55 @@ public function testReset() public function getCollectTestData() { - yield 'simple log' => array( + yield 'simple log' => [ 1, - array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo', 'context' => array(), 'priority' => 100, 'priorityName' => 'DEBUG')), + [['message' => 'foo', 'context' => [], 'priority' => 100, 'priorityName' => 'DEBUG']], + [['message' => 'foo', 'context' => [], 'priority' => 100, 'priorityName' => 'DEBUG']], 0, 0, - ); + ]; - yield 'log with a context' => array( + yield 'log with a context' => [ 1, - array(array('message' => 'foo', 'context' => array('foo' => 'bar'), 'priority' => 100, 'priorityName' => 'DEBUG')), - array(array('message' => 'foo', 'context' => array('foo' => 'bar'), 'priority' => 100, 'priorityName' => 'DEBUG')), + [['message' => 'foo', 'context' => ['foo' => 'bar'], 'priority' => 100, 'priorityName' => 'DEBUG']], + [['message' => 'foo', 'context' => ['foo' => 'bar'], 'priority' => 100, 'priorityName' => 'DEBUG']], 0, 0, - ); + ]; if (!class_exists(SilencedErrorContext::class)) { return; } - yield 'logs with some deprecations' => array( + yield 'logs with some deprecations' => [ 1, - array( - array('message' => 'foo3', 'context' => array('exception' => new \ErrorException('warning', 0, E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo', 'context' => array('exception' => new \ErrorException('deprecated', 0, E_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo2', 'context' => array('exception' => new \ErrorException('deprecated', 0, E_USER_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG'), - ), - array( - array('message' => 'foo3', 'context' => array('exception' => array('warning', E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo', 'context' => array('exception' => array('deprecated', E_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false), - array('message' => 'foo2', 'context' => array('exception' => array('deprecated', E_USER_DEPRECATED)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => false), - ), + [ + ['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], + ], 2, 0, - array(100 => array('count' => 3, 'name' => 'DEBUG')), - ); + [100 => ['count' => 3, 'name' => 'DEBUG']], + ]; - yield 'logs with some silent errors' => array( + yield 'logs with some silent errors' => [ 1, - array( - array('message' => 'foo3', 'context' => array('exception' => new \ErrorException('warning', 0, E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo3', 'context' => array('exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)), 'priority' => 100, 'priorityName' => 'DEBUG'), - ), - array( - array('message' => 'foo3', 'context' => array('exception' => array('warning', E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG'), - array('message' => 'foo3', 'context' => array('exception' => array(E_USER_WARNING)), 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true), - ), + [ + ['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' => '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], + ], 0, 1, - ); + ]; } } diff --git a/Tests/DataCollector/MemoryDataCollectorTest.php b/Tests/DataCollector/MemoryDataCollectorTest.php index 1435d05e83..c434ed1e11 100644 --- a/Tests/DataCollector/MemoryDataCollectorTest.php +++ b/Tests/DataCollector/MemoryDataCollectorTest.php @@ -39,21 +39,21 @@ public function testBytesConversion($limit, $bytes) public function getBytesConversionTestData() { - return array( - array('2k', 2048), - array('2 k', 2048), - array('8m', 8 * 1024 * 1024), - array('+2 k', 2048), - array('+2???k', 2048), - array('0x10', 16), - array('0xf', 15), - array('010', 8), - array('+0x10 k', 16 * 1024), - array('1g', 1024 * 1024 * 1024), - array('1G', 1024 * 1024 * 1024), - array('-1', -1), - array('0', 0), - array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' - ); + return [ + ['2k', 2048], + ['2 k', 2048], + ['8m', 8 * 1024 * 1024], + ['+2 k', 2048], + ['+2???k', 2048], + ['0x10', 16], + ['0xf', 15], + ['010', 8], + ['+0x10 k', 16 * 1024], + ['1g', 1024 * 1024 * 1024], + ['1G', 1024 * 1024 * 1024], + ['-1', -1], + ['0', 0], + ['2mk', 2048], // the unit must be the last char, so in this case 'k', not 'm' + ]; } } diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index cce08e27c4..5e97267da5 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -48,8 +48,8 @@ public function testCollect() $this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies()); $this->assertSame('html', $c->getFormat()); $this->assertEquals('foobar', $c->getRoute()); - $this->assertEquals(array('name' => 'foo'), $c->getRouteParams()); - $this->assertSame(array(), $c->getSessionAttributes()); + $this->assertEquals(['name' => 'foo'], $c->getRouteParams()); + $this->assertSame([], $c->getSessionAttributes()); $this->assertSame('en', $c->getLocale()); $this->assertContains(__FILE__, $attributes->get('resource')); $this->assertSame('stdClass', $attributes->get('object')->getType()); @@ -62,13 +62,13 @@ public function testCollect() public function testCollectWithoutRouteParams() { - $request = $this->createRequest(array()); + $request = $this->createRequest([]); $c = new RequestDataCollector(); $c->collect($request, $this->createResponse()); $c->lateCollect(); - $this->assertEquals(array(), $c->getRouteParams()); + $this->assertEquals([], $c->getRouteParams()); } /** @@ -94,95 +94,95 @@ public function provideControllerCallables() $r3 = new \ReflectionClass($this); // test name, callable, expected - return array( - array( + return [ + [ '"Regular" callable', - array($this, 'testControllerInspection'), - array( + [$this, 'testControllerInspection'], + [ 'class' => __NAMESPACE__.'\RequestDataCollectorTest', 'method' => 'testControllerInspection', 'file' => __FILE__, 'line' => $r1->getStartLine(), - ), - ), + ], + ], - array( + [ 'Closure', function () { return 'foo'; }, - array( + [ 'class' => __NAMESPACE__.'\{closure}', 'method' => null, 'file' => __FILE__, 'line' => __LINE__ - 5, - ), - ), + ], + ], - array( + [ 'Static callback as string', __NAMESPACE__.'\RequestDataCollectorTest::staticControllerMethod', - array( + [ 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, 'line' => $r2->getStartLine(), - ), - ), + ], + ], - array( + [ 'Static callable with instance', - array($this, 'staticControllerMethod'), - array( + [$this, 'staticControllerMethod'], + [ 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, 'line' => $r2->getStartLine(), - ), - ), + ], + ], - array( + [ 'Static callable with class name', - array('Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'staticControllerMethod'), - array( + ['Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'staticControllerMethod'], + [ 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, 'line' => $r2->getStartLine(), - ), - ), + ], + ], - array( + [ 'Callable with instance depending on __call()', - array($this, 'magicMethod'), - array( + [$this, 'magicMethod'], + [ 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'magicMethod', 'file' => 'n/a', 'line' => 'n/a', - ), - ), + ], + ], - array( + [ 'Callable with class name depending on __callStatic()', - array('Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'magicMethod'), - array( + ['Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'magicMethod'], + [ 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'magicMethod', 'file' => 'n/a', 'line' => 'n/a', - ), - ), + ], + ], - array( + [ 'Invokable controller', $this, - array( + [ 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => null, 'file' => __FILE__, 'line' => $r3->getStartLine(), - ), - ), - ); + ], + ], + ]; } public function testItIgnoresInvalidCallables() @@ -199,9 +199,9 @@ public function testItIgnoresInvalidCallables() public function testItAddsRedirectedAttributesWhenRequestContainsSpecificCookie() { $request = $this->createRequest(); - $request->cookies->add(array( + $request->cookies->add([ 'sf_redirect' => '{}', - )); + ]); $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); @@ -233,9 +233,9 @@ public function testItCollectsTheRedirectionAndClearTheCookie() $request = $this->createRequest(); $request->attributes->set('_redirected', true); - $request->cookies->add(array( + $request->cookies->add([ 'sf_redirect' => '{"method": "POST"}', - )); + ]); $c->collect($request, $response = $this->createResponse()); $c->lateCollect(); @@ -246,7 +246,7 @@ public function testItCollectsTheRedirectionAndClearTheCookie() $this->assertNull($cookie->getValue()); } - protected function createRequest($routeParams = array('name' => 'foo')) + protected function createRequest($routeParams = ['name' => 'foo']) { $request = Request::create('http://test.com/foo?bar=baz'); $request->attributes->set('foo', 'bar'); diff --git a/Tests/Debug/TraceableEventDispatcherTest.php b/Tests/Debug/TraceableEventDispatcherTest.php index 3de147c7f7..8b8e91aeb4 100644 --- a/Tests/Debug/TraceableEventDispatcherTest.php +++ b/Tests/Debug/TraceableEventDispatcherTest.php @@ -31,7 +31,7 @@ public function testStopwatchSections() $kernel->terminate($request, $response); $events = $stopwatch->getSectionEvents($response->headers->get('X-Debug-Token')); - $this->assertEquals(array( + $this->assertEquals([ '__section__', 'kernel.request', 'kernel.controller', @@ -39,13 +39,13 @@ public function testStopwatchSections() 'controller', 'kernel.response', 'kernel.terminate', - ), array_keys($events)); + ], array_keys($events)); } public function testStopwatchCheckControllerOnRequestEvent() { $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') - ->setMethods(array('isStarted')) + ->setMethods(['isStarted']) ->getMock(); $stopwatch->expects($this->once()) ->method('isStarted') @@ -61,7 +61,7 @@ public function testStopwatchCheckControllerOnRequestEvent() public function testStopwatchStopControllerOnRequestEvent() { $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch') - ->setMethods(array('isStarted', 'stop', 'stopSection')) + ->setMethods(['isStarted', 'stop', 'stopSection']) ->getMock(); $stopwatch->expects($this->once()) ->method('isStarted') @@ -114,7 +114,7 @@ protected function getHttpKernel($dispatcher, $controller) $controllerResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface')->getMock(); $controllerResolver->expects($this->once())->method('getController')->will($this->returnValue($controller)); $argumentResolver = $this->getMockBuilder('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface')->getMock(); - $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue(array())); + $argumentResolver->expects($this->once())->method('getArguments')->will($this->returnValue([])); return new HttpKernel($dispatcher, $controllerResolver, new RequestStack(), $argumentResolver); } diff --git a/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php b/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php index a2fb6afca4..914b1dd8d6 100644 --- a/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php +++ b/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php @@ -24,76 +24,76 @@ public function testExpandClasses() $r->setAccessible(true); $expand = $r->getClosure($pass); - $this->assertSame('Foo', $expand(array('Foo'), array())[0]); - $this->assertSame('Foo', $expand(array('\\Foo'), array())[0]); - $this->assertSame('Foo', $expand(array('Foo'), array('\\Foo'))[0]); - $this->assertSame('Foo', $expand(array('Foo'), array('Foo'))[0]); - $this->assertSame('Foo', $expand(array('\\Foo'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo', $expand(array('Foo'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo', $expand(array('\\Foo'), array('\\Foo\\Bar\\Acme'))[0]); + $this->assertSame('Foo', $expand(['Foo'], [])[0]); + $this->assertSame('Foo', $expand(['\\Foo'], [])[0]); + $this->assertSame('Foo', $expand(['Foo'], ['\\Foo'])[0]); + $this->assertSame('Foo', $expand(['Foo'], ['Foo'])[0]); + $this->assertSame('Foo', $expand(['\\Foo'], ['\\Foo\\Bar'])[0]); + $this->assertSame('Foo', $expand(['Foo'], ['\\Foo\\Bar'])[0]); + $this->assertSame('Foo', $expand(['\\Foo'], ['\\Foo\\Bar\\Acme'])[0]); - $this->assertSame('Foo\\Bar', $expand(array('Foo\\'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo\\Bar\\Acme', $expand(array('Foo\\'), array('\\Foo\\Bar\\Acme'))[0]); - $this->assertEmpty($expand(array('Foo\\'), array('\\Foo'))); + $this->assertSame('Foo\\Bar', $expand(['Foo\\'], ['\\Foo\\Bar'])[0]); + $this->assertSame('Foo\\Bar\\Acme', $expand(['Foo\\'], ['\\Foo\\Bar\\Acme'])[0]); + $this->assertEmpty($expand(['Foo\\'], ['\\Foo'])); - $this->assertSame('Acme\\Foo\\Bar', $expand(array('**\\Foo\\'), array('\\Acme\\Foo\\Bar'))[0]); - $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo\\Bar'))); - $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Acme\\Foo'))); - $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo'))); + $this->assertSame('Acme\\Foo\\Bar', $expand(['**\\Foo\\'], ['\\Acme\\Foo\\Bar'])[0]); + $this->assertEmpty($expand(['**\\Foo\\'], ['\\Foo\\Bar'])); + $this->assertEmpty($expand(['**\\Foo\\'], ['\\Acme\\Foo'])); + $this->assertEmpty($expand(['**\\Foo\\'], ['\\Foo'])); - $this->assertSame('Acme\\Foo', $expand(array('**\\Foo'), array('\\Acme\\Foo'))[0]); - $this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\Foo\\AcmeBundle'))); - $this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\FooBar\\AcmeBundle'))); + $this->assertSame('Acme\\Foo', $expand(['**\\Foo'], ['\\Acme\\Foo'])[0]); + $this->assertEmpty($expand(['**\\Foo'], ['\\Acme\\Foo\\AcmeBundle'])); + $this->assertEmpty($expand(['**\\Foo'], ['\\Acme\\FooBar\\AcmeBundle'])); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bar'))[0]); - $this->assertEmpty($expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))); + $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bar'])[0]); + $this->assertEmpty($expand(['Foo\\*\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]); - $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]); + $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**\\Bar'], ['\\Foo\\Acme\\Bar'])[0]); + $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(['Foo\\**\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])[0]); - $this->assertSame('Acme\\Bar', $expand(array('*\\Bar'), array('\\Acme\\Bar'))[0]); - $this->assertEmpty($expand(array('*\\Bar'), array('\\Bar'))); - $this->assertEmpty($expand(array('*\\Bar'), array('\\Foo\\Acme\\Bar'))); + $this->assertSame('Acme\\Bar', $expand(['*\\Bar'], ['\\Acme\\Bar'])[0]); + $this->assertEmpty($expand(['*\\Bar'], ['\\Bar'])); + $this->assertEmpty($expand(['*\\Bar'], ['\\Foo\\Acme\\Bar'])); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]); - $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(array('**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]); - $this->assertEmpty($expand(array('**\\Bar'), array('\\Bar'))); + $this->assertSame('Foo\\Acme\\Bar', $expand(['**\\Bar'], ['\\Foo\\Acme\\Bar'])[0]); + $this->assertSame('Foo\\Acme\\Bundle\\Bar', $expand(['**\\Bar'], ['\\Foo\\Acme\\Bundle\\Bar'])[0]); + $this->assertEmpty($expand(['**\\Bar'], ['\\Bar'])); - $this->assertSame('Foo\\Bar', $expand(array('Foo\\*'), array('\\Foo\\Bar'))[0]); - $this->assertEmpty($expand(array('Foo\\*'), array('\\Foo\\Acme\\Bar'))); + $this->assertSame('Foo\\Bar', $expand(['Foo\\*'], ['\\Foo\\Bar'])[0]); + $this->assertEmpty($expand(['Foo\\*'], ['\\Foo\\Acme\\Bar'])); - $this->assertSame('Foo\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Bar'))[0]); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]); + $this->assertSame('Foo\\Bar', $expand(['Foo\\**'], ['\\Foo\\Bar'])[0]); + $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**'], ['\\Foo\\Acme\\Bar'])[0]); - $this->assertSame(array('Foo\\Bar'), $expand(array('Foo\\*'), array('Foo\\Bar', 'Foo\\BarTest'))); - $this->assertSame(array('Foo\\Bar', 'Foo\\BarTest'), $expand(array('Foo\\*', 'Foo\\*Test'), array('Foo\\Bar', 'Foo\\BarTest'))); + $this->assertSame(['Foo\\Bar'], $expand(['Foo\\*'], ['Foo\\Bar', 'Foo\\BarTest'])); + $this->assertSame(['Foo\\Bar', 'Foo\\BarTest'], $expand(['Foo\\*', 'Foo\\*Test'], ['Foo\\Bar', 'Foo\\BarTest'])); $this->assertSame( 'Acme\\FooBundle\\Controller\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\DefaultController'))[0] + $expand(['**Bundle\\Controller\\'], ['\\Acme\\FooBundle\\Controller\\DefaultController'])[0] ); $this->assertSame( 'FooBundle\\Controller\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\FooBundle\\Controller\\DefaultController'))[0] + $expand(['**Bundle\\Controller\\'], ['\\FooBundle\\Controller\\DefaultController'])[0] ); $this->assertSame( 'Acme\\FooBundle\\Controller\\Bar\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\Bar\\DefaultController'))[0] + $expand(['**Bundle\\Controller\\'], ['\\Acme\\FooBundle\\Controller\\Bar\\DefaultController'])[0] ); $this->assertSame( 'Bundle\\Controller\\Bar\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Bundle\\Controller\\Bar\\DefaultController'))[0] + $expand(['**Bundle\\Controller\\'], ['\\Bundle\\Controller\\Bar\\DefaultController'])[0] ); $this->assertSame( 'Acme\\Bundle\\Controller\\Bar\\DefaultController', - $expand(array('**Bundle\\Controller\\'), array('\\Acme\\Bundle\\Controller\\Bar\\DefaultController'))[0] + $expand(['**Bundle\\Controller\\'], ['\\Acme\\Bundle\\Controller\\Bar\\DefaultController'])[0] ); - $this->assertSame('Foo\\Bar', $expand(array('Foo\\Bar'), array())[0]); - $this->assertSame('Foo\\Acme\\Bar', $expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]); + $this->assertSame('Foo\\Bar', $expand(['Foo\\Bar'], [])[0]); + $this->assertSame('Foo\\Acme\\Bar', $expand(['Foo\\**'], ['\\Foo\\Acme\\Bar'])[0]); } } diff --git a/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php b/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php index df8977de0b..871b7e0ee8 100644 --- a/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php +++ b/Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php @@ -22,19 +22,19 @@ class ControllerArgumentValueResolverPassTest extends TestCase { public function testServicesAreOrderedAccordingToPriority() { - $services = array( - 'n3' => array(array()), - 'n1' => array(array('priority' => 200)), - 'n2' => array(array('priority' => 100)), - ); + $services = [ + 'n3' => [[]], + 'n1' => [['priority' => 200]], + 'n2' => [['priority' => 100]], + ]; - $expected = array( + $expected = [ new Reference('n1'), new Reference('n2'), new Reference('n3'), - ); + ]; - $definition = new Definition(ArgumentResolver::class, array(null, array())); + $definition = new Definition(ArgumentResolver::class, [null, []]); $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); @@ -48,12 +48,12 @@ public function testServicesAreOrderedAccordingToPriority() public function testReturningEmptyArrayWhenNoService() { - $definition = new Definition(ArgumentResolver::class, array(null, array())); + $definition = new Definition(ArgumentResolver::class, [null, []]); $container = new ContainerBuilder(); $container->setDefinition('argument_resolver', $definition); (new ControllerArgumentValueResolverPass())->process($container); - $this->assertEquals(array(), $definition->getArgument(1)->getValues()); + $this->assertEquals([], $definition->getArgument(1)->getValues()); } public function testNoArgumentResolver() diff --git a/Tests/DependencyInjection/FragmentRendererPassTest.php b/Tests/DependencyInjection/FragmentRendererPassTest.php index e8957bb3cc..087c666596 100644 --- a/Tests/DependencyInjection/FragmentRendererPassTest.php +++ b/Tests/DependencyInjection/FragmentRendererPassTest.php @@ -33,12 +33,12 @@ public function testContentRendererWithoutInterface() $builder = new ContainerBuilder(); $fragmentHandlerDefinition = $builder->register('fragment.handler'); $builder->register('my_content_renderer', 'Symfony\Component\DependencyInjection\Definition') - ->addTag('kernel.fragment_renderer', array('alias' => 'foo')); + ->addTag('kernel.fragment_renderer', ['alias' => 'foo']); $pass = new FragmentRendererPass(); $pass->process($builder); - $this->assertEquals(array(array('addRendererService', array('foo', 'my_content_renderer'))), $fragmentHandlerDefinition->getMethodCalls()); + $this->assertEquals([['addRendererService', ['foo', 'my_content_renderer']]], $fragmentHandlerDefinition->getMethodCalls()); } public function testValidContentRenderer() @@ -47,20 +47,20 @@ public function testValidContentRenderer() $fragmentHandlerDefinition = $builder->register('fragment.handler') ->addArgument(null); $builder->register('my_content_renderer', 'Symfony\Component\HttpKernel\Tests\DependencyInjection\RendererService') - ->addTag('kernel.fragment_renderer', array('alias' => 'foo')); + ->addTag('kernel.fragment_renderer', ['alias' => 'foo']); $pass = new FragmentRendererPass(); $pass->process($builder); $serviceLocatorDefinition = $builder->getDefinition((string) $fragmentHandlerDefinition->getArgument(0)); $this->assertSame(ServiceLocator::class, $serviceLocatorDefinition->getClass()); - $this->assertEquals(array('foo' => new ServiceClosureArgument(new Reference('my_content_renderer'))), $serviceLocatorDefinition->getArgument(0)); + $this->assertEquals(['foo' => new ServiceClosureArgument(new Reference('my_content_renderer'))], $serviceLocatorDefinition->getArgument(0)); } } class RendererService implements FragmentRendererInterface { - public function render($uri, Request $request = null, array $options = array()) + public function render($uri, Request $request = null, array $options = []) { } diff --git a/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php index ae421d919b..7af756e0b8 100644 --- a/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php +++ b/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php @@ -23,9 +23,9 @@ public function testAutoloadMainExtension() $container = new ContainerBuilder(); $container->registerExtension(new LoadedExtension()); $container->registerExtension(new NotLoadedExtension()); - $container->loadFromExtension('loaded', array()); + $container->loadFromExtension('loaded', []); - $configPass = new MergeExtensionConfigurationPass(array('loaded', 'not_loaded')); + $configPass = new MergeExtensionConfigurationPass(['loaded', 'not_loaded']); $configPass->process($container); $this->assertTrue($container->hasDefinition('loaded.foo')); diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index ca121c7327..6d0da5fcf8 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -32,7 +32,7 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase public function testInvalidClass() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', NotFound::class) ->addTag('controller.service_arguments') @@ -49,10 +49,10 @@ public function testInvalidClass() public function testNoAction() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('argument' => 'bar')) + ->addTag('controller.service_arguments', ['argument' => 'bar']) ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -66,10 +66,10 @@ public function testNoAction() public function testNoArgument() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction')) + ->addTag('controller.service_arguments', ['action' => 'fooAction']) ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -83,10 +83,10 @@ public function testNoArgument() public function testNoService() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar')) + ->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar']) ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -100,10 +100,10 @@ public function testNoService() public function testInvalidMethod() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'barAction', 'argument' => 'bar', 'id' => 'bar_service')) + ->addTag('controller.service_arguments', ['action' => 'barAction', 'argument' => 'bar', 'id' => 'bar_service']) ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -117,10 +117,10 @@ public function testInvalidMethod() public function testInvalidArgument() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'baz', 'id' => 'bar')) + ->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'baz', 'id' => 'bar']) ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -130,7 +130,7 @@ public function testInvalidArgument() public function testAllActions() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) ->addTag('controller.service_arguments') @@ -141,7 +141,7 @@ public function testAllActions() $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertEquals(array('foo:fooAction'), array_keys($locator)); + $this->assertEquals(['foo:fooAction'], array_keys($locator)); $this->assertInstanceof(ServiceClosureArgument::class, $locator['foo:fooAction']); $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); @@ -149,18 +149,18 @@ public function testAllActions() $this->assertSame(ServiceLocator::class, $locator->getClass()); $this->assertFalse($locator->isPublic()); - $expected = array('bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))); + $expected = ['bar' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))]; $this->assertEquals($expected, $locator->getArgument(0)); } public function testExplicitArgument() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => 'bar')) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => 'baz')) // should be ignored, the first wins + ->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar', 'id' => 'bar']) + ->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar', 'id' => 'baz']) // should be ignored, the first wins ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -169,17 +169,17 @@ public function testExplicitArgument() $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - $expected = array('bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, RegisterTestController::class))); + $expected = ['bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, RegisterTestController::class))]; $this->assertEquals($expected, $locator->getArgument(0)); } public function testOptionalArgument() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->addTag('controller.service_arguments', array('action' => 'fooAction', 'argument' => 'bar', 'id' => '?bar')) + ->addTag('controller.service_arguments', ['action' => 'fooAction', 'argument' => 'bar', 'id' => '?bar']) ; $pass = new RegisterControllerArgumentLocatorsPass(); @@ -188,14 +188,14 @@ public function testOptionalArgument() $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - $expected = array('bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))); + $expected = ['bar' => new ServiceClosureArgument(new TypedReference('bar', ControllerDummy::class, RegisterTestController::class, ContainerInterface::IGNORE_ON_INVALID_REFERENCE))]; $this->assertEquals($expected, $locator->getArgument(0)); } public function testSkipSetContainer() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', ContainerAwareRegisterTestController::class) ->addTag('controller.service_arguments'); @@ -204,7 +204,7 @@ public function testSkipSetContainer() $pass->process($container); $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertSame(array('foo:fooAction'), array_keys($locator)); + $this->assertSame(['foo:fooAction'], array_keys($locator)); } /** @@ -214,7 +214,7 @@ public function testSkipSetContainer() public function testExceptionOnNonExistentTypeHint() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', NonExistentClassController::class) ->addTag('controller.service_arguments'); @@ -230,7 +230,7 @@ public function testExceptionOnNonExistentTypeHint() public function testExceptionOnNonExistentTypeHintDifferentNamespace() { $container = new ContainerBuilder(); - $container->register('argument_resolver.service')->addArgument(array()); + $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', NonExistentClassDifferentNamespaceController::class) ->addTag('controller.service_arguments'); @@ -242,7 +242,7 @@ public function testExceptionOnNonExistentTypeHintDifferentNamespace() public function testNoExceptionOnNonExistentTypeHintOptionalArg() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', NonExistentClassOptionalController::class) ->addTag('controller.service_arguments'); @@ -251,13 +251,13 @@ public function testNoExceptionOnNonExistentTypeHintOptionalArg() $pass->process($container); $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertSame(array('foo:barAction', 'foo:fooAction'), array_keys($locator)); + $this->assertSame(['foo:barAction', 'foo:fooAction'], array_keys($locator)); } public function testArgumentWithNoTypeHintIsOk() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', ArgumentWithoutTypeController::class) ->addTag('controller.service_arguments'); @@ -272,7 +272,7 @@ public function testArgumentWithNoTypeHintIsOk() public function testControllersAreMadePublic() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', ArgumentWithoutTypeController::class) ->setPublic(false) @@ -290,10 +290,10 @@ public function testControllersAreMadePublic() public function testBindings($bindingName) { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', RegisterTestController::class) - ->setBindings(array($bindingName => new Reference('foo'))) + ->setBindings([$bindingName => new Reference('foo')]) ->addTag('controller.service_arguments'); $pass = new RegisterControllerArgumentLocatorsPass(); @@ -303,22 +303,22 @@ public function testBindings($bindingName) $locator = $container->getDefinition((string) $locator['foo:fooAction']->getValues()[0]); - $expected = array('bar' => new ServiceClosureArgument(new Reference('foo'))); + $expected = ['bar' => new ServiceClosureArgument(new Reference('foo'))]; $this->assertEquals($expected, $locator->getArgument(0)); } public function provideBindings() { - return array(array(ControllerDummy::class), array('$bar')); + return [[ControllerDummy::class], ['$bar']]; } public function testDoNotBindScalarValueToControllerArgument() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('foo', ArgumentWithoutTypeController::class) - ->setBindings(array('$someArg' => '%foo%')) + ->setBindings(['$someArg' => '%foo%']) ->addTag('controller.service_arguments'); $pass = new RegisterControllerArgumentLocatorsPass(); @@ -331,12 +331,12 @@ public function testDoNotBindScalarValueToControllerArgument() public function testBindingsOnChildDefinitions() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('parent', ArgumentWithoutTypeController::class); $container->setDefinition('child', (new ChildDefinition('parent')) - ->setBindings(array('$someArg' => new Reference('parent'))) + ->setBindings(['$someArg' => new Reference('parent')]) ->addTag('controller.service_arguments') ); diff --git a/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php index 9cac968185..713ab5441a 100644 --- a/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php @@ -23,13 +23,13 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase public function testProcess() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('stdClass', 'stdClass'); $container->register(parent::class, 'stdClass'); $container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments'); $container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments') - ->addMethodCall('setTestCase', array(new Reference('c1'))); + ->addMethodCall('setTestCase', [new Reference('c1')]); $pass = new RegisterControllerArgumentLocatorsPass(); $pass->process($container); @@ -43,19 +43,19 @@ public function testProcess() (new ResolveInvalidReferencesPass())->process($container); $this->assertCount(1, $container->getDefinition((string) $controllers['c2:setTestCase']->getValues()[0])->getArgument(0)); - $this->assertSame(array(), $container->getDefinition((string) $controllers['c2:fooAction']->getValues()[0])->getArgument(0)); + $this->assertSame([], $container->getDefinition((string) $controllers['c2:fooAction']->getValues()[0])->getArgument(0)); (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); $controllers = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); - $this->assertSame(array('c1:fooAction'), array_keys($controllers)); - $this->assertSame(array('bar'), array_keys($container->getDefinition((string) $controllers['c1:fooAction']->getValues()[0])->getArgument(0))); + $this->assertSame(['c1:fooAction'], array_keys($controllers)); + $this->assertSame(['bar'], array_keys($container->getDefinition((string) $controllers['c1:fooAction']->getValues()[0])->getArgument(0))); - $expectedLog = array( + $expectedLog = [ 'Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass: Removing service-argument resolver for controller "c2:fooAction": no corresponding services exist for the referenced types.', 'Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass: Removing method "setTestCase" of service "c2" from controller candidates: the method is called at instantiation, thus cannot be an action.', - ); + ]; $this->assertSame($expectedLog, $container->getCompiler()->getLog()); } @@ -63,7 +63,7 @@ public function testProcess() public function testSameIdClass() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register(RegisterTestController::class, RegisterTestController::class) ->addTag('controller.service_arguments') @@ -72,17 +72,17 @@ public function testSameIdClass() (new RegisterControllerArgumentLocatorsPass())->process($container); (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); - $expected = array( + $expected = [ RegisterTestController::class.':fooAction', RegisterTestController::class.'::fooAction', - ); + ]; $this->assertEquals($expected, array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))); } public function testInvoke() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register('invokable', InvokableRegisterTestController::class) ->addTag('controller.service_arguments') @@ -92,7 +92,7 @@ public function testInvoke() (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); $this->assertEquals( - array('invokable:__invoke', 'invokable'), + ['invokable:__invoke', 'invokable'], array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0)) ); } @@ -100,7 +100,7 @@ public function testInvoke() public function testInvokeSameIdClass() { $container = new ContainerBuilder(); - $resolver = $container->register('argument_resolver.service')->addArgument(array()); + $resolver = $container->register('argument_resolver.service')->addArgument([]); $container->register(InvokableRegisterTestController::class, InvokableRegisterTestController::class) ->addTag('controller.service_arguments') @@ -109,11 +109,11 @@ public function testInvokeSameIdClass() (new RegisterControllerArgumentLocatorsPass())->process($container); (new RemoveEmptyControllerArgumentLocatorsPass())->process($container); - $expected = array( + $expected = [ InvokableRegisterTestController::class.':__invoke', InvokableRegisterTestController::class.'::__invoke', InvokableRegisterTestController::class, - ); + ]; $this->assertEquals($expected, array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))); } } diff --git a/Tests/DependencyInjection/ResettableServicePassTest.php b/Tests/DependencyInjection/ResettableServicePassTest.php index f7ea16dbfb..9b23ad003d 100644 --- a/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/Tests/DependencyInjection/ResettableServicePassTest.php @@ -19,14 +19,14 @@ public function testCompilerPass() $container = new ContainerBuilder(); $container->register('one', ResettableService::class) ->setPublic(true) - ->addTag('kernel.reset', array('method' => 'reset')); + ->addTag('kernel.reset', ['method' => 'reset']); $container->register('two', ClearableService::class) ->setPublic(true) - ->addTag('kernel.reset', array('method' => 'clear')); + ->addTag('kernel.reset', ['method' => 'clear']); $container->register('services_resetter', ServicesResetter::class) ->setPublic(true) - ->setArguments(array(null, array())); + ->setArguments([null, []]); $container->addCompilerPass(new ResettableServicePass()); $container->compile(); @@ -34,16 +34,16 @@ public function testCompilerPass() $definition = $container->getDefinition('services_resetter'); $this->assertEquals( - array( - new IteratorArgument(array( + [ + new IteratorArgument([ 'one' => new Reference('one', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE), 'two' => new Reference('two', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE), - )), - array( + ]), + [ 'one' => 'reset', 'two' => 'clear', - ), - ), + ], + ], $definition->getArguments() ); } @@ -58,7 +58,7 @@ public function testMissingMethod() $container->register(ResettableService::class) ->addTag('kernel.reset'); $container->register('services_resetter', ServicesResetter::class) - ->setArguments(array(null, array())); + ->setArguments([null, []]); $container->addCompilerPass(new ResettableServicePass()); $container->compile(); @@ -68,7 +68,7 @@ public function testCompilerPassWithoutResetters() { $container = new ContainerBuilder(); $container->register('services_resetter', ServicesResetter::class) - ->setArguments(array(null, array())); + ->setArguments([null, []]); $container->addCompilerPass(new ResettableServicePass()); $container->compile(); diff --git a/Tests/DependencyInjection/ServicesResetterTest.php b/Tests/DependencyInjection/ServicesResetterTest.php index 47c62abd0d..86f1abdb05 100644 --- a/Tests/DependencyInjection/ServicesResetterTest.php +++ b/Tests/DependencyInjection/ServicesResetterTest.php @@ -26,13 +26,13 @@ protected function setUp() public function testResetServices() { - $resetter = new ServicesResetter(new \ArrayIterator(array( + $resetter = new ServicesResetter(new \ArrayIterator([ 'id1' => new ResettableService(), 'id2' => new ClearableService(), - )), array( + ]), [ 'id1' => 'reset', 'id2' => 'clear', - )); + ]); $resetter->reset(); diff --git a/Tests/Event/FilterControllerArgumentsEventTest.php b/Tests/Event/FilterControllerArgumentsEventTest.php index f1e440b2fc..abc51ac51e 100644 --- a/Tests/Event/FilterControllerArgumentsEventTest.php +++ b/Tests/Event/FilterControllerArgumentsEventTest.php @@ -11,7 +11,7 @@ class FilterControllerArgumentsEventTest extends TestCase { public function testFilterControllerArgumentsEvent() { - $filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, array('test'), new Request(), 1); - $this->assertEquals($filterController->getArguments(), array('test')); + $filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1); + $this->assertEquals($filterController->getArguments(), ['test']); } } diff --git a/Tests/EventListener/AddRequestFormatsListenerTest.php b/Tests/EventListener/AddRequestFormatsListenerTest.php index 3ffb9f3d63..b4ea2f955b 100644 --- a/Tests/EventListener/AddRequestFormatsListenerTest.php +++ b/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -30,7 +30,7 @@ class AddRequestFormatsListenerTest extends TestCase protected function setUp() { - $this->listener = new AddRequestFormatsListener(array('csv' => array('text/csv', 'text/plain'))); + $this->listener = new AddRequestFormatsListener(['csv' => ['text/csv', 'text/plain']]); } protected function tearDown() @@ -46,7 +46,7 @@ public function testIsAnEventSubscriber() public function testRegisteredEvent() { $this->assertEquals( - array(KernelEvents::REQUEST => array('onKernelRequest', 1)), + [KernelEvents::REQUEST => ['onKernelRequest', 1]], AddRequestFormatsListener::getSubscribedEvents() ); } @@ -58,7 +58,7 @@ public function testSetAdditionalFormats() $request->expects($this->once()) ->method('setFormat') - ->with('csv', array('text/csv', 'text/plain')); + ->with('csv', ['text/csv', 'text/plain']); $this->listener->onKernelRequest($event); } diff --git a/Tests/EventListener/DebugHandlersListenerTest.php b/Tests/EventListener/DebugHandlersListenerTest.php index 9a9c17edab..d9e261d35a 100644 --- a/Tests/EventListener/DebugHandlersListenerTest.php +++ b/Tests/EventListener/DebugHandlersListenerTest.php @@ -40,11 +40,11 @@ public function testConfigure() $listener = new DebugHandlersListener($userHandler, $logger); $xHandler = new ExceptionHandler(); $eHandler = new ErrorHandler(); - $eHandler->setExceptionHandler(array($xHandler, 'handle')); + $eHandler->setExceptionHandler([$xHandler, 'handle']); $exception = null; - set_error_handler(array($eHandler, 'handleError')); - set_exception_handler(array($eHandler, 'handleException')); + set_error_handler([$eHandler, 'handleError']); + set_exception_handler([$eHandler, 'handleException']); try { $listener->configure(); } catch (\Exception $exception) { @@ -58,10 +58,10 @@ public function testConfigure() $this->assertSame($userHandler, $xHandler->setHandler('var_dump')); - $loggers = $eHandler->setLoggers(array()); + $loggers = $eHandler->setLoggers([]); $this->assertArrayHasKey(E_DEPRECATED, $loggers); - $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]); + $this->assertSame([$logger, LogLevel::INFO], $loggers[E_DEPRECATED]); } public function testConfigureForHttpKernelWithNoTerminateWithException() @@ -75,7 +75,7 @@ public function testConfigureForHttpKernelWithNoTerminateWithException() ); $exception = null; - $h = set_exception_handler(array($eHandler, 'handleException')); + $h = set_exception_handler([$eHandler, 'handleException']); try { $listener->configure($event); } catch (\Exception $exception) { @@ -101,16 +101,16 @@ public function testConsoleEvent() $dispatcher->addSubscriber($listener); - $xListeners = array( - KernelEvents::REQUEST => array(array($listener, 'configure')), - ConsoleEvents::COMMAND => array(array($listener, 'configure')), - ); + $xListeners = [ + KernelEvents::REQUEST => [[$listener, 'configure']], + ConsoleEvents::COMMAND => [[$listener, 'configure']], + ]; $this->assertSame($xListeners, $dispatcher->getListeners()); $exception = null; $eHandler = new ErrorHandler(); - set_error_handler(array($eHandler, 'handleError')); - set_exception_handler(array($eHandler, 'handleException')); + set_error_handler([$eHandler, 'handleError']); + set_exception_handler([$eHandler, 'handleException']); try { $dispatcher->dispatch(ConsoleEvents::COMMAND, $event); } catch (\Exception $exception) { @@ -139,7 +139,7 @@ public function testReplaceExistingExceptionHandler() $eHandler->setExceptionHandler('var_dump'); $exception = null; - set_exception_handler(array($eHandler, 'handleException')); + set_exception_handler([$eHandler, 'handleException']); try { $listener->configure(); } catch (\Exception $exception) { diff --git a/Tests/EventListener/DumpListenerTest.php b/Tests/EventListener/DumpListenerTest.php index 509f443087..b86a7552f8 100644 --- a/Tests/EventListener/DumpListenerTest.php +++ b/Tests/EventListener/DumpListenerTest.php @@ -29,7 +29,7 @@ class DumpListenerTest extends TestCase public function testSubscribedEvents() { $this->assertSame( - array(ConsoleEvents::COMMAND => array('configure', 1024)), + [ConsoleEvents::COMMAND => ['configure', 1024]], DumpListener::getSubscribedEvents() ); } @@ -68,7 +68,7 @@ class MockCloner implements ClonerInterface { public function cloneVar($var) { - return new Data(array(array($var.'-'))); + return new Data([[$var.'-']]); } } diff --git a/Tests/EventListener/ExceptionListenerTest.php b/Tests/EventListener/ExceptionListenerTest.php index 0b73075e7b..c4e8cd505c 100644 --- a/Tests/EventListener/ExceptionListenerTest.php +++ b/Tests/EventListener/ExceptionListenerTest.php @@ -94,7 +94,7 @@ public function testHandleWithLogger($event, $event2) public function provider() { if (!class_exists('Symfony\Component\HttpFoundation\Request')) { - return array(array(null, null)); + return [[null, null]]; } $request = new Request(); @@ -102,9 +102,9 @@ public function provider() $event = new GetResponseForExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MASTER_REQUEST, $exception); $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, HttpKernelInterface::MASTER_REQUEST, $exception); - return array( - array($event, $event2), - ); + return [ + [$event, $event2], + ]; } public function testSubRequestFormat() @@ -142,7 +142,7 @@ public function testCSPHeaderIsRemoved() $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); $dispatcher->dispatch(KernelEvents::EXCEPTION, $event); - $response = new Response('', 200, array('content-security-policy' => "style-src 'self'")); + $response = new Response('', 200, ['content-security-policy' => "style-src 'self'"]); $this->assertTrue($response->headers->has('content-security-policy')); $event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response); diff --git a/Tests/EventListener/FragmentListenerTest.php b/Tests/EventListener/FragmentListenerTest.php index edf0498265..6408b1b21c 100644 --- a/Tests/EventListener/FragmentListenerTest.php +++ b/Tests/EventListener/FragmentListenerTest.php @@ -68,7 +68,7 @@ public function testAccessDeniedWithNonSafeMethods() */ public function testAccessDeniedWithWrongSignature() { - $request = Request::create('http://example.com/_fragment', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); + $request = Request::create('http://example.com/_fragment', 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']); $listener = new FragmentListener(new UriSigner('foo')); $event = $this->createGetResponseEvent($request); @@ -79,14 +79,14 @@ public function testAccessDeniedWithWrongSignature() public function testWithSignature() { $signer = new UriSigner('foo'); - $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); + $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']); $listener = new FragmentListener($signer); $event = $this->createGetResponseEvent($request); $listener->onKernelRequest($event); - $this->assertEquals(array('foo' => 'bar', '_controller' => 'foo'), $request->attributes->get('_route_params')); + $this->assertEquals(['foo' => 'bar', '_controller' => 'foo'], $request->attributes->get('_route_params')); $this->assertFalse($request->query->has('_path')); } @@ -105,7 +105,7 @@ public function testRemovesPathWithControllerDefined() public function testRemovesPathWithControllerNotDefined() { $signer = new UriSigner('foo'); - $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); + $request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']); $listener = new FragmentListener($signer); $event = $this->createGetResponseEvent($request); diff --git a/Tests/EventListener/LocaleListenerTest.php b/Tests/EventListener/LocaleListenerTest.php index f442235ad0..1cf4b72c69 100644 --- a/Tests/EventListener/LocaleListenerTest.php +++ b/Tests/EventListener/LocaleListenerTest.php @@ -54,7 +54,7 @@ public function testLocaleSetForRoutingContext() $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $request = Request::create('/'); @@ -70,7 +70,7 @@ public function testRouterResetWithParentRequestOnKernelFinishRequest() $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); - $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); + $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(['getContext'])->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $parentRequest = Request::create('/'); diff --git a/Tests/EventListener/ResponseListenerTest.php b/Tests/EventListener/ResponseListenerTest.php index 1d8960267d..aeab68f3e9 100644 --- a/Tests/EventListener/ResponseListenerTest.php +++ b/Tests/EventListener/ResponseListenerTest.php @@ -30,7 +30,7 @@ protected function setUp() { $this->dispatcher = new EventDispatcher(); $listener = new ResponseListener('UTF-8'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); + $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); $this->kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); } @@ -54,7 +54,7 @@ public function testFilterDoesNothingForSubRequests() public function testFilterSetsNonDefaultCharsetIfNotOverridden() { $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); + $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse'], 1); $response = new Response('foo'); @@ -67,7 +67,7 @@ public function testFilterSetsNonDefaultCharsetIfNotOverridden() public function testFilterDoesNothingIfCharsetIsOverridden() { $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); + $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse'], 1); $response = new Response('foo'); $response->setCharset('ISO-8859-1'); @@ -81,7 +81,7 @@ public function testFilterDoesNothingIfCharsetIsOverridden() public function testFiltersSetsNonDefaultCharsetIfNotOverriddenOnNonTextContentType() { $listener = new ResponseListener('ISO-8859-15'); - $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1); + $this->dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse'], 1); $response = new Response('foo'); $request = Request::create('/'); diff --git a/Tests/EventListener/RouterListenerTest.php b/Tests/EventListener/RouterListenerTest.php index ecbce409fb..218af8d36e 100644 --- a/Tests/EventListener/RouterListenerTest.php +++ b/Tests/EventListener/RouterListenerTest.php @@ -62,12 +62,12 @@ public function testPort($defaultHttpPort, $defaultHttpsPort, $uri, $expectedHtt public function getPortData() { - return array( - array(80, 443, 'http://localhost/', 80, 443), - array(80, 443, 'http://localhost:90/', 90, 443), - array(80, 443, 'https://localhost/', 80, 443), - array(80, 443, 'https://localhost:90/', 80, 90), - ); + return [ + [80, 443, 'http://localhost/', 80, 443], + [80, 443, 'http://localhost:90/', 90, 443], + [80, 443, 'https://localhost/', 80, 443], + [80, 443, 'https://localhost:90/', 80, 90], + ]; } /** @@ -102,7 +102,7 @@ public function testRequestMatcher() $requestMatcher->expects($this->once()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext()); $listener->onKernelRequest($event); @@ -118,7 +118,7 @@ public function testSubRequestWithDifferentMethod() $requestMatcher->expects($this->any()) ->method('matchRequest') ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $context = new RequestContext(); @@ -159,10 +159,10 @@ public function testLoggingParameter($parameter, $log, $parameters) public function getLoggingParameterData() { - return array( - array(array('_route' => 'foo'), 'Matched route "{route}".', array('route' => 'foo', 'route_parameters' => array('_route' => 'foo'), 'request_uri' => 'http://localhost/', 'method' => 'GET')), - array(array(), 'Matched route "{route}".', array('route' => 'n/a', 'route_parameters' => array(), 'request_uri' => 'http://localhost/', 'method' => 'GET')), - ); + return [ + [['_route' => 'foo'], 'Matched route "{route}".', ['route' => 'foo', 'route_parameters' => ['_route' => 'foo'], 'request_uri' => 'http://localhost/', 'method' => 'GET']], + [[], 'Matched route "{route}".', ['route' => 'n/a', 'route_parameters' => [], 'request_uri' => 'http://localhost/', 'method' => 'GET']], + ]; } public function testWithBadRequest() diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 1b95d19f9c..f0bac60505 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -90,7 +90,7 @@ public function testSurrogateMasterRequestIsPublic() $request = new Request(); $response = new Response(); - $response->setCache(array('public' => true, 'max_age' => '30')); + $response->setCache(['public' => true, 'max_age' => '30']); $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); $this->assertTrue($request->hasSession()); diff --git a/Tests/EventListener/SurrogateListenerTest.php b/Tests/EventListener/SurrogateListenerTest.php index b955c07d47..66e119f123 100644 --- a/Tests/EventListener/SurrogateListenerTest.php +++ b/Tests/EventListener/SurrogateListenerTest.php @@ -30,7 +30,7 @@ public function testFilterDoesNothingForSubRequests() $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); + $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response); $dispatcher->dispatch(KernelEvents::RESPONSE, $event); @@ -44,7 +44,7 @@ public function testFilterWhenThereIsSomeEsiIncludes() $response = new Response('foo '); $listener = new SurrogateListener(new Esi()); - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); + $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $dispatcher->dispatch(KernelEvents::RESPONSE, $event); @@ -58,7 +58,7 @@ public function testFilterWhenThereIsNoEsiIncludes() $response = new Response('foo'); $listener = new SurrogateListener(new Esi()); - $dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); + $dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']); $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response); $dispatcher->dispatch(KernelEvents::RESPONSE, $event); diff --git a/Tests/EventListener/TestSessionListenerTest.php b/Tests/EventListener/TestSessionListenerTest.php index 0d0985ca5d..f261f2ed15 100644 --- a/Tests/EventListener/TestSessionListenerTest.php +++ b/Tests/EventListener/TestSessionListenerTest.php @@ -87,7 +87,7 @@ public function testEmptySessionDoesNotSendCookie() $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); - $this->assertSame(array(), $response->headers->getCookies()); + $this->assertSame([], $response->headers->getCookies()); } public function testEmptySessionWithNewSessionIdDoesSendCookie() @@ -97,7 +97,7 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie() $this->fixSessionId('456'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123')); + $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -116,11 +116,11 @@ public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie( $this->fixSessionId('456'); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123')); + $request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); - $response = new Response('', 200, array('Set-Cookie' => $existing)); + $response = new Response('', 200, ['Set-Cookie' => $existing]); $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST, $response); @@ -129,11 +129,11 @@ public function testSessionWithNewSessionIdAndNewCookieDoesNotSendAnotherCookie( public function anotherCookieProvider() { - return array( - 'same' => array('MOCKSESSID=789; path=/', array('MOCKSESSID=789; path=/')), - 'different domain' => array('MOCKSESSID=789; path=/; domain=example.com', array('MOCKSESSID=789; path=/; domain=example.com', 'MOCKSESSID=456; path=/')), - 'different path' => array('MOCKSESSID=789; path=/foo', array('MOCKSESSID=789; path=/foo', 'MOCKSESSID=456; path=/')), - ); + return [ + 'same' => ['MOCKSESSID=789; path=/', ['MOCKSESSID=789; path=/']], + 'different domain' => ['MOCKSESSID=789; path=/; domain=example.com', ['MOCKSESSID=789; path=/; domain=example.com', 'MOCKSESSID=456; path=/']], + 'different path' => ['MOCKSESSID=789; path=/foo', ['MOCKSESSID=789; path=/foo', 'MOCKSESSID=456; path=/']], + ]; } public function testUnstartedSessionIsNotSave() diff --git a/Tests/EventListener/ValidateRequestListenerTest.php b/Tests/EventListener/ValidateRequestListenerTest.php index bdab742ce1..fb7a4379bf 100644 --- a/Tests/EventListener/ValidateRequestListenerTest.php +++ b/Tests/EventListener/ValidateRequestListenerTest.php @@ -23,7 +23,7 @@ class ValidateRequestListenerTest extends TestCase { protected function tearDown() { - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } /** @@ -35,12 +35,12 @@ public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = new Request(); - $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); + $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); $request->server->set('REMOTE_ADDR', '1.1.1.1'); $request->headers->set('FORWARDED', 'for=2.2.2.2'); $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); - $dispatcher->addListener(KernelEvents::REQUEST, array(new ValidateRequestListener(), 'onKernelRequest')); + $dispatcher->addListener(KernelEvents::REQUEST, [new ValidateRequestListener(), 'onKernelRequest']); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $dispatcher->dispatch(KernelEvents::REQUEST, $event); diff --git a/Tests/Exception/HttpExceptionTest.php b/Tests/Exception/HttpExceptionTest.php index b64773551e..f5fe97255b 100644 --- a/Tests/Exception/HttpExceptionTest.php +++ b/Tests/Exception/HttpExceptionTest.php @@ -9,22 +9,22 @@ class HttpExceptionTest extends TestCase { public function headerDataProvider() { - return array( - array(array('X-Test' => 'Test')), - array(array('X-Test' => 1)), - array( - array( - array('X-Test' => 'Test'), - array('X-Test-2' => 'Test-2'), - ), - ), - ); + return [ + [['X-Test' => 'Test']], + [['X-Test' => 1]], + [ + [ + ['X-Test' => 'Test'], + ['X-Test-2' => 'Test-2'], + ], + ], + ]; } public function testHeadersDefault() { $exception = $this->createException(); - $this->assertSame(array(), $exception->getHeaders()); + $this->assertSame([], $exception->getHeaders()); } /** diff --git a/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/Tests/Exception/MethodNotAllowedHttpExceptionTest.php index b5def13ce3..31dbf2f036 100644 --- a/Tests/Exception/MethodNotAllowedHttpExceptionTest.php +++ b/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -8,8 +8,8 @@ class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest { public function testHeadersDefault() { - $exception = new MethodNotAllowedHttpException(array('GET', 'PUT')); - $this->assertSame(array('Allow' => 'GET, PUT'), $exception->getHeaders()); + $exception = new MethodNotAllowedHttpException(['GET', 'PUT']); + $this->assertSame(['Allow' => 'GET, PUT'], $exception->getHeaders()); } /** @@ -17,7 +17,7 @@ public function testHeadersDefault() */ public function testHeadersSetter($headers) { - $exception = new MethodNotAllowedHttpException(array('GET')); + $exception = new MethodNotAllowedHttpException(['GET']); $exception->setHeaders($headers); $this->assertSame($headers, $exception->getHeaders()); } diff --git a/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/Tests/Exception/ServiceUnavailableHttpExceptionTest.php index e41a23d4e7..cefde951cc 100644 --- a/Tests/Exception/ServiceUnavailableHttpExceptionTest.php +++ b/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -9,7 +9,7 @@ class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest public function testHeadersDefaultRetryAfter() { $exception = new ServiceUnavailableHttpException(10); - $this->assertSame(array('Retry-After' => 10), $exception->getHeaders()); + $this->assertSame(['Retry-After' => 10], $exception->getHeaders()); } /** diff --git a/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/Tests/Exception/TooManyRequestsHttpExceptionTest.php index 2079bb3380..73ee91a77d 100644 --- a/Tests/Exception/TooManyRequestsHttpExceptionTest.php +++ b/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -9,7 +9,7 @@ class TooManyRequestsHttpExceptionTest extends HttpExceptionTest public function testHeadersDefaultRertyAfter() { $exception = new TooManyRequestsHttpException(10); - $this->assertSame(array('Retry-After' => 10), $exception->getHeaders()); + $this->assertSame(['Retry-After' => 10], $exception->getHeaders()); } /** diff --git a/Tests/Exception/UnauthorizedHttpExceptionTest.php b/Tests/Exception/UnauthorizedHttpExceptionTest.php index 37a0028dc8..a8cc19aef8 100644 --- a/Tests/Exception/UnauthorizedHttpExceptionTest.php +++ b/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -9,7 +9,7 @@ class UnauthorizedHttpExceptionTest extends HttpExceptionTest public function testHeadersDefault() { $exception = new UnauthorizedHttpException('Challenge'); - $this->assertSame(array('WWW-Authenticate' => 'Challenge'), $exception->getHeaders()); + $this->assertSame(['WWW-Authenticate' => 'Challenge'], $exception->getHeaders()); } /** diff --git a/Tests/Fixtures/123/Kernel123.php b/Tests/Fixtures/123/Kernel123.php index d3a76684df..70c4026f06 100644 --- a/Tests/Fixtures/123/Kernel123.php +++ b/Tests/Fixtures/123/Kernel123.php @@ -18,7 +18,7 @@ class Kernel123 extends Kernel { public function registerBundles() { - return array(); + return []; } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/Tests/Fixtures/DataCollector/CloneVarDataCollector.php b/Tests/Fixtures/DataCollector/CloneVarDataCollector.php index 89dec36af4..4f5de182fd 100644 --- a/Tests/Fixtures/DataCollector/CloneVarDataCollector.php +++ b/Tests/Fixtures/DataCollector/CloneVarDataCollector.php @@ -31,7 +31,7 @@ public function collect(Request $request, Response $response, \Exception $except public function reset() { - $this->data = array(); + $this->data = []; } public function getData() diff --git a/Tests/Fixtures/KernelForTest.php b/Tests/Fixtures/KernelForTest.php index 9acee4cac5..88c34b0231 100644 --- a/Tests/Fixtures/KernelForTest.php +++ b/Tests/Fixtures/KernelForTest.php @@ -23,7 +23,7 @@ public function getBundleMap() public function registerBundles() { - return array(); + return []; } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/Tests/Fixtures/KernelWithoutBundles.php b/Tests/Fixtures/KernelWithoutBundles.php index cee1b09fb2..1f5a456061 100644 --- a/Tests/Fixtures/KernelWithoutBundles.php +++ b/Tests/Fixtures/KernelWithoutBundles.php @@ -19,7 +19,7 @@ class KernelWithoutBundles extends Kernel { public function registerBundles() { - return array(); + return []; } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/Tests/Fixtures/TestEventDispatcher.php b/Tests/Fixtures/TestEventDispatcher.php index ca2e6a693d..dc9c9166f9 100644 --- a/Tests/Fixtures/TestEventDispatcher.php +++ b/Tests/Fixtures/TestEventDispatcher.php @@ -18,12 +18,12 @@ class TestEventDispatcher extends EventDispatcher implements TraceableEventDispa { public function getCalledListeners() { - return array('foo'); + return ['foo']; } public function getNotCalledListeners() { - return array('bar'); + return ['bar']; } public function reset() diff --git a/Tests/Fragment/EsiFragmentRendererTest.php b/Tests/Fragment/EsiFragmentRendererTest.php index 51e5756203..52d8551965 100644 --- a/Tests/Fragment/EsiFragmentRendererTest.php +++ b/Tests/Fragment/EsiFragmentRendererTest.php @@ -34,7 +34,7 @@ public function testRenderFallbackWithObjectAttributesIsDeprecated() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); $request = Request::create('/'); - $reference = new ControllerReference('main_controller', array('foo' => new \stdClass()), array()); + $reference = new ControllerReference('main_controller', ['foo' => new \stdClass()], []); $strategy->render($reference, $request); } @@ -42,7 +42,7 @@ public function testRenderFallbackWithScalarIsNotDeprecated() { $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo')); $request = Request::create('/'); - $reference = new ControllerReference('main_controller', array('foo' => array(true)), array()); + $reference = new ControllerReference('main_controller', ['foo' => [true]], []); $strategy->render($reference, $request); } @@ -55,8 +55,8 @@ public function testRender() $request->headers->set('Surrogate-Capability', 'ESI/1.0'); $this->assertEquals('', $strategy->render('/', $request)->getContent()); - $this->assertEquals("\n", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); - $this->assertEquals('', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); + $this->assertEquals("\n", $strategy->render('/', $request, ['comment' => 'This is a comment'])->getContent()); + $this->assertEquals('', $strategy->render('/', $request, ['alt' => 'foo'])->getContent()); } public function testRenderControllerReference() @@ -68,12 +68,12 @@ public function testRenderControllerReference() $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - $reference = new ControllerReference('main_controller', array(), array()); - $altReference = new ControllerReference('alt_controller', array(), array()); + $reference = new ControllerReference('main_controller', [], []); + $altReference = new ControllerReference('alt_controller', [], []); $this->assertEquals( '', - $strategy->render($reference, $request, array('alt' => $altReference))->getContent() + $strategy->render($reference, $request, ['alt' => $altReference])->getContent() ); } @@ -102,7 +102,7 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException() $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'ESI/1.0'); - $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); + $strategy->render('/', $request, ['alt' => new ControllerReference('alt_controller')]); } private function getInlineStrategy($called = false) diff --git a/Tests/Fragment/FragmentHandlerTest.php b/Tests/Fragment/FragmentHandlerTest.php index a296aa0e18..8829393ea4 100644 --- a/Tests/Fragment/FragmentHandlerTest.php +++ b/Tests/Fragment/FragmentHandlerTest.php @@ -68,12 +68,12 @@ public function testDeliverWithUnsuccessfulResponse() public function testRender() { - $handler = $this->getHandler($this->returnValue(new Response('foo')), array('/', Request::create('/'), array('foo' => 'foo', 'ignore_errors' => true))); + $handler = $this->getHandler($this->returnValue(new Response('foo')), ['/', Request::create('/'), ['foo' => 'foo', 'ignore_errors' => true]]); - $this->assertEquals('foo', $handler->render('/', 'foo', array('foo' => 'foo'))); + $this->assertEquals('foo', $handler->render('/', 'foo', ['foo' => 'foo'])); } - protected function getHandler($returnValue, $arguments = array()) + protected function getHandler($returnValue, $arguments = []) { $renderer = $this->getMockBuilder('Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface')->getMock(); $renderer @@ -88,7 +88,7 @@ protected function getHandler($returnValue, $arguments = array()) ; if ($arguments) { - \call_user_func_array(array($e, 'with'), $arguments); + \call_user_func_array([$e, 'with'], $arguments); } $handler = new FragmentHandler($this->requestStack); diff --git a/Tests/Fragment/HIncludeFragmentRendererTest.php b/Tests/Fragment/HIncludeFragmentRendererTest.php index 68f8ded4e9..6125d95ff4 100644 --- a/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -25,14 +25,14 @@ class HIncludeFragmentRendererTest extends TestCase public function testRenderExceptionWhenControllerAndNoSigner() { $strategy = new HIncludeFragmentRenderer(); - $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/')); + $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/')); } public function testRenderWithControllerAndSigner() { $strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo')); - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); + $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'))->getContent()); } public function testRenderWithUri() @@ -48,30 +48,30 @@ public function testRenderWithDefault() { // only default $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent()); // only global default $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); - $this->assertEquals('global_default', $strategy->render('/foo', Request::create('/'), array())->getContent()); + $this->assertEquals('global_default', $strategy->render('/foo', Request::create('/'), [])->getContent()); // global default and default $strategy = new HIncludeFragmentRenderer(null, null, 'global_default'); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent()); } public function testRenderWithAttributesOptions() { // with id $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar'))->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar'])->getContent()); // with attributes $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent()); // with id & attributes $strategy = new HIncludeFragmentRenderer(); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent()); } public function testRenderWithDefaultText() @@ -84,7 +84,7 @@ public function testRenderWithDefaultText() // only default $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent()); } public function testRenderWithEngineAndDefaultText() @@ -97,6 +97,6 @@ public function testRenderWithEngineAndDefaultText() // only default $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), array('default' => 'loading...'))->getContent()); + $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent()); } } diff --git a/Tests/Fragment/InlineFragmentRendererTest.php b/Tests/Fragment/InlineFragmentRendererTest.php index 80f9cd2b53..11adf74c29 100644 --- a/Tests/Fragment/InlineFragmentRendererTest.php +++ b/Tests/Fragment/InlineFragmentRendererTest.php @@ -36,7 +36,7 @@ public function testRenderWithControllerReference() { $strategy = new InlineFragmentRenderer($this->getKernel($this->returnValue(new Response('foo')))); - $this->assertEquals('foo', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent()); + $this->assertEquals('foo', $strategy->render(new ControllerReference('main_controller', [], []), Request::create('/'))->getContent()); } public function testRenderWithObjectsAsAttributes() @@ -44,15 +44,15 @@ public function testRenderWithObjectsAsAttributes() $object = new \stdClass(); $subRequest = Request::create('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dmain_controller'); - $subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en')); - $subRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $subRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $subRequest->attributes->replace(['object' => $object, '_format' => 'html', '_controller' => 'main_controller', '_locale' => 'en']); + $subRequest->headers->set('x-forwarded-for', ['127.0.0.1']); + $subRequest->headers->set('forwarded', ['for="127.0.0.1";host="localhost";proto=http']); $subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $subRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest)); - $this->assertSame('foo', $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'))->getContent()); + $this->assertSame('foo', $strategy->render(new ControllerReference('main_controller', ['object' => $object], []), Request::create('/'))->getContent()); } /** @@ -60,7 +60,7 @@ public function testRenderWithObjectsAsAttributes() */ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerLegacy() { - $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver')->setMethods(array('getController'))->getMock(); + $resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver')->setMethods(['getController'])->getMock(); $resolver ->expects($this->once()) ->method('getController') @@ -72,7 +72,7 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheControllerL $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack()); $renderer = new InlineFragmentRenderer($kernel); - $response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/')); + $response = $renderer->render(new ControllerReference('main_controller', ['object' => new \stdClass(), 'object1' => new Bar()], []), Request::create('/')); $this->assertEquals('bar', $response->getContent()); } @@ -93,22 +93,22 @@ public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController( $kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack(), new ArgumentResolver()); $renderer = new InlineFragmentRenderer($kernel); - $response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/')); + $response = $renderer->render(new ControllerReference('main_controller', ['object' => new \stdClass(), 'object1' => new Bar()], []), Request::create('/')); $this->assertEquals('bar', $response->getContent()); } public function testRenderWithTrustedHeaderDisabled() { - Request::setTrustedProxies(array(), 0); + Request::setTrustedProxies([], 0); $expectedSubRequest = Request::create('/'); - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->headers->set('x-forwarded-for', ['127.0.0.1']); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $this->assertSame('foo', $strategy->render('/', Request::create('/'))->getContent()); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } /** @@ -131,7 +131,7 @@ public function testRenderExceptionIgnoreErrors() $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher); - $this->assertEmpty($strategy->render('/', Request::create('/'), array('ignore_errors' => true))->getContent()); + $this->assertEmpty($strategy->render('/', Request::create('/'), ['ignore_errors' => true])->getContent()); } public function testRenderExceptionIgnoreErrorsWithAlt() @@ -141,7 +141,7 @@ public function testRenderExceptionIgnoreErrorsWithAlt() $this->returnValue(new Response('bar')) ))); - $this->assertEquals('bar', $strategy->render('/', Request::create('/'), array('ignore_errors' => true, 'alt' => '/foo'))->getContent()); + $this->assertEquals('bar', $strategy->render('/', Request::create('/'), ['ignore_errors' => true, 'alt' => '/foo'])->getContent()); } private function getKernel($returnValue) @@ -173,7 +173,7 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() $argumentResolver ->expects($this->once()) ->method('getArguments') - ->will($this->returnValue(array())) + ->will($this->returnValue([])) ; $kernel = new HttpKernel(new EventDispatcher(), $controllerResolver, new RequestStack(), $argumentResolver); @@ -184,7 +184,7 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() echo 'Foo'; // simulate a sub-request with output buffering and an exception - $renderer->render('/', Request::create('/'), array('ignore_errors' => true)); + $renderer->render('/', Request::create('/'), ['ignore_errors' => true]); $this->assertEquals('Foo', ob_get_clean()); } @@ -195,10 +195,10 @@ public function testLocaleAndFormatAreIsKeptInSubrequest() $expectedSubRequest->attributes->set('_format', 'foo'); $expectedSubRequest->setLocale('fr'); if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->headers->set('x-forwarded-for', ['127.0.0.1']); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } - $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->headers->set('forwarded', ['for="127.0.0.1";host="localhost";proto=http']); $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); @@ -215,10 +215,10 @@ public function testESIHeaderIsKeptInSubrequest() $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->headers->set('x-forwarded-for', ['127.0.0.1']); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } - $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->headers->set('forwarded', ['for="127.0.0.1";host="localhost";proto=http']); $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); @@ -230,35 +230,35 @@ public function testESIHeaderIsKeptInSubrequest() public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled() { - Request::setTrustedProxies(array(), Request::HEADER_FORWARDED); + Request::setTrustedProxies([], Request::HEADER_FORWARDED); $this->testESIHeaderIsKeptInSubrequest(); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest() { $expectedSubRequest = Request::create('/'); - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->headers->set('x-forwarded-for', ['127.0.0.1']); + $expectedSubRequest->headers->set('forwarded', ['for="127.0.0.1";host="localhost";proto=http']); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); - $request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*')); + $request = Request::create('/', 'GET', [], [], [], ['HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*']); $strategy->render('/', $request); } public function testFirstTrustedProxyIsSetAsRemote() { - Request::setTrustedProxies(array('1.1.1.1'), -1); + Request::setTrustedProxies(['1.1.1.1'], -1); $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); $expectedSubRequest->server->set('REMOTE_ADDR', '127.0.0.1'); - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->headers->set('x-forwarded-for', ['127.0.0.1']); + $expectedSubRequest->headers->set('forwarded', ['for="127.0.0.1";host="localhost";proto=http']); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); @@ -268,7 +268,7 @@ public function testFirstTrustedProxyIsSetAsRemote() $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); $strategy->render('/', $request); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() @@ -276,12 +276,12 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); $expectedSubRequest->server->set('REMOTE_ADDR', '127.0.0.1'); - $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); - $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->headers->set('x-forwarded-for', ['127.0.0.1']); + $expectedSubRequest->headers->set('forwarded', ['for="127.0.0.1";host="localhost";proto=http']); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); - Request::setTrustedProxies(array('1.1.1.1/24'), -1); + Request::setTrustedProxies(['1.1.1.1/24'], -1); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); @@ -289,7 +289,7 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote() $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); $strategy->render('/', $request); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } /** diff --git a/Tests/Fragment/RoutableFragmentRendererTest.php b/Tests/Fragment/RoutableFragmentRendererTest.php index 3a040dedd6..c03e8c4a92 100644 --- a/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/Tests/Fragment/RoutableFragmentRendererTest.php @@ -35,14 +35,14 @@ public function testGenerateAbsoluteFragmentUri($uri, $controller) public function getGenerateFragmentUriData() { - return array( - array('/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())), - array('/_fragment?_path=_format%3Dxml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())), - array('/_fragment?_path=foo%3Dfoo%26_format%3Djson%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())), - array('/_fragment?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))), - array('/_fragment?foo=foo&_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))), - array('/_fragment?_path=foo%255B0%255D%3Dfoo%26foo%255B1%255D%3Dbar%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => array('foo', 'bar')), array())), - ); + return [ + ['/_fragment?_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', [], [])], + ['/_fragment?_path=_format%3Dxml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', ['_format' => 'xml'], [])], + ['/_fragment?_path=foo%3Dfoo%26_format%3Djson%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', ['foo' => 'foo', '_format' => 'json'], [])], + ['/_fragment?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', ['foo' => 'foo'], ['bar' => 'bar'])], + ['/_fragment?foo=foo&_path=_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', [], ['foo' => 'foo'])], + ['/_fragment?_path=foo%255B0%255D%3Dfoo%26foo%255B1%255D%3Dbar%26_format%3Dhtml%26_locale%3Den%26_controller%3Dcontroller', new ControllerReference('controller', ['foo' => ['foo', 'bar']], [])], + ]; } public function testGenerateFragmentUriWithARequest() @@ -50,7 +50,7 @@ public function testGenerateFragmentUriWithARequest() $request = Request::create('/'); $request->attributes->set('_format', 'json'); $request->setLocale('fr'); - $controller = new ControllerReference('controller', array(), array()); + $controller = new ControllerReference('controller', [], []); $this->assertEquals('/_fragment?_path=_format%3Djson%26_locale%3Dfr%26_controller%3Dcontroller', $this->callGenerateFragmentUriMethod($controller, $request)); } @@ -66,10 +66,10 @@ public function testGenerateFragmentUriWithNonScalar($controller) public function getGenerateFragmentUriDataWithNonScalar() { - return array( - array(new ControllerReference('controller', array('foo' => new Foo(), 'bar' => 'bar'), array())), - array(new ControllerReference('controller', array('foo' => array('foo' => 'foo'), 'bar' => array('bar' => new Foo())), array())), - ); + return [ + [new ControllerReference('controller', ['foo' => new Foo(), 'bar' => 'bar'], [])], + [new ControllerReference('controller', ['foo' => ['foo' => 'foo'], 'bar' => ['bar' => new Foo()]], [])], + ]; } private function callGenerateFragmentUriMethod(ControllerReference $reference, Request $request, $absolute = false) diff --git a/Tests/Fragment/SsiFragmentRendererTest.php b/Tests/Fragment/SsiFragmentRendererTest.php index ff98fd2616..b2181725ed 100644 --- a/Tests/Fragment/SsiFragmentRendererTest.php +++ b/Tests/Fragment/SsiFragmentRendererTest.php @@ -35,7 +35,7 @@ public function testRender() $request->headers->set('Surrogate-Capability', 'SSI/1.0'); $this->assertEquals('', $strategy->render('/', $request)->getContent()); - $this->assertEquals('', $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent(), 'Strategy options should not impact the ssi include tag'); + $this->assertEquals('', $strategy->render('/', $request, ['comment' => 'This is a comment'])->getContent(), 'Strategy options should not impact the ssi include tag'); } public function testRenderControllerReference() @@ -47,12 +47,12 @@ public function testRenderControllerReference() $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'SSI/1.0'); - $reference = new ControllerReference('main_controller', array(), array()); - $altReference = new ControllerReference('alt_controller', array(), array()); + $reference = new ControllerReference('main_controller', [], []); + $altReference = new ControllerReference('alt_controller', [], []); $this->assertEquals( '', - $strategy->render($reference, $request, array('alt' => $altReference))->getContent() + $strategy->render($reference, $request, ['alt' => $altReference])->getContent() ); } @@ -81,7 +81,7 @@ public function testRenderAltControllerReferenceWithoutSignerThrowsException() $request->setLocale('fr'); $request->headers->set('Surrogate-Capability', 'SSI/1.0'); - $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); + $strategy->render('/', $request, ['alt' => new ControllerReference('alt_controller')]); } private function getInlineStrategy($called = false) diff --git a/Tests/HttpCache/EsiTest.php b/Tests/HttpCache/EsiTest.php index 863ad76147..ccc3eecfaf 100644 --- a/Tests/HttpCache/EsiTest.php +++ b/Tests/HttpCache/EsiTest.php @@ -220,13 +220,13 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() $response1 = new Response('foo'); $response1->setStatusCode(404); $response2 = new Response('bar'); - $cache = $this->getCache(Request::create('/'), array($response1, $response2)); + $cache = $this->getCache(Request::create('/'), [$response1, $response2]); $this->assertEquals('bar', $esi->handle($cache, '/', '/alt', false)); } protected function getCache($request, $response) { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)) @@ -234,7 +234,7 @@ protected function getCache($request, $response) if (\is_array($response)) { $cache->expects($this->any()) ->method('handle') - ->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) + ->will(\call_user_func_array([$this, 'onConsecutiveCalls'], $response)) ; } else { $cache->expects($this->any()) diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index a41d866508..7b3cac78c7 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -39,7 +39,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() // implements TerminableInterface $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel') ->disableOriginalConstructor() - ->setMethods(array('terminate', 'registerBundles', 'registerContainerConfiguration')) + ->setMethods(['terminate', 'registerBundles', 'registerContainerConfiguration']) ->getMock(); $kernelMock->expects($this->once()) @@ -61,7 +61,7 @@ public function testPassesOnNonGetHeadRequests() public function testInvalidatesOnPostPutDeleteRequests() { - foreach (array('post', 'put', 'delete') as $method) { + foreach (['post', 'put', 'delete'] as $method) { $this->setNextResponse(200); $this->request($method, '/'); @@ -74,8 +74,8 @@ public function testInvalidatesOnPostPutDeleteRequests() public function testDoesNotCacheWithAuthorizationRequestHeaderAndNonPublicResponse() { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); + $this->setNextResponse(200, ['ETag' => '"Foo"']); + $this->request('GET', '/', ['HTTP_AUTHORIZATION' => 'basic foobarbaz']); $this->assertHttpKernelIsCalled(); $this->assertResponseOk(); @@ -88,8 +88,8 @@ public function testDoesNotCacheWithAuthorizationRequestHeaderAndNonPublicRespon public function testDoesCacheWithAuthorizationRequestHeaderAndPublicResponse() { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"Foo"')); - $this->request('GET', '/', array('HTTP_AUTHORIZATION' => 'basic foobarbaz')); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'ETag' => '"Foo"']); + $this->request('GET', '/', ['HTTP_AUTHORIZATION' => 'basic foobarbaz']); $this->assertHttpKernelIsCalled(); $this->assertResponseOk(); @@ -101,8 +101,8 @@ public function testDoesCacheWithAuthorizationRequestHeaderAndPublicResponse() public function testDoesNotCacheWithCookieHeaderAndNonPublicResponse() { - $this->setNextResponse(200, array('ETag' => '"Foo"')); - $this->request('GET', '/', array(), array('foo' => 'bar')); + $this->setNextResponse(200, ['ETag' => '"Foo"']); + $this->request('GET', '/', [], ['foo' => 'bar']); $this->assertHttpKernelIsCalled(); $this->assertResponseOk(); @@ -115,7 +115,7 @@ public function testDoesNotCacheWithCookieHeaderAndNonPublicResponse() public function testDoesNotCacheRequestsWithACookieHeader() { $this->setNextResponse(200); - $this->request('GET', '/', array(), array('foo' => 'bar')); + $this->request('GET', '/', [], ['foo' => 'bar']); $this->assertHttpKernelIsCalled(); $this->assertResponseOk(); @@ -129,8 +129,8 @@ public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Last-Modified' => $time->format(DATE_RFC2822), 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('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()); @@ -142,8 +142,8 @@ public function testRespondsWith304WhenIfModifiedSinceMatchesLastModified() public function testRespondsWith304WhenIfNoneMatchMatchesETag() { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '12345', 'Content-Type' => 'text/plain'), 'Hello World'); - $this->request('GET', '/', array('HTTP_IF_NONE_MATCH' => '12345')); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'ETag' => '12345', 'Content-Type' => 'text/plain'], 'Hello World'); + $this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345']); $this->assertHttpKernelIsCalled(); $this->assertEquals(304, $this->response->getStatusCode()); @@ -158,7 +158,7 @@ public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch( { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), '', function ($request, $response) use ($time) { + $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)); @@ -168,17 +168,17 @@ public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch( // only ETag matches $t = \DateTime::createFromFormat('U', time() - 3600); - $this->request('GET', '/', array('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', '/', array('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', '/', array('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()); } @@ -187,10 +187,10 @@ public function testIncrementsMaxAgeWhenNoDateIsSpecifiedEventWhenUsingETag() { $this->setNextResponse( 200, - array( + [ 'ETag' => '1234', 'Cache-Control' => 'public, s-maxage=60', - ) + ] ); $this->request('GET', '/'); @@ -210,7 +210,7 @@ public function testIncrementsMaxAgeWhenNoDateIsSpecifiedEventWhenUsingETag() public function testValidatesPrivateResponsesCachedOnTheClient() { - $this->setNextResponse(200, array(), '', function ($request, $response) { + $this->setNextResponse(200, [], '', function ($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'); @@ -243,7 +243,7 @@ public function testValidatesPrivateResponsesCachedOnTheClient() $this->assertTraceContains('miss'); $this->assertTraceContains('store'); - $this->request('GET', '/', array(), array('authenticated' => '')); + $this->request('GET', '/', [], ['authenticated' => '']); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('"private tag"', $this->response->headers->get('ETag')); @@ -257,8 +257,8 @@ public function testStoresResponsesWhenNoCacheRequestDirectivePresent() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822))); - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'Expires' => $time->format(DATE_RFC2822)]); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'no-cache']); $this->assertHttpKernelIsCalled(); $this->assertTraceContains('store'); @@ -269,7 +269,7 @@ public function testReloadsResponsesWhenCacheHitsButNoCacheRequestDirectivePrese { $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) { + $this->setNextResponse(200, ['Cache-Control' => 'public, max-age=10000'], '', function ($request, $response) use (&$count) { ++$count; $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); }); @@ -285,7 +285,7 @@ public function testReloadsResponsesWhenCacheHitsButNoCacheRequestDirectivePrese $this->assertTraceContains('fresh'); $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'no-cache']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Goodbye World', $this->response->getContent()); $this->assertTraceContains('reload'); @@ -296,7 +296,7 @@ public function testDoesNotReloadResponsesWhenAllowReloadIsSetFalseDefault() { $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=10000'), '', function ($request, $response) use (&$count) { + $this->setNextResponse(200, ['Cache-Control' => 'public, max-age=10000'], '', function ($request, $response) use (&$count) { ++$count; $response->setContent(1 == $count ? 'Hello World' : 'Goodbye World'); }); @@ -312,12 +312,12 @@ public function testDoesNotReloadResponsesWhenAllowReloadIsSetFalseDefault() $this->assertTraceContains('fresh'); $this->cacheConfig['allow_reload'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'no-cache']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Hello World', $this->response->getContent()); $this->assertTraceNotContains('reload'); - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'no-cache')); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'no-cache']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Hello World', $this->response->getContent()); $this->assertTraceNotContains('reload'); @@ -327,7 +327,7 @@ public function testRevalidatesFreshCacheEntryWhenMaxAgeRequestDirectiveIsExceed { $count = 0; - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) { + $this->setNextResponse(200, [], '', function ($request, $response) use (&$count) { ++$count; $response->headers->set('Cache-Control', 'public, max-age=10000'); $response->setETag($count); @@ -345,7 +345,7 @@ public function testRevalidatesFreshCacheEntryWhenMaxAgeRequestDirectiveIsExceed $this->assertTraceContains('fresh'); $this->cacheConfig['allow_revalidate'] = true; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'max-age=0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Goodbye World', $this->response->getContent()); $this->assertTraceContains('stale'); @@ -357,7 +357,7 @@ public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIs { $count = 0; - $this->setNextResponse(200, array(), '', function ($request, $response) use (&$count) { + $this->setNextResponse(200, [], '', function ($request, $response) use (&$count) { ++$count; $response->headers->set('Cache-Control', 'public, max-age=10000'); $response->setETag($count); @@ -375,14 +375,14 @@ public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIs $this->assertTraceContains('fresh'); $this->cacheConfig['allow_revalidate'] = false; - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'max-age=0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Hello World', $this->response->getContent()); $this->assertTraceNotContains('stale'); $this->assertTraceNotContains('invalid'); $this->assertTraceContains('fresh'); - $this->request('GET', '/', array('HTTP_CACHE_CONTROL' => 'max-age=0')); + $this->request('GET', '/', ['HTTP_CACHE_CONTROL' => 'max-age=0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Hello World', $this->response->getContent()); $this->assertTraceNotContains('stale'); @@ -393,7 +393,7 @@ public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIs public function testFetchesResponseFromBackendWhenCacheMisses() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('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, array('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, array('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, array('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'); @@ -446,7 +446,7 @@ public function testCachesResponsesWithExplicitNoCacheDirective() public function testCachesResponsesWithAnExpirationHeader() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('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()); @@ -462,7 +462,7 @@ public function testCachesResponsesWithAnExpirationHeader() public function testCachesResponsesWithAMaxAgeDirective() { - $this->setNextResponse(200, array('Cache-Control' => 'public, max-age=5')); + $this->setNextResponse(200, ['Cache-Control' => 'public, max-age=5']); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -478,7 +478,7 @@ public function testCachesResponsesWithAMaxAgeDirective() public function testCachesResponsesWithASMaxAgeDirective() { - $this->setNextResponse(200, array('Cache-Control' => 's-maxage=5')); + $this->setNextResponse(200, ['Cache-Control' => 's-maxage=5']); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -495,7 +495,7 @@ public function testCachesResponsesWithASMaxAgeDirective() public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInformation() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array('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()); @@ -506,7 +506,7 @@ public function testCachesResponsesWithALastModifiedValidatorButNoFreshnessInfor public function testCachesResponsesWithAnETagValidatorButNoFreshnessInformation() { - $this->setNextResponse(200, array('Cache-Control' => 'public', 'ETag' => '"123456"')); + $this->setNextResponse(200, ['Cache-Control' => 'public', 'ETag' => '"123456"']); $this->request('GET', '/'); $this->assertEquals(200, $this->response->getStatusCode()); @@ -519,7 +519,7 @@ public function testHitsCachedResponsesWithExpiresHeader() { $time1 = \DateTime::createFromFormat('U', time() - 5); $time2 = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('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(); @@ -543,7 +543,7 @@ public function testHitsCachedResponsesWithExpiresHeader() public function testHitsCachedResponseWithMaxAgeDirective() { $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('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(); @@ -573,7 +573,7 @@ public function testDegradationWhenCacheLocked() $this->cacheConfig['stale_while_revalidate'] = 10; // The prescence of Last-Modified makes this cacheable (because Response::isValidateable() then). - $this->setNextResponse(200, array('Cache-Control' => 'public, s-maxage=5', 'Last-Modified' => 'some while ago'), 'Old response'); + $this->setNextResponse(200, ['Cache-Control' => 'public, s-maxage=5', 'Last-Modified' => 'some while ago'], 'Old response'); $this->request('GET', '/'); // warm the cache // Now, lock the cache @@ -607,7 +607,7 @@ public function testDegradationWhenCacheLocked() public function testHitsCachedResponseWithSMaxAgeDirective() { $time = \DateTime::createFromFormat('U', time() - 5); - $this->setNextResponse(200, array('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(); @@ -752,7 +752,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() { - $this->setNextResponse(200, array('Cache-Control' => 'must-revalidate')); + $this->setNextResponse(200, ['Cache-Control' => 'must-revalidate']); $this->cacheConfig['default_ttl'] = 10; $this->request('GET', '/'); @@ -767,7 +767,7 @@ public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirectiv public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() { $time = \DateTime::createFromFormat('U', time() + 5); - $this->setNextResponse(200, array('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', '/'); @@ -807,7 +807,7 @@ public function testFetchesFullResponseWhenCacheStaleAndNoValidatorsPresent() public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInformation() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($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')) { @@ -845,7 +845,7 @@ public function testValidatesCachedResponsesUseSameHttpMethod() { $test = $this; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($test) { + $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($test) { $test->assertSame('OPTIONS', $request->getMethod()); }); @@ -858,7 +858,7 @@ public function testValidatesCachedResponsesUseSameHttpMethod() public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation() { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { + $this->setNextResponse(200, [], 'Hello World', function ($request, $response) { $response->headers->set('Cache-Control', 'public'); $response->headers->set('ETag', '"12345"'); if ($response->getETag() == $request->headers->get('IF_NONE_MATCH')) { @@ -895,7 +895,7 @@ public function testServesResponseWhileFreshAndRevalidatesWithLastModifiedInform { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function (Request $request, Response $response) use ($time) { + $this->setNextResponse(200, [], 'Hello World', function (Request $request, Response $response) use ($time) { $response->setSharedMaxAge(10); $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); }); @@ -913,7 +913,7 @@ public function testServesResponseWhileFreshAndRevalidatesWithLastModifiedInform sleep(15); // expire the cache - $this->setNextResponse(304, array(), '', function (Request $request, Response $response) use ($time) { + $this->setNextResponse(304, [], '', function (Request $request, Response $response) use ($time) { $this->assertEquals($time->format(DATE_RFC2822), $request->headers->get('IF_MODIFIED_SINCE')); }); @@ -929,7 +929,7 @@ public function testReplacesCachedResponsesWhenValidationResultsInNon304Response { $time = \DateTime::createFromFormat('U', time()); $count = 0; - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($time, &$count) { + $this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($time, &$count) { $response->headers->set('Last-Modified', $time->format(DATE_RFC2822)); $response->headers->set('Cache-Control', 'public'); switch (++$count) { @@ -966,20 +966,20 @@ public function testReplacesCachedResponsesWhenValidationResultsInNon304Response public function testPassesHeadRequestsThroughDirectlyOnPass() { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { + $this->setNextResponse(200, [], 'Hello World', function ($request, $response) { $response->setContent(''); $response->setStatusCode(200); $this->assertEquals('HEAD', $request->getMethod()); }); - $this->request('HEAD', '/', array('HTTP_EXPECT' => 'something ...')); + $this->request('HEAD', '/', ['HTTP_EXPECT' => 'something ...']); $this->assertHttpKernelIsCalled(); $this->assertEquals('', $this->response->getContent()); } public function testUsesCacheToRespondToHeadRequestsWhenFresh() { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { + $this->setNextResponse(200, [], 'Hello World', function ($request, $response) { $response->headers->set('Cache-Control', 'public, max-age=10'); $response->setContent('Hello World'); $response->setStatusCode(200); @@ -1000,7 +1000,7 @@ public function testUsesCacheToRespondToHeadRequestsWhenFresh() public function testSendsNoContentWhenFresh() { $time = \DateTime::createFromFormat('U', time()); - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($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)); }); @@ -1009,7 +1009,7 @@ public function testSendsNoContentWhenFresh() $this->assertHttpKernelIsCalled(); $this->assertEquals('Hello World', $this->response->getContent()); - $this->request('GET', '/', array('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()); @@ -1017,7 +1017,7 @@ public function testSendsNoContentWhenFresh() public function testInvalidatesCachedResponsesOnPost() { - $this->setNextResponse(200, array(), 'Hello World', function ($request, $response) { + $this->setNextResponse(200, [], 'Hello World', function ($request, $response) { if ('GET' == $request->getMethod()) { $response->setStatusCode(200); $response->headers->set('Cache-Control', 'public, max-age=500'); @@ -1066,20 +1066,20 @@ public function testInvalidatesCachedResponsesOnPost() public function testServesFromCacheWhenHeadersMatch() { $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) { + $this->setNextResponse(200, ['Cache-Control' => 'max-age=10000'], '', function ($request, $response) use (&$count) { $response->headers->set('Vary', 'Accept User-Agent Foo'); $response->headers->set('Cache-Control', 'public, max-age=10'); $response->headers->set('X-Response-Count', ++$count); $response->setContent($request->headers->get('USER_AGENT')); }); - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); + $this->request('GET', '/', ['HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Bob/1.0', $this->response->getContent()); $this->assertTraceContains('miss'); $this->assertTraceContains('store'); - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); + $this->request('GET', '/', ['HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Bob/1.0', $this->response->getContent()); $this->assertTraceContains('fresh'); @@ -1090,36 +1090,36 @@ public function testServesFromCacheWhenHeadersMatch() public function testStoresMultipleResponsesWhenHeadersDiffer() { $count = 0; - $this->setNextResponse(200, array('Cache-Control' => 'max-age=10000'), '', function ($request, $response) use (&$count) { + $this->setNextResponse(200, ['Cache-Control' => 'max-age=10000'], '', function ($request, $response) use (&$count) { $response->headers->set('Vary', 'Accept User-Agent Foo'); $response->headers->set('Cache-Control', 'public, max-age=10'); $response->headers->set('X-Response-Count', ++$count); $response->setContent($request->headers->get('USER_AGENT')); }); - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); + $this->request('GET', '/', ['HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertEquals('Bob/1.0', $this->response->getContent()); $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); + $this->request('GET', '/', ['HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0']); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Bob/2.0', $this->response->getContent()); $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0')); + $this->request('GET', '/', ['HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/1.0']); $this->assertTraceContains('fresh'); $this->assertEquals('Bob/1.0', $this->response->getContent()); $this->assertEquals(1, $this->response->headers->get('X-Response-Count')); - $this->request('GET', '/', array('HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0')); + $this->request('GET', '/', ['HTTP_ACCEPT' => 'text/html', 'HTTP_USER_AGENT' => 'Bob/2.0']); $this->assertTraceContains('fresh'); $this->assertEquals('Bob/2.0', $this->response->getContent()); $this->assertEquals(2, $this->response->headers->get('X-Response-Count')); - $this->request('GET', '/', array('HTTP_USER_AGENT' => 'Bob/2.0')); + $this->request('GET', '/', ['HTTP_USER_AGENT' => 'Bob/2.0']); $this->assertTraceContains('miss'); $this->assertEquals('Bob/2.0', $this->response->getContent()); $this->assertEquals(3, $this->response->headers->get('X-Response-Count')); @@ -1141,7 +1141,7 @@ public function testShouldCatchExceptionsWhenReloadingAndNoCacheRequest() $this->setNextResponse(); $this->cacheConfig['allow_reload'] = true; - $this->request('GET', '/', array(), array(), false, array('Pragma' => 'no-cache')); + $this->request('GET', '/', [], [], false, ['Pragma' => 'no-cache']); $this->assertExceptionsAreCaught(); } @@ -1158,30 +1158,30 @@ public function testShouldNotCatchExceptions() public function testEsiCacheSendsTheLowestTtl() { - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => ' ', - 'headers' => array( + 'headers' => [ 'Cache-Control' => 's-maxage=300', 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'Hello World!', - 'headers' => array('Cache-Control' => 's-maxage=200'), - ), - array( + 'headers' => ['Cache-Control' => 's-maxage=200'], + ], + [ 'status' => 200, 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); + 'headers' => ['Cache-Control' => 's-maxage=100'], + ], + ]; $this->setNextResponses($responses); - $this->request('GET', '/', array(), array(), true); + $this->request('GET', '/', [], [], true); $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); $this->assertEquals(100, $this->response->getTtl()); @@ -1189,25 +1189,25 @@ public function testEsiCacheSendsTheLowestTtl() public function testEsiCacheSendsTheLowestTtlForHeadRequests() { - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => 'I am a long-lived master response, but I embed a short-lived resource: ', - 'headers' => array( + 'headers' => [ 'Cache-Control' => 's-maxage=300', 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'I am a short-lived resource', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); + 'headers' => ['Cache-Control' => 's-maxage=100'], + ], + ]; $this->setNextResponses($responses); - $this->request('HEAD', '/', array(), array(), true); + $this->request('HEAD', '/', [], [], true); $this->assertEmpty($this->response->getContent()); $this->assertEquals(100, $this->response->getTtl()); @@ -1215,30 +1215,30 @@ public function testEsiCacheSendsTheLowestTtlForHeadRequests() public function testEsiCacheForceValidation() { - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => ' ', - 'headers' => array( + 'headers' => [ 'Cache-Control' => 's-maxage=300', 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'Hello World!', - 'headers' => array('ETag' => 'foobar'), - ), - array( + 'headers' => ['ETag' => 'foobar'], + ], + [ 'status' => 200, 'body' => 'My name is Bobby.', - 'headers' => array('Cache-Control' => 's-maxage=100'), - ), - ); + 'headers' => ['Cache-Control' => 's-maxage=100'], + ], + ]; $this->setNextResponses($responses); - $this->request('GET', '/', array(), array(), true); + $this->request('GET', '/', [], [], true); $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); $this->assertNull($this->response->getTtl()); $this->assertTrue($this->response->mustRevalidate()); @@ -1248,25 +1248,25 @@ public function testEsiCacheForceValidation() public function testEsiCacheForceValidationForHeadRequests() { - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => 'I am the master response and use expiration caching, but I embed another resource: ', - 'headers' => array( + 'headers' => [ 'Cache-Control' => 's-maxage=300', 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'I am the embedded resource and use validation caching', - 'headers' => array('ETag' => 'foobar'), - ), - ); + 'headers' => ['ETag' => 'foobar'], + ], + ]; $this->setNextResponses($responses); - $this->request('HEAD', '/', array(), array(), true); + $this->request('HEAD', '/', [], [], true); // The response has been assembled from expiration and validation based resources // This can neither be cached nor revalidated, so it should be private/no cache @@ -1279,50 +1279,50 @@ public function testEsiCacheForceValidationForHeadRequests() public function testEsiRecalculateContentLengthHeader() { - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => '', - 'headers' => array( + 'headers' => [ 'Content-Length' => 26, 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'Hello World!', - 'headers' => array(), - ), - ); + 'headers' => [], + ], + ]; $this->setNextResponses($responses); - $this->request('GET', '/', array(), array(), true); + $this->request('GET', '/', [], [], true); $this->assertEquals('Hello World!', $this->response->getContent()); $this->assertEquals(12, $this->response->headers->get('Content-Length')); } public function testEsiRecalculateContentLengthHeaderForHeadRequest() { - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => '', - 'headers' => array( + 'headers' => [ 'Content-Length' => 26, 'Surrogate-Control' => 'content="ESI/1.0"', - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'Hello World!', - 'headers' => array(), - ), - ); + 'headers' => [], + ], + ]; $this->setNextResponses($responses); - $this->request('HEAD', '/', array(), array(), true); + $this->request('HEAD', '/', [], [], true); // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13 // "The Content-Length entity-header field indicates the size of the entity-body, @@ -1336,7 +1336,7 @@ public function testEsiRecalculateContentLengthHeaderForHeadRequest() public function testClientIpIsAlwaysLocalhostForForwardedRequests() { $this->setNextResponse(); - $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); + $this->request('GET', '/', ['REMOTE_ADDR' => '10.0.0.1']); $this->kernel->assert(function ($backendRequest) { $this->assertSame('127.0.0.1', $backendRequest->server->get('REMOTE_ADDR')); @@ -1351,25 +1351,25 @@ public function testHttpCacheIsSetAsATrustedProxy(array $existing) Request::setTrustedProxies($existing, Request::HEADER_X_FORWARDED_ALL); $this->setNextResponse(); - $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); + $this->request('GET', '/', ['REMOTE_ADDR' => '10.0.0.1']); $this->assertSame($existing, Request::getTrustedProxies()); - $existing = array_unique(array_merge($existing, array('127.0.0.1'))); + $existing = array_unique(array_merge($existing, ['127.0.0.1'])); $this->kernel->assert(function ($backendRequest) use ($existing) { $this->assertSame($existing, Request::getTrustedProxies()); $this->assertsame('10.0.0.1', $backendRequest->getClientIp()); }); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } public function getTrustedProxyData() { - return array( - array(array()), - array(array('10.0.0.2')), - array(array('10.0.0.2', '127.0.0.1')), - ); + return [ + [[]], + [['10.0.0.2']], + [['10.0.0.2', '127.0.0.1']], + ]; } /** @@ -1378,7 +1378,7 @@ public function getTrustedProxyData() public function testForwarderHeaderForForwardedRequests($forwarded, $expected) { $this->setNextResponse(); - $server = array('REMOTE_ADDR' => '10.0.0.1'); + $server = ['REMOTE_ADDR' => '10.0.0.1']; if (null !== $forwarded) { Request::setTrustedProxies($server, -1); $server['HTTP_FORWARDED'] = $forwarded; @@ -1389,42 +1389,42 @@ public function testForwarderHeaderForForwardedRequests($forwarded, $expected) $this->assertSame($expected, $backendRequest->headers->get('Forwarded')); }); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } public function getForwardedData() { - return array( - array(null, 'for="10.0.0.1";host="localhost";proto=http'), - array('for=10.0.0.2', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.1"'), - array('for=10.0.0.2, for=10.0.0.3', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.3", for="10.0.0.1"'), - ); + return [ + [null, 'for="10.0.0.1";host="localhost";proto=http'], + ['for=10.0.0.2', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.1"'], + ['for=10.0.0.2, for=10.0.0.3', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.3", for="10.0.0.1"'], + ]; } public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses() { $time = \DateTime::createFromFormat('U', time()); - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => '', - 'headers' => array( + 'headers' => [ 'Surrogate-Control' => 'content="ESI/1.0"', 'ETag' => 'hey', 'Last-Modified' => $time->format(DATE_RFC2822), - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'Hey!', - 'headers' => array(), - ), - ); + 'headers' => [], + ], + ]; $this->setNextResponses($responses); - $this->request('GET', '/', array(), array(), true); + $this->request('GET', '/', [], [], true); $this->assertNull($this->response->getETag()); $this->assertNull($this->response->getLastModified()); } @@ -1433,26 +1433,26 @@ public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponsesAndHeadReq { $time = \DateTime::createFromFormat('U', time()); - $responses = array( - array( + $responses = [ + [ 'status' => 200, 'body' => '', - 'headers' => array( + 'headers' => [ 'Surrogate-Control' => 'content="ESI/1.0"', 'ETag' => 'hey', 'Last-Modified' => $time->format(DATE_RFC2822), - ), - ), - array( + ], + ], + [ 'status' => 200, 'body' => 'Hey!', - 'headers' => array(), - ), - ); + 'headers' => [], + ], + ]; $this->setNextResponses($responses); - $this->request('HEAD', '/', array(), array(), true); + $this->request('HEAD', '/', [], [], true); $this->assertEmpty($this->response->getContent()); $this->assertNull($this->response->getETag()); $this->assertNull($this->response->getLastModified()); @@ -1460,11 +1460,11 @@ public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponsesAndHeadReq public function testDoesNotCacheOptionsRequest() { - $this->setNextResponse(200, array('Cache-Control' => 'public, s-maxage=60'), 'get'); + $this->setNextResponse(200, ['Cache-Control' => 'public, s-maxage=60'], 'get'); $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); - $this->setNextResponse(200, array('Cache-Control' => 'public, s-maxage=60'), 'options'); + $this->setNextResponse(200, ['Cache-Control' => 'public, s-maxage=60'], 'options'); $this->request('OPTIONS', '/'); $this->assertHttpKernelIsCalled(); diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index b3aa2be2f0..1eb4617447 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -41,12 +41,12 @@ protected function setUp() $this->cache = null; $this->esi = null; - $this->caches = array(); - $this->cacheConfig = array(); + $this->caches = []; + $this->cacheConfig = []; $this->request = null; $this->response = null; - $this->responses = array(); + $this->responses = []; $this->catch = false; @@ -112,7 +112,7 @@ public function assertExceptionsAreNotCaught() $this->assertFalse($this->kernel->isCatchingExceptions()); } - public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false, $headers = array()) + public function request($method, $uri = '/', $server = [], $cookies = [], $esi = false, $headers = []) { if (null === $this->kernel) { throw new \LogicException('You must call setNextResponse() before calling request().'); @@ -126,7 +126,7 @@ public function request($method, $uri = '/', $server = array(), $cookies = array $this->esi = $esi ? new Esi() : null; $this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig); - $this->request = Request::create($uri, $method, array(), $cookies, array(), $server); + $this->request = Request::create($uri, $method, [], $cookies, [], $server); $this->request->headers->add($headers); $this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch); @@ -136,7 +136,7 @@ public function request($method, $uri = '/', $server = array(), $cookies = array public function getMetaStorageValues() { - $values = array(); + $values = []; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(sys_get_temp_dir().'/http_cache/md', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { $values[] = file_get_contents($file); } @@ -145,7 +145,7 @@ public function getMetaStorageValues() } // A basic response with 200 status code and a tiny body. - public function setNextResponse($statusCode = 200, array $headers = array(), $body = 'Hello World', \Closure $customizer = null) + public function setNextResponse($statusCode = 200, array $headers = [], $body = 'Hello World', \Closure $customizer = null) { $this->kernel = new TestHttpKernel($body, $statusCode, $headers, $customizer); } @@ -168,7 +168,7 @@ public static function clearDirectory($directory) $fp = opendir($directory); while (false !== $file = readdir($fp)) { - if (!\in_array($file, array('.', '..'))) { + if (!\in_array($file, ['.', '..'])) { if (is_link($directory.'/'.$file)) { unlink($directory.'/'.$file); } elseif (is_dir($directory.'/'.$file)) { diff --git a/Tests/HttpCache/SsiTest.php b/Tests/HttpCache/SsiTest.php index 26ef6cb2b8..2fc0bb9660 100644 --- a/Tests/HttpCache/SsiTest.php +++ b/Tests/HttpCache/SsiTest.php @@ -187,13 +187,13 @@ public function testHandleWhenResponseIsNot200AndAltIsPresent() $response1 = new Response('foo'); $response1->setStatusCode(404); $response2 = new Response('bar'); - $cache = $this->getCache(Request::create('/'), array($response1, $response2)); + $cache = $this->getCache(Request::create('/'), [$response1, $response2]); $this->assertEquals('bar', $ssi->handle($cache, '/', '/alt', false)); } protected function getCache($request, $response) { - $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(array('getRequest', 'handle'))->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\HttpCache')->setMethods(['getRequest', 'handle'])->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('getRequest') ->will($this->returnValue($request)) @@ -201,7 +201,7 @@ protected function getCache($request, $response) if (\is_array($response)) { $cache->expects($this->any()) ->method('handle') - ->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response)) + ->will(\call_user_func_array([$this, 'onConsecutiveCalls'], $response)) ; } else { $cache->expects($this->any()) diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index cef019167a..fc47ff2c88 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -29,7 +29,7 @@ class StoreTest extends TestCase protected function setUp() { $this->request = Request::create('/'); - $this->response = new Response('hello world', 200, array()); + $this->response = new Response('hello world', 200, []); HttpCacheTestCase::clearDirectory(sys_get_temp_dir().'/http_cache'); @@ -108,7 +108,7 @@ public function testFindsAStoredEntryWithLookup() public function testDoesNotFindAnEntryWithLookupWhenNoneExists() { - $request = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); + $request = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); $this->assertNull($this->store->lookup($request)); } @@ -137,7 +137,7 @@ public function testRestoresResponseHeadersProperlyWithLookup() $this->storeSimpleEntry(); $response = $this->store->lookup($this->request); - $this->assertEquals($response->headers->all(), array_merge(array('content-length' => 4, 'x-body-file' => array($this->getStorePath($response->headers->get('X-Content-Digest')))), $this->response->headers->all())); + $this->assertEquals($response->headers->all(), array_merge(['content-length' => 4, 'x-body-file' => [$this->getStorePath($response->headers->get('X-Content-Digest'))]], $this->response->headers->all())); } public function testRestoresResponseContentFromEntityStoreWithLookup() @@ -165,9 +165,9 @@ public function testSucceedsQuietlyWhenInvalidateCalledWithNoMatchingEntries() public function testDoesNotReturnEntriesThatVaryWithLookup() { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res = new Response('test', 200, array('Vary' => 'Foo Bar')); + $req1 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); + $req2 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam']); + $res = new Response('test', 200, ['Vary' => 'Foo Bar']); $this->store->write($req1, $res); $this->assertNull($this->store->lookup($req2)); @@ -175,9 +175,9 @@ public function testDoesNotReturnEntriesThatVaryWithLookup() public function testDoesNotReturnEntriesThatSlightlyVaryWithLookup() { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bam')); - $res = new Response('test', 200, array('Vary' => array('Foo', 'Bar'))); + $req1 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); + $req2 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bam']); + $res = new Response('test', 200, ['Vary' => ['Foo', 'Bar']]); $this->store->write($req1, $res); $this->assertNull($this->store->lookup($req2)); @@ -185,16 +185,16 @@ public function testDoesNotReturnEntriesThatSlightlyVaryWithLookup() public function testStoresMultipleResponsesForEachVaryCombination() { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); + $req1 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); + $res1 = new Response('test 1', 200, ['Vary' => 'Foo Bar']); $key = $this->store->write($req1, $res1); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); + $req2 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam']); + $res2 = new Response('test 2', 200, ['Vary' => 'Foo Bar']); $this->store->write($req2, $res2); - $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Baz', 'HTTP_BAR' => 'Boom')); - $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); + $req3 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Baz', 'HTTP_BAR' => 'Boom']); + $res3 = new Response('test 3', 200, ['Vary' => 'Foo Bar']); $this->store->write($req3, $res3); $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); @@ -206,18 +206,18 @@ public function testStoresMultipleResponsesForEachVaryCombination() public function testOverwritesNonVaryingResponseWithStore() { - $req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res1 = new Response('test 1', 200, array('Vary' => 'Foo Bar')); + $req1 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); + $res1 = new Response('test 1', 200, ['Vary' => 'Foo Bar']); $key = $this->store->write($req1, $res1); $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 1')), $this->store->lookup($req1)->getContent()); - $req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam')); - $res2 = new Response('test 2', 200, array('Vary' => 'Foo Bar')); + $req2 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Bling', 'HTTP_BAR' => 'Bam']); + $res2 = new Response('test 2', 200, ['Vary' => 'Foo Bar']); $this->store->write($req2, $res2); $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 2')), $this->store->lookup($req2)->getContent()); - $req3 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); - $res3 = new Response('test 3', 200, array('Vary' => 'Foo Bar')); + $req3 = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); + $res3 = new Response('test 3', 200, ['Vary' => 'Foo Bar']); $key = $this->store->write($req3, $res3); $this->assertEquals($this->getStorePath('en'.hash('sha256', 'test 3')), $this->store->lookup($req3)->getContent()); @@ -226,7 +226,7 @@ public function testOverwritesNonVaryingResponseWithStore() public function testLocking() { - $req = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar')); + $req = Request::create('/test', 'get', [], [], [], ['HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar']); $this->assertTrue($this->store->lock($req)); $path = $this->store->lock($req); @@ -263,14 +263,14 @@ public function testPurgeHttpAndHttps() $this->assertEmpty($this->getStoreMetadata($requestHttps)); } - protected function storeSimpleEntry($path = null, $headers = array()) + protected function storeSimpleEntry($path = null, $headers = []) { if (null === $path) { $path = '/test'; } - $this->request = Request::create($path, 'get', array(), array(), array(), $headers); - $this->response = new Response('test', 200, array('Cache-Control' => 'max-age=420')); + $this->request = Request::create($path, 'get', [], [], [], $headers); + $this->response = new Response('test', 200, ['Cache-Control' => 'max-age=420']); return $this->store->write($this->request, $this->response); } diff --git a/Tests/HttpCache/SubRequestHandlerTest.php b/Tests/HttpCache/SubRequestHandlerTest.php index dfe0a734bf..67b637bfe3 100644 --- a/Tests/HttpCache/SubRequestHandlerTest.php +++ b/Tests/HttpCache/SubRequestHandlerTest.php @@ -33,7 +33,7 @@ protected function tearDown() public function testTrustedHeadersAreKept() { - Request::setTrustedProxies(array('10.0.0.1'), -1); + Request::setTrustedProxies(['10.0.0.1'], -1); $globalState = $this->getGlobalState(); $request = Request::create('/'); @@ -82,7 +82,7 @@ public function testUntrustedHeadersAreRemoved() public function testTrustedForwardedHeader() { - Request::setTrustedProxies(array('10.0.0.1'), -1); + Request::setTrustedProxies(['10.0.0.1'], -1); $globalState = $this->getGlobalState(); $request = Request::create('/'); @@ -104,7 +104,7 @@ public function testTrustedForwardedHeader() public function testTrustedXForwardedForHeader() { - Request::setTrustedProxies(array('10.0.0.1'), -1); + Request::setTrustedProxies(['10.0.0.1'], -1); $globalState = $this->getGlobalState(); $request = Request::create('/'); @@ -127,10 +127,10 @@ public function testTrustedXForwardedForHeader() private function getGlobalState() { - return array( + return [ Request::getTrustedProxies(), Request::getTrustedHeaderSet(), - ); + ]; } } diff --git a/Tests/HttpCache/TestHttpKernel.php b/Tests/HttpCache/TestHttpKernel.php index 5dbf02c992..304ff9d9e4 100644 --- a/Tests/HttpCache/TestHttpKernel.php +++ b/Tests/HttpCache/TestHttpKernel.php @@ -41,7 +41,7 @@ public function __construct($body, $status, $headers, \Closure $customizer = nul public function assert(\Closure $callback) { - $trustedConfig = array(Request::getTrustedProxies(), Request::getTrustedHeaderSet()); + $trustedConfig = [Request::getTrustedProxies(), Request::getTrustedHeaderSet()]; list($trustedProxies, $trustedHeaderSet, $backendRequest) = $this->backendRequest; Request::setTrustedProxies($trustedProxies, $trustedHeaderSet); @@ -57,7 +57,7 @@ public function assert(\Closure $callback) public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false) { $this->catch = $catch; - $this->backendRequest = array(Request::getTrustedProxies(), Request::getTrustedHeaderSet(), $request); + $this->backendRequest = [Request::getTrustedProxies(), Request::getTrustedHeaderSet(), $request]; return parent::handle($request, $type, $catch); } @@ -69,12 +69,12 @@ public function isCatchingExceptions() public function getController(Request $request) { - return array($this, 'callController'); + return [$this, 'callController']; } public function getArguments(Request $request, $controller) { - return array($request); + return [$request]; } public function callController(Request $request) diff --git a/Tests/HttpCache/TestMultipleHttpKernel.php b/Tests/HttpCache/TestMultipleHttpKernel.php index 712132bd13..010bee8689 100644 --- a/Tests/HttpCache/TestMultipleHttpKernel.php +++ b/Tests/HttpCache/TestMultipleHttpKernel.php @@ -21,9 +21,9 @@ class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface, ArgumentResolverInterface { - protected $bodies = array(); - protected $statuses = array(); - protected $headers = array(); + protected $bodies = []; + protected $statuses = []; + protected $headers = []; protected $called = false; protected $backendRequest; @@ -52,12 +52,12 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ public function getController(Request $request) { - return array($this, 'callController'); + return [$this, 'callController']; } public function getArguments(Request $request, $controller) { - return array($request); + return [$request]; } public function callController(Request $request) diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index 239865a861..939ecc0446 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -104,7 +104,7 @@ public function testHandleHttpException() $event->setResponse(new Response($event->getException()->getMessage())); }); - $kernel = $this->getHttpKernel($dispatcher, function () { throw new MethodNotAllowedHttpException(array('POST')); }); + $kernel = $this->getHttpKernel($dispatcher, function () { throw new MethodNotAllowedHttpException(['POST']); }); $response = $kernel->handle(new Request()); $this->assertEquals('405', $response->getStatusCode()); @@ -119,7 +119,7 @@ public function testLegacyHandleWhenAnExceptionIsHandledWithASpecificStatusCode( { $dispatcher = new EventDispatcher(); $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($responseStatusCode, $expectedStatusCode) { - $event->setResponse(new Response('', $responseStatusCode, array('X-Status-Code' => $expectedStatusCode))); + $event->setResponse(new Response('', $responseStatusCode, ['X-Status-Code' => $expectedStatusCode])); }); $kernel = $this->getHttpKernel($dispatcher, function () { throw new \RuntimeException(); }); @@ -131,12 +131,12 @@ public function testLegacyHandleWhenAnExceptionIsHandledWithASpecificStatusCode( public function getStatusCodes() { - return array( - array(200, 404), - array(404, 200), - array(301, 200), - array(500, 200), - ); + return [ + [200, 404], + [404, 200], + [301, 200], + [500, 200], + ]; } /** @@ -158,11 +158,11 @@ public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($expec public function getSpecificStatusCodes() { - return array( - array(200), - array(302), - array(403), - ); + return [ + [200], + [302], + [403], + ]; } public function testHandleWhenAListenerReturnsAResponse() @@ -216,7 +216,7 @@ public function testHandleWhenTheControllerIsAFunction() public function testHandleWhenTheControllerIsAnArray() { $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, array(new TestController(), 'controller')); + $kernel = $this->getHttpKernel($dispatcher, [new TestController(), 'controller']); $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); } @@ -224,7 +224,7 @@ public function testHandleWhenTheControllerIsAnArray() public function testHandleWhenTheControllerIsAStaticArray() { $dispatcher = new EventDispatcher(); - $kernel = $this->getHttpKernel($dispatcher, array('Symfony\Component\HttpKernel\Tests\TestController', 'staticcontroller')); + $kernel = $this->getHttpKernel($dispatcher, ['Symfony\Component\HttpKernel\Tests\TestController', 'staticcontroller']); $this->assertResponseEquals(new Response('foo'), $kernel->handle(new Request())); } @@ -267,7 +267,7 @@ public function testHandleAllowChangingControllerArguments() { $dispatcher = new EventDispatcher(); $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function (FilterControllerArgumentsEvent $event) { - $event->setArguments(array('foo')); + $event->setArguments(['foo']); }); $kernel = $this->getHttpKernel($dispatcher, function ($content) { return new Response($content); }); @@ -291,12 +291,12 @@ public function testHandleAllowChangingControllerAndArguments() }; $event->setController($newController); - $event->setArguments(array('bar')); + $event->setArguments(['bar']); }); - $kernel = $this->getHttpKernel($dispatcher, function ($content) { return new Response($content); }, null, array('foo')); + $kernel = $this->getHttpKernel($dispatcher, function ($content) { return new Response($content); }, null, ['foo']); - $this->assertResponseEquals(new Response('foo', 200, array('X-Id' => 'bar')), $kernel->handle(new Request())); + $this->assertResponseEquals(new Response('foo', 200, ['X-Id' => 'bar']), $kernel->handle(new Request())); } public function testTerminate() @@ -321,7 +321,7 @@ public function testVerifyRequestStackPushPopDuringHandle() { $request = new Request(); - $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('push', 'pop'))->getMock(); + $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'); @@ -337,7 +337,7 @@ public function testVerifyRequestStackPushPopDuringHandle() public function testInconsistentClientIpsOnMasterRequests() { $request = new Request(); - $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); + $request->setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); $request->server->set('REMOTE_ADDR', '1.1.1.1'); $request->headers->set('FORWARDED', 'for=2.2.2.2'); $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); @@ -350,10 +350,10 @@ public function testInconsistentClientIpsOnMasterRequests() $kernel = $this->getHttpKernel($dispatcher); $kernel->handle($request, $kernel::MASTER_REQUEST, false); - Request::setTrustedProxies(array(), -1); + Request::setTrustedProxies([], -1); } - private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = array()) + private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = []) { if (null === $controller) { $controller = function () { return new Response('Hello'); }; diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index ab0b8cfb6e..208e11e182 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -92,7 +92,7 @@ public function testInitializeContainerClearsOldContainers() public function testBootInitializesBundlesAndContainer() { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); + $kernel = $this->getKernel(['initializeBundles', 'initializeContainer']); $kernel->expects($this->once()) ->method('initializeBundles'); $kernel->expects($this->once()) @@ -107,10 +107,10 @@ public function testBootSetsTheContainerToTheBundles() $bundle->expects($this->once()) ->method('setContainer'); - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'getBundles')); + $kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'getBundles']); $kernel->expects($this->once()) ->method('getBundles') - ->will($this->returnValue(array($bundle))); + ->will($this->returnValue([$bundle])); $kernel->boot(); } @@ -118,7 +118,7 @@ public function testBootSetsTheContainerToTheBundles() public function testBootSetsTheBootedFlagToTrue() { // use test kernel to access isBooted() - $kernel = $this->getKernelForTest(array('initializeBundles', 'initializeContainer')); + $kernel = $this->getKernelForTest(['initializeBundles', 'initializeContainer']); $kernel->boot(); $this->assertTrue($kernel->isBooted()); @@ -129,7 +129,7 @@ public function testBootSetsTheBootedFlagToTrue() */ public function testClassCacheIsLoaded() { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); + $kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'doLoadClassCache']); $kernel->loadClassCache('name', '.extension'); $kernel->expects($this->once()) ->method('doLoadClassCache') @@ -140,7 +140,7 @@ public function testClassCacheIsLoaded() public function testClassCacheIsNotLoadedByDefault() { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); + $kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'doLoadClassCache']); $kernel->expects($this->never()) ->method('doLoadClassCache'); @@ -152,7 +152,7 @@ public function testClassCacheIsNotLoadedByDefault() */ public function testClassCacheIsNotLoadedWhenKernelIsNotBooted() { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); + $kernel = $this->getKernel(['initializeBundles', 'initializeContainer', 'doLoadClassCache']); $kernel->loadClassCache(); $kernel->expects($this->never()) ->method('doLoadClassCache'); @@ -163,7 +163,7 @@ public function testEnvParametersResourceIsAdded() $container = new ContainerBuilder(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') ->disableOriginalConstructor() - ->setMethods(array('getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir')) + ->setMethods(['getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir']) ->getMock(); $kernel->expects($this->any()) ->method('getContainerBuilder') @@ -196,7 +196,7 @@ public function testEnvParametersResourceIsAdded() public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() { - $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); + $kernel = $this->getKernel(['initializeBundles', 'initializeContainer']); $kernel->expects($this->once()) ->method('initializeBundles'); @@ -210,7 +210,7 @@ public function testShutdownCallsShutdownOnAllBundles() $bundle->expects($this->once()) ->method('shutdown'); - $kernel = $this->getKernel(array(), array($bundle)); + $kernel = $this->getKernel([], [$bundle]); $kernel->boot(); $kernel->shutdown(); @@ -223,10 +223,10 @@ public function testShutdownGivesNullContainerToAllBundles() ->method('setContainer') ->with(null); - $kernel = $this->getKernel(array('getBundles')); + $kernel = $this->getKernel(['getBundles']); $kernel->expects($this->any()) ->method('getBundles') - ->will($this->returnValue(array($bundle))); + ->will($this->returnValue([$bundle])); $kernel->boot(); $kernel->shutdown(); @@ -246,7 +246,7 @@ public function testHandleCallsHandleOnHttpKernel() ->method('handle') ->with($request, $type, $catch); - $kernel = $this->getKernel(array('getHttpKernel')); + $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -264,7 +264,7 @@ public function testHandleBootsTheKernel() ->disableOriginalConstructor() ->getMock(); - $kernel = $this->getKernel(array('getHttpKernel', 'boot')); + $kernel = $this->getKernel(['getHttpKernel', 'boot']); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -384,7 +384,7 @@ public function testSerialize() $debug = true; $kernel = new KernelForTest($env, $debug); - $expected = serialize(array($env, $debug)); + $expected = serialize([$env, $debug]); $this->assertEquals($expected, $kernel->serialize()); } @@ -417,11 +417,11 @@ public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() */ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) ; $kernel->locateResource('@Bundle1Bundle/config/routing.xml'); @@ -429,11 +429,11 @@ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() public function testLocateResourceReturnsTheFirstThatMatches() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) ; $this->assertEquals(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt', $kernel->locateResource('@Bundle1Bundle/foo.txt')); @@ -447,11 +447,11 @@ public function testLocateResourceReturnsTheFirstThatMatchesWithParent() $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) + ->will($this->returnValue([$child, $parent])) ; $this->assertEquals(__DIR__.'/Fixtures/Bundle2Bundle/foo.txt', $kernel->locateResource('@ParentAABundle/foo.txt')); @@ -466,16 +466,16 @@ public function testLocateResourceReturnsAllMatches() $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) + ->will($this->returnValue([$child, $parent])) ; - $this->assertEquals(array( + $this->assertEquals([ __DIR__.'/Fixtures/Bundle2Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', ), + __DIR__.'/Fixtures/Bundle1Bundle/foo.txt', ], $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)); } @@ -484,29 +484,29 @@ public function testLocateResourceReturnsAllMatches() */ public function testLocateResourceReturnsAllMatchesBis() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array( + ->will($this->returnValue([ $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), $this->getBundle(__DIR__.'/Foobar'), - ))) + ])) ; $this->assertEquals( - array(__DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), + [__DIR__.'/Fixtures/Bundle1Bundle/foo.txt'], $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false) ); } public function testLocateResourceIgnoresDirOnNonResource() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle')])) ; $this->assertEquals( @@ -517,11 +517,11 @@ public function testLocateResourceIgnoresDirOnNonResource() public function testLocateResourceReturnsTheDirOneForResources() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')])) ; $this->assertEquals( @@ -535,16 +535,16 @@ public function testLocateResourceReturnsTheDirOneForResources() */ public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->once()) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')])) ; - $this->assertEquals(array( + $this->assertEquals([ __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt', ), + __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt', ], $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) ); } @@ -557,18 +557,18 @@ public function testLocateResourceOverrideBundleAndResourcesFolders() $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle'); $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle'); - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->exactly(4)) ->method('getBundle') - ->will($this->returnValue(array($child, $parent))) + ->will($this->returnValue([$child, $parent])) ; - $this->assertEquals(array( + $this->assertEquals([ __DIR__.'/Fixtures/Resources/ChildBundle/foo.txt', __DIR__.'/Fixtures/ChildBundle/Resources/foo.txt', __DIR__.'/Fixtures/BaseBundle/Resources/foo.txt', - ), + ], $kernel->locateResource('@BaseBundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) ); @@ -592,11 +592,11 @@ public function testLocateResourceOverrideBundleAndResourcesFolders() public function testLocateResourceOnDirectories() { - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/FooBundle', null, null, 'FooBundle')])) ; $this->assertEquals( @@ -608,11 +608,11 @@ public function testLocateResourceOnDirectories() $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources') ); - $kernel = $this->getKernel(array('getBundle')); + $kernel = $this->getKernel(['getBundle']); $kernel ->expects($this->exactly(2)) ->method('getBundle') - ->will($this->returnValue(array($this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')))) + ->will($this->returnValue([$this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle', null, null, 'Bundle1Bundle')])) ; $this->assertEquals( @@ -634,16 +634,16 @@ public function testInitializeBundles() $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); + $kernel = $this->getKernelForTest(['registerBundles']); $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue(array($parent, $child))) + ->will($this->returnValue([$parent, $child])) ; $kernel->boot(); $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent), $map['ParentABundle']); + $this->assertEquals([$child, $parent], $map['ParentABundle']); } /** @@ -656,18 +656,18 @@ public function testInitializeBundlesSupportInheritanceCascade() $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); + $kernel = $this->getKernelForTest(['registerBundles']); $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue(array($grandparent, $parent, $child))) + ->will($this->returnValue([$grandparent, $parent, $child])) ; $kernel->boot(); $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']); - $this->assertEquals(array($child, $parent), $map['ParentBBundle']); - $this->assertEquals(array($child), $map['ChildBBundle']); + $this->assertEquals([$child, $parent, $grandparent], $map['GrandParentBBundle']); + $this->assertEquals([$child, $parent], $map['ParentBBundle']); + $this->assertEquals([$child], $map['ChildBBundle']); } /** @@ -678,7 +678,7 @@ public function testInitializeBundlesSupportInheritanceCascade() public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists() { $child = $this->getBundle(null, 'FooBar', 'ChildCBundle'); - $kernel = $this->getKernel(array(), array($child)); + $kernel = $this->getKernel([], [$child]); $kernel->boot(); } @@ -692,18 +692,18 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle'); // use test kernel so we can access getBundleMap() - $kernel = $this->getKernelForTest(array('registerBundles')); + $kernel = $this->getKernelForTest(['registerBundles']); $kernel ->expects($this->once()) ->method('registerBundles') - ->will($this->returnValue(array($parent, $grandparent, $child))) + ->will($this->returnValue([$parent, $grandparent, $child])) ; $kernel->boot(); $map = $kernel->getBundleMap(); - $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCBundle']); - $this->assertEquals(array($child, $parent), $map['ParentCBundle']); - $this->assertEquals(array($child), $map['ChildCBundle']); + $this->assertEquals([$child, $parent, $grandparent], $map['GrandParentCBundle']); + $this->assertEquals([$child, $parent], $map['ParentCBundle']); + $this->assertEquals([$child], $map['ChildCBundle']); } /** @@ -717,7 +717,7 @@ public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtende $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle'); $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle'); - $kernel = $this->getKernel(array(), array($parent, $child1, $child2)); + $kernel = $this->getKernel([], [$parent, $child1, $child2]); $kernel->boot(); } @@ -731,7 +731,7 @@ public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWith $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); - $kernel = $this->getKernel(array(), array($fooBundle, $barBundle)); + $kernel = $this->getKernel([], [$fooBundle, $barBundle]); $kernel->boot(); } @@ -744,13 +744,13 @@ public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself() { $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle'); - $kernel = $this->getKernel(array(), array($circularRef)); + $kernel = $this->getKernel([], [$circularRef]); $kernel->boot(); } public function testTerminateReturnsSilentlyIfKernelIsNotBooted() { - $kernel = $this->getKernel(array('getHttpKernel')); + $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->never()) ->method('getHttpKernel'); @@ -762,7 +762,7 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() // does not implement TerminableInterface $httpKernel = new TestKernel(); - $kernel = $this->getKernel(array('getHttpKernel')); + $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->once()) ->method('getHttpKernel') ->willReturn($httpKernel); @@ -775,14 +775,14 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() // implements TerminableInterface $httpKernelMock = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernel') ->disableOriginalConstructor() - ->setMethods(array('terminate')) + ->setMethods(['terminate']) ->getMock(); $httpKernelMock ->expects($this->once()) ->method('terminate'); - $kernel = $this->getKernel(array('getHttpKernel')); + $kernel = $this->getKernel(['getHttpKernel']); $kernel->expects($this->exactly(2)) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -882,7 +882,7 @@ public function testServicesResetter() $container->addCompilerPass(new ResettableServicePass()); $container->register('one', ResettableService::class) ->setPublic(true) - ->addTag('kernel.reset', array('method' => 'reset')); + ->addTag('kernel.reset', ['method' => 'reset']); $container->register('services_resetter', ServicesResetter::class)->setPublic(true); }, $httpKernelMock, 'resetting'); @@ -906,7 +906,7 @@ public function testServicesResetter() */ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() { - $kernel = $this->getKernelForTest(array('initializeBundles'), true); + $kernel = $this->getKernelForTest(['initializeBundles'], true); $kernel->boot(); $preReBoot = $kernel->getStartTime(); @@ -925,7 +925,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu { $bundle = $this ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') - ->setMethods(array('getPath', 'getParent', 'getName')) + ->setMethods(['getPath', 'getParent', 'getName']) ->disableOriginalConstructor() ; @@ -964,14 +964,14 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu * * @return Kernel */ - protected function getKernel(array $methods = array(), array $bundles = array()) + protected function getKernel(array $methods = [], array $bundles = []) { $methods[] = 'registerBundles'; $kernel = $this ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') ->setMethods($methods) - ->setConstructorArgs(array('test', false)) + ->setConstructorArgs(['test', false]) ->getMockForAbstractClass() ; $kernel->expects($this->any()) @@ -985,10 +985,10 @@ protected function getKernel(array $methods = array(), array $bundles = array()) return $kernel; } - protected function getKernelForTest(array $methods = array(), $debug = false) + protected function getKernelForTest(array $methods = [], $debug = false) { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setConstructorArgs(array('test', $debug)) + ->setConstructorArgs(['test', $debug]) ->setMethods($methods) ->getMock(); $p = new \ReflectionProperty($kernel, 'rootDir'); @@ -1030,7 +1030,7 @@ public function __construct(\Closure $buildContainer = null, HttpKernelInterface public function registerBundles() { - return array(); + return []; } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/Tests/Log/LoggerTest.php b/Tests/Log/LoggerTest.php index a5d070c8a7..7354000b16 100644 --- a/Tests/Log/LoggerTest.php +++ b/Tests/Log/LoggerTest.php @@ -72,39 +72,39 @@ public function testImplements() */ public function testLogsAtAllLevels($level, $message) { - $this->logger->{$level}($message, array('user' => 'Bob')); - $this->logger->log($level, $message, array('user' => 'Bob')); + $this->logger->{$level}($message, ['user' => 'Bob']); + $this->logger->log($level, $message, ['user' => 'Bob']); - $expected = array( + $expected = [ "[$level] message of level $level with context: Bob", "[$level] message of level $level with context: Bob", - ); + ]; $this->assertLogsMatch($expected, $this->getLogs()); } public function provideLevelsAndMessages() { - return array( - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), - ); + return [ + LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'], + LogLevel::ALERT => [LogLevel::ALERT, 'message of level alert with context: {user}'], + LogLevel::CRITICAL => [LogLevel::CRITICAL, 'message of level critical with context: {user}'], + LogLevel::ERROR => [LogLevel::ERROR, 'message of level error with context: {user}'], + LogLevel::WARNING => [LogLevel::WARNING, 'message of level warning with context: {user}'], + LogLevel::NOTICE => [LogLevel::NOTICE, 'message of level notice with context: {user}'], + LogLevel::INFO => [LogLevel::INFO, 'message of level info with context: {user}'], + LogLevel::DEBUG => [LogLevel::DEBUG, 'message of level debug with context: {user}'], + ]; } public function testLogLevelDisabled() { $this->logger = new Logger(LogLevel::INFO, $this->tmpFile); - $this->logger->debug('test', array('user' => 'Bob')); - $this->logger->log(LogLevel::DEBUG, 'test', array('user' => 'Bob')); + $this->logger->debug('test', ['user' => 'Bob']); + $this->logger->log(LogLevel::DEBUG, 'test', ['user' => 'Bob']); // Will always be true, but asserts than an exception isn't thrown - $this->assertSame(array(), $this->getLogs()); + $this->assertSame([], $this->getLogs()); } /** @@ -134,18 +134,18 @@ public function testInvalidOutput() public function testContextReplacement() { $logger = $this->logger; - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); + $logger->info('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']); - $expected = array('[info] {Message {nothing} Bob Bar a}'); + $expected = ['[info] {Message {nothing} Bob Bar a}']; $this->assertLogsMatch($expected, $this->getLogs()); } public function testObjectCastToString() { if (method_exists($this, 'createPartialMock')) { - $dummy = $this->createPartialMock(DummyTest::class, array('__toString')); + $dummy = $this->createPartialMock(DummyTest::class, ['__toString']); } else { - $dummy = $this->getMock(DummyTest::class, array('__toString')); + $dummy = $this->getMock(DummyTest::class, ['__toString']); } $dummy->expects($this->atLeastOnce()) ->method('__toString') @@ -153,54 +153,54 @@ public function testObjectCastToString() $this->logger->warning($dummy); - $expected = array('[warning] DUMMY'); + $expected = ['[warning] DUMMY']; $this->assertLogsMatch($expected, $this->getLogs()); } public function testContextCanContainAnything() { - $context = array( + $context = [ 'bool' => true, 'null' => null, 'string' => 'Foo', 'int' => 0, 'float' => 0.5, - 'nested' => array('with object' => new DummyTest()), + 'nested' => ['with object' => new DummyTest()], 'object' => new \DateTime(), 'resource' => fopen('php://memory', 'r'), - ); + ]; $this->logger->warning('Crazy context data', $context); - $expected = array('[warning] Crazy context data'); + $expected = ['[warning] Crazy context data']; $this->assertLogsMatch($expected, $this->getLogs()); } public function testContextExceptionKeyCanBeExceptionOrOtherValues() { $logger = $this->logger; - $logger->warning('Random message', array('exception' => 'oops')); - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); + $logger->warning('Random message', ['exception' => 'oops']); + $logger->critical('Uncaught Exception!', ['exception' => new \LogicException('Fail')]); - $expected = array( + $expected = [ '[warning] Random message', '[critical] Uncaught Exception!', - ); + ]; $this->assertLogsMatch($expected, $this->getLogs()); } public function testFormatter() { $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile, function ($level, $message, $context) { - return json_encode(array('level' => $level, 'message' => $message, 'context' => $context)).\PHP_EOL; + return json_encode(['level' => $level, 'message' => $message, 'context' => $context]).\PHP_EOL; }); - $this->logger->error('An error', array('foo' => 'bar')); - $this->logger->warning('A warning', array('baz' => 'bar')); - $this->assertSame(array( + $this->logger->error('An error', ['foo' => 'bar']); + $this->logger->warning('A warning', ['baz' => 'bar']); + $this->assertSame([ '{"level":"error","message":"An error","context":{"foo":"bar"}}', '{"level":"warning","message":"A warning","context":{"baz":"bar"}}', - ), $this->getLogs()); + ], $this->getLogs()); } } diff --git a/Tests/Logger.php b/Tests/Logger.php index 63c70bf67a..8ae756132c 100644 --- a/Tests/Logger.php +++ b/Tests/Logger.php @@ -29,59 +29,59 @@ public function getLogs($level = false) public function clear() { - $this->logs = array( - 'emergency' => array(), - 'alert' => array(), - 'critical' => array(), - 'error' => array(), - 'warning' => array(), - 'notice' => array(), - 'info' => array(), - 'debug' => array(), - ); + $this->logs = [ + 'emergency' => [], + 'alert' => [], + 'critical' => [], + 'error' => [], + 'warning' => [], + 'notice' => [], + 'info' => [], + 'debug' => [], + ]; } - public function log($level, $message, array $context = array()) + public function log($level, $message, array $context = []) { $this->logs[$level][] = $message; } - public function emergency($message, array $context = array()) + public function emergency($message, array $context = []) { $this->log('emergency', $message, $context); } - public function alert($message, array $context = array()) + public function alert($message, array $context = []) { $this->log('alert', $message, $context); } - public function critical($message, array $context = array()) + public function critical($message, array $context = []) { $this->log('critical', $message, $context); } - public function error($message, array $context = array()) + public function error($message, array $context = []) { $this->log('error', $message, $context); } - public function warning($message, array $context = array()) + public function warning($message, array $context = []) { $this->log('warning', $message, $context); } - public function notice($message, array $context = array()) + public function notice($message, array $context = []) { $this->log('notice', $message, $context); } - public function info($message, array $context = array()) + public function info($message, array $context = []) { $this->log('info', $message, $context); } - public function debug($message, array $context = array()) + public function debug($message, array $context = []) { $this->log('debug', $message, $context); } diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index a1db1d9c0e..1cc05e41ec 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -226,7 +226,7 @@ public function testRetrieveByEmptyUrlAndIp() public function testRetrieveByMethodAndLimit() { - foreach (array('POST', 'GET') as $method) { + foreach (['POST', 'GET'] as $method) { for ($i = 0; $i < 5; ++$i) { $profile = new Profile('token_'.$i.$method); $profile->setMethod($method); @@ -293,8 +293,8 @@ public function testStatusCode() $tokens = $this->storage->find('', '', 10, ''); $this->assertCount(2, $tokens); - $this->assertContains($tokens[0]['status_code'], array(200, 404)); - $this->assertContains($tokens[1]['status_code'], array(200, 404)); + $this->assertContains($tokens[0]['status_code'], [200, 404]); + $this->assertContains($tokens[1]['status_code'], [200, 404]); } public function testMultiRowIndexFile() diff --git a/Tests/Profiler/ProfilerTest.php b/Tests/Profiler/ProfilerTest.php index cff133c1aa..8f12e013a4 100644 --- a/Tests/Profiler/ProfilerTest.php +++ b/Tests/Profiler/ProfilerTest.php @@ -44,7 +44,7 @@ public function testCollect() public function testReset() { $collector = $this->getMockBuilder(DataCollectorInterface::class) - ->setMethods(array('collect', 'getName', 'reset')) + ->setMethods(['collect', 'getName', 'reset']) ->getMock(); $collector->expects($this->any())->method('getName')->willReturn('mock'); $collector->expects($this->once())->method('reset'); diff --git a/Tests/TestHttpKernel.php b/Tests/TestHttpKernel.php index fb95aa033b..27ba2d6f89 100644 --- a/Tests/TestHttpKernel.php +++ b/Tests/TestHttpKernel.php @@ -27,12 +27,12 @@ public function __construct() public function getController(Request $request) { - return array($this, 'callController'); + return [$this, 'callController']; } public function getArguments(Request $request, $controller) { - return array($request); + return [$request]; } public function callController(Request $request) diff --git a/UriSigner.php b/UriSigner.php index 63d1a0856f..481270da51 100644 --- a/UriSigner.php +++ b/UriSigner.php @@ -47,7 +47,7 @@ public function sign($uri) if (isset($url['query'])) { parse_str($url['query'], $params); } else { - $params = array(); + $params = []; } $uri = $this->buildUrl($url, $params); @@ -69,7 +69,7 @@ public function check($uri) if (isset($url['query'])) { parse_str($url['query'], $params); } else { - $params = array(); + $params = []; } if (empty($params[$this->parameter])) { @@ -87,7 +87,7 @@ private function computeHash($uri) return base64_encode(hash_hmac('sha256', $uri, $this->secret, true)); } - private function buildUrl(array $url, array $params = array()) + private function buildUrl(array $url, array $params = []) { ksort($params, SORT_STRING); $url['query'] = http_build_query($params, '', '&'); From 136c10ae0fe40ce31657a116ef266bac63e84cbd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 16 Jan 2019 14:03:22 +0100 Subject: [PATCH 137/294] fixed short array CS in comments --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 50413ce4ed..758e9043da 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -216,7 +216,7 @@ private function getControllerError($callable) } if (2 !== \count($callable)) { - return 'Invalid format for controller, expected array(controller, method) or controller::method.'; + return 'Invalid format for controller, expected [controller, method] or controller::method.'; } list($controller, $method) = $callable; From fa661e1ff285ad6fc60668f8da686d7ae90ee124 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 16 Jan 2019 23:54:03 +0100 Subject: [PATCH 138/294] ensure compatibility with older PHPUnit mocks --- Tests/EventListener/ProfilerListenerTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Tests/EventListener/ProfilerListenerTest.php b/Tests/EventListener/ProfilerListenerTest.php index 526b3aa75d..392aa2fc35 100644 --- a/Tests/EventListener/ProfilerListenerTest.php +++ b/Tests/EventListener/ProfilerListenerTest.php @@ -19,6 +19,7 @@ use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\HttpKernel\Profiler\Profile; class ProfilerListenerTest extends TestCase { @@ -27,9 +28,7 @@ class ProfilerListenerTest extends TestCase */ public function testKernelTerminate() { - $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') - ->disableOriginalConstructor() - ->getMock(); + $profile = new Profile('token'); $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() From da8c454936202c2c1a22884d9d4c6cc19b76b969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vasseur?= Date: Wed, 23 Jan 2019 13:42:58 +0100 Subject: [PATCH 139/294] Fix HttpKernel Debug requirement --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9ad3877ba1..f47f1162d1 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "^5.5.9|>=7.0.8", "symfony/event-dispatcher": "~2.8|~3.0|~4.0", "symfony/http-foundation": "~3.4.12|~4.0.12|^4.1.1", - "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/debug": "^3.3.3|~4.0", "symfony/polyfill-ctype": "~1.8", "psr/log": "~1.0" }, From de76e4c6c1ce5b08c896945eaa93294d89766295 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 29 Jan 2019 11:03:44 +0100 Subject: [PATCH 140/294] [HttpKernel] fix nested calls to serialize when using DataCollector --- DataCollector/DataCollector.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index de19678a30..4346e0ec0f 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -42,12 +42,15 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable public function serialize() { - return serialize($this->data); + $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); } public function unserialize($data) { - $this->data = unserialize($data); + $this->data = \is_array($data) ? $data : unserialize($data); } /** From 0d3534bc4d01c64547c7228160ce7bd81b2d560b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Jan 2019 10:03:33 +0100 Subject: [PATCH 141/294] Mark some/most implementations of Serializable as `@internal` --- Config/EnvParametersResource.php | 6 ++++++ DataCollector/DataCollector.php | 6 ++++++ Debug/FileLinkFormatter.php | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/Config/EnvParametersResource.php b/Config/EnvParametersResource.php index a5be98ee81..26869ced2f 100644 --- a/Config/EnvParametersResource.php +++ b/Config/EnvParametersResource.php @@ -65,11 +65,17 @@ public function isFresh($timestamp) return $this->findVariables() === $this->variables; } + /** + * @internal + */ public function serialize() { return serialize(['prefix' => $this->prefix, 'variables' => $this->variables]); } + /** + * @internal + */ public function unserialize($serialized) { if (\PHP_VERSION_ID >= 70000) { diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 4346e0ec0f..4a257ff5f8 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -40,6 +40,9 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable */ private $cloner; + /** + * @internal + */ public function serialize() { $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); @@ -48,6 +51,9 @@ public function serialize() return $isCalledFromOverridingMethod ? $this->data : serialize($this->data); } + /** + * @internal + */ public function unserialize($data) { $this->data = \is_array($data) ? $data : unserialize($data); diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index 8a4aa62b74..af65f7ec57 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -61,11 +61,17 @@ public function format($file, $line) return false; } + /** + * @internal + */ public function serialize() { return serialize($this->getFileLinkFormat()); } + /** + * @internal + */ public function unserialize($serialized) { if (\PHP_VERSION_ID >= 70000) { From 798807fdb9bbd3918b58f70cc513fae96246a629 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Jan 2019 12:43:38 +0100 Subject: [PATCH 142/294] Add missing `@internal` annotations --- DataCollector/DumpDataCollector.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 27197226de..e25e4fb37d 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -176,6 +176,9 @@ public function reset() $this->clonesIndex = 0; } + /** + * @internal + */ public function serialize() { if ($this->clonesCount !== $this->clonesIndex) { @@ -195,9 +198,12 @@ public function serialize() return $ser; } + /** + * @internal + */ public function unserialize($data) { - parent::unserialize($data); + $this->data = unserialize($data); $charset = array_pop($this->data); $fileLinkFormat = array_pop($this->data); $this->dataCount = \count($this->data); From dc6bf17684b7120f7bf74fae85c9155506041002 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 3 Feb 2019 13:22:50 +0100 Subject: [PATCH 143/294] updated VERSION for 3.4.22 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 66a3fba2e1..54bcfd1719 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.22-DEV'; + const VERSION = '3.4.22'; const VERSION_ID = 30422; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 22; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From d1be4b488e3dc50441ef08da757cc74bc03321d6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 3 Feb 2019 13:46:56 +0100 Subject: [PATCH 144/294] bumped Symfony version to 3.4.23 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 54bcfd1719..c97924b778 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.22'; - const VERSION_ID = 30422; + const VERSION = '3.4.23-DEV'; + const VERSION_ID = 30423; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 22; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 23; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From fac54687148b1875d78599e1d35dd77a6df7079d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 8 Feb 2019 13:25:22 +0100 Subject: [PATCH 145/294] Remove "internal" annotation from datacollector serialization methods --- DataCollector/DataCollector.php | 6 ------ DataCollector/DumpDataCollector.php | 6 ------ 2 files changed, 12 deletions(-) diff --git a/DataCollector/DataCollector.php b/DataCollector/DataCollector.php index 4a257ff5f8..4346e0ec0f 100644 --- a/DataCollector/DataCollector.php +++ b/DataCollector/DataCollector.php @@ -40,9 +40,6 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable */ private $cloner; - /** - * @internal - */ public function serialize() { $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); @@ -51,9 +48,6 @@ public function serialize() return $isCalledFromOverridingMethod ? $this->data : serialize($this->data); } - /** - * @internal - */ public function unserialize($data) { $this->data = \is_array($data) ? $data : unserialize($data); diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index e25e4fb37d..4266b22fec 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -176,9 +176,6 @@ public function reset() $this->clonesIndex = 0; } - /** - * @internal - */ public function serialize() { if ($this->clonesCount !== $this->clonesIndex) { @@ -198,9 +195,6 @@ public function serialize() return $ser; } - /** - * @internal - */ public function unserialize($data) { $this->data = unserialize($data); From eafa57eada9552e40facccf4e7e6605c6d19adcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 21 Feb 2019 12:47:58 +0100 Subject: [PATCH 146/294] [HttpKernel] Fix possible infinite loop of exceptions --- EventListener/ExceptionListener.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/EventListener/ExceptionListener.php b/EventListener/ExceptionListener.php index 67db029af1..e7e36d188b 100644 --- a/EventListener/ExceptionListener.php +++ b/EventListener/ExceptionListener.php @@ -56,13 +56,12 @@ public function onKernelException(GetResponseForExceptionEvent $event) } catch (\Exception $e) { $this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', \get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())); - $wrapper = $e; - - while ($prev = $wrapper->getPrevious()) { + $prev = $e; + do { if ($exception === $wrapper = $prev) { throw $e; } - } + } while ($prev = $wrapper->getPrevious()); $prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous'); $prev->setAccessible(true); From 75f38d1502564cc9509bd0103a5cb390dc30520b Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 22 Feb 2019 14:34:02 +0100 Subject: [PATCH 147/294] be keen to newcomers --- Fragment/InlineFragmentRenderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fragment/InlineFragmentRenderer.php b/Fragment/InlineFragmentRenderer.php index 73defb9d3e..ce88bd45de 100644 --- a/Fragment/InlineFragmentRenderer.php +++ b/Fragment/InlineFragmentRenderer.php @@ -80,7 +80,7 @@ public function render($uri, Request $request, array $options = []) return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false); } catch (\Exception $e) { // we dispatch the exception event to trigger the logging - // the response that comes back is simply ignored + // the response that comes back is ignored if (isset($options['ignore_errors']) && $options['ignore_errors'] && $this->dispatcher) { $event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::SUB_REQUEST, $e); From 8a7452f406fb9c0bfaaae1b62e5ce545ea31b6fb Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 23 Feb 2019 16:06:07 +0100 Subject: [PATCH 148/294] Apply php-cs-fixer rule for array_key_exists() --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 758e9043da..e657f61430 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -131,7 +131,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete $attributes = $request->attributes->all(); $arguments = []; foreach ($parameters as $param) { - if (array_key_exists($param->name, $attributes)) { + if (\array_key_exists($param->name, $attributes)) { if ($this->supportsVariadic && $param->isVariadic() && \is_array($attributes[$param->name])) { $arguments = array_merge($arguments, array_values($attributes[$param->name])); } else { From 601caa2afbdd8327b42b1b9226afcc76350b8e5d Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Wed, 14 Mar 2018 17:46:26 +0700 Subject: [PATCH 149/294] [HttpKernel] Correctly merging cache directives in HttpCache/ResponseCacheStrategy --- HttpCache/ResponseCacheStrategy.php | 198 ++++++++++++--- Tests/HttpCache/ResponseCacheStrategyTest.php | 229 ++++++++++++++++++ 2 files changed, 391 insertions(+), 36 deletions(-) diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 168e9564b0..862bac557d 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -5,10 +5,6 @@ * * (c) Fabien Potencier * - * This code is partially based on the Rack-Cache library by Ryan Tomayko, - * which is released under the MIT license. - * (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801) - * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -28,30 +24,69 @@ */ class ResponseCacheStrategy implements ResponseCacheStrategyInterface { - private $cacheable = true; + /** + * 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']; + + /** + * Cache-Control headers that are sent to the final response if they appear in ALL of the responses. + */ + private static $inheritDirectives = ['public', 'immutable']; + private $embeddedResponses = 0; - private $ttls = []; - private $maxAges = []; private $isNotCacheableResponseEmbedded = false; + private $age = 0; + private $flagDirectives = [ + 'no-cache' => null, + 'no-store' => null, + 'no-transform' => null, + 'must-revalidate' => null, + 'proxy-revalidate' => null, + 'public' => null, + 'private' => null, + 'immutable' => null, + ]; + private $ageDirectives = [ + 'max-age' => null, + 's-maxage' => null, + 'expires' => null, + ]; /** * {@inheritdoc} */ public function add(Response $response) { - if (!$response->isFresh() || !$response->isCacheable()) { - $this->cacheable = false; - } else { - $maxAge = $response->getMaxAge(); - $this->ttls[] = $response->getTtl(); - $this->maxAges[] = $maxAge; - - if (null === $maxAge) { - $this->isNotCacheableResponseEmbedded = true; + ++$this->embeddedResponses; + + foreach (self::$overrideDirectives as $directive) { + if ($response->headers->hasCacheControlDirective($directive)) { + $this->flagDirectives[$directive] = true; } } - ++$this->embeddedResponses; + foreach (self::$inheritDirectives as $directive) { + if (false !== $this->flagDirectives[$directive]) { + $this->flagDirectives[$directive] = $response->headers->hasCacheControlDirective($directive); + } + } + + $age = $response->getAge(); + $this->age = max($this->age, $age); + + if ($this->willMakeFinalResponseUncacheable($response)) { + $this->isNotCacheableResponseEmbedded = true; + + 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); + + $expires = $response->getExpires(); + $expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null; + $this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0); } /** @@ -64,33 +99,124 @@ public function update(Response $response) return; } - // Remove validation related headers in order to avoid browsers using - // their own cache, because some of the response content comes from - // at least one embedded response (which likely has a different caching strategy). - if ($response->isValidateable()) { - $response->setEtag(null); - $response->setLastModified(null); + // Remove validation related headers of the master response, + // because some of the response content comes from at least + // one embedded response (which likely has a different caching strategy). + $response->setEtag(null); + $response->setLastModified(null); + + $this->add($response); + + $response->headers->set('Age', $this->age); + + if ($this->isNotCacheableResponseEmbedded) { + $response->setExpires($response->getDate()); + + if ($this->flagDirectives['no-store']) { + $response->headers->set('Cache-Control', 'no-cache, no-store, must-revalidate'); + } else { + $response->headers->set('Cache-Control', 'no-cache, must-revalidate'); + } + + return; + } + + $flags = array_filter($this->flagDirectives); + + if (isset($flags['must-revalidate'])) { + $flags['no-cache'] = true; } - if (!$response->isFresh() || !$response->isCacheable()) { - $this->cacheable = false; + $response->headers->set('Cache-Control', implode(', ', array_keys($flags))); + + $maxAge = null; + $sMaxage = null; + + if (\is_numeric($this->ageDirectives['max-age'])) { + $maxAge = $this->ageDirectives['max-age'] + $this->age; + $response->headers->addCacheControlDirective('max-age', $maxAge); } - if (!$this->cacheable) { - $response->headers->set('Cache-Control', 'no-cache, must-revalidate'); + if (\is_numeric($this->ageDirectives['s-maxage'])) { + $sMaxage = $this->ageDirectives['s-maxage'] + $this->age; - return; + if ($maxAge !== $sMaxage) { + $response->headers->addCacheControlDirective('s-maxage', $sMaxage); + } + } + + if (\is_numeric($this->ageDirectives['expires'])) { + $date = clone $response->getDate(); + $date->modify('+'.($this->ageDirectives['expires'] + $this->age).' seconds'); + $response->setExpires($date); } + } - $this->ttls[] = $response->getTtl(); - $this->maxAges[] = $response->getMaxAge(); + /** + * RFC2616, Section 13.4. + * + * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4 + * + * @return bool + */ + private function willMakeFinalResponseUncacheable(Response $response) + { + // RFC2616: A response received with a status code of 200, 203, 300, 301 or 410 + // MAY be stored by a cache […] unless a cache-control directive prohibits caching. + if ($response->headers->hasCacheControlDirective('no-cache') + || $response->headers->getCacheControlDirective('no-store') + ) { + return true; + } - if ($this->isNotCacheableResponseEmbedded) { - $response->headers->removeCacheControlDirective('s-maxage'); - } elseif (null !== $maxAge = min($this->maxAges)) { - $response->setSharedMaxAge($maxAge); - $response->headers->set('Age', $maxAge - min($this->ttls)); + // Last-Modified and Etag headers cannot be merged, they render the response uncacheable + // by default (except if the response also has max-age etc.). + if (\in_array($response->getStatusCode(), [200, 203, 300, 301, 410]) + && null === $response->getLastModified() + && null === $response->getEtag() + ) { + return false; + } + + // RFC2616: A response received with any other status code (e.g. status codes 302 and 307) + // MUST NOT be returned in a reply to a subsequent request unless there are + // cache-control directives or another header(s) that explicitly allow it. + $cacheControl = ['max-age', 's-maxage', 'must-revalidate', 'proxy-revalidate', 'public', 'private']; + foreach ($cacheControl as $key) { + if ($response->headers->hasCacheControlDirective($key)) { + return false; + } + } + + if ($response->headers->has('Expires')) { + return false; + } + + return true; + } + + /** + * Store lowest max-age/s-maxage/expires for the final response. + * + * The response might have been stored in cache a while ago. To keep things comparable, + * 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. + * + * @param string $directive + * @param int|null $value + * @param int $age + */ + private function storeRelativeAgeDirective($directive, $value, $age) + { + if (null === $value) { + $this->ageDirectives[$directive] = false; + } + + if (false !== $this->ageDirectives[$directive]) { + $value = $value - $age; + $this->ageDirectives[$directive] = null !== $this->ageDirectives[$directive] ? min($this->ageDirectives[$directive], $value) : $value; } - $response->setMaxAge(0); } } diff --git a/Tests/HttpCache/ResponseCacheStrategyTest.php b/Tests/HttpCache/ResponseCacheStrategyTest.php index 6d67a17739..22cadf7129 100644 --- a/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -237,4 +237,233 @@ public function testResponseIsExpirableButNotValidateableWhenMasterResponseCombi $this->assertSame('60', $masterResponse->headers->getCacheControlDirective('s-maxage')); $this->assertFalse($masterResponse->isValidateable()); } + + /** + * @dataProvider cacheControlMergingProvider + */ + public function testCacheControlMerging(array $expects, array $master, array $surrogates) + { + $cacheStrategy = new ResponseCacheStrategy(); + $buildResponse = function ($config) { + $response = new Response(); + + foreach ($config as $key => $value) { + switch ($key) { + case 'age': + $response->headers->set('Age', $value); + break; + + case 'expires': + $expires = clone $response->getDate(); + $expires->modify('+'.$value.' seconds'); + $response->setExpires($expires); + break; + + case 'max-age': + $response->setMaxAge($value); + break; + + case 's-maxage': + $response->setSharedMaxAge($value); + break; + + case 'private': + $response->setPrivate(); + break; + + case 'public': + $response->setPublic(); + break; + + default: + $response->headers->addCacheControlDirective($key, $value); + } + } + + return $response; + }; + + foreach ($surrogates as $config) { + $cacheStrategy->add($buildResponse($config)); + } + + $response = $buildResponse($master); + $cacheStrategy->update($response); + + foreach ($expects as $key => $value) { + if ('expires' === $key) { + $this->assertSame($value, $response->getExpires()->format('U') - $response->getDate()->format('U')); + } elseif ('age' === $key) { + $this->assertSame($value, $response->getAge()); + } elseif (true === $value) { + $this->assertTrue($response->headers->hasCacheControlDirective($key), sprintf('Cache-Control header must have "%s" flag', $key)); + } elseif (false === $value) { + $this->assertFalse( + $response->headers->hasCacheControlDirective($key), + sprintf('Cache-Control header must NOT have "%s" flag', $key) + ); + } else { + $this->assertSame($value, $response->headers->getCacheControlDirective($key), sprintf('Cache-Control flag "%s" should be "%s"', $key, $value)); + } + } + } + + public function cacheControlMergingProvider() + { + yield 'result is public if all responses are public' => [ + ['private' => false, 'public' => true], + ['public' => true], + [ + ['public' => true], + ], + ]; + + yield 'result is private by default' => [ + ['private' => true, 'public' => false], + ['public' => true], + [ + [], + ], + ]; + + yield 'combines public and private responses' => [ + ['must-revalidate' => false, 'private' => true, 'public' => false], + ['public' => true], + [ + ['private' => true], + ], + ]; + + yield 'inherits no-cache from surrogates' => [ + ['no-cache' => true, 'public' => false], + ['public' => true], + [ + ['no-cache' => true], + ], + ]; + + yield 'inherits no-store from surrogate' => [ + ['no-store' => true, 'public' => false], + ['public' => true], + [ + ['no-store' => true], + ], + ]; + + yield 'resolve to lowest possible max-age' => [ + ['public' => false, 'private' => true, 's-maxage' => false, 'max-age' => '60'], + ['public' => true, 'max-age' => 3600], + [ + ['private' => true, 'max-age' => 60], + ], + ]; + + yield 'resolves multiple max-age' => [ + ['public' => false, 'private' => true, 's-maxage' => false, 'max-age' => '60'], + ['private' => true, 'max-age' => 100], + [ + ['private' => true, 'max-age' => 3600], + ['public' => true, 'max-age' => 60, 's-maxage' => 60], + ['private' => true, 'max-age' => 60], + ], + ]; + + yield 'merge max-age and s-maxage' => [ + ['public' => true, 's-maxage' => '60', 'max-age' => null], + ['public' => true, 's-maxage' => 3600], + [ + ['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], + [ + ['s-maxage' => 60, 'private' => true], + ], + ]; + + yield 'result can have s-maxage and max-age' => [ + ['public' => true, 'private' => false, 's-maxage' => '60', 'max-age' => '30'], + ['s-maxage' => 100, 'max-age' => 2000], + [ + ['s-maxage' => 1000, 'max-age' => 30], + ['s-maxage' => 500, 'max-age' => 500], + ['s-maxage' => 60, 'max-age' => 1000], + ], + ]; + + yield 'does not set headers without value' => [ + ['max-age' => null, 's-maxage' => null, 'public' => null], + ['private' => true], + [ + ['private' => true], + ], + ]; + + yield 'max-age 0 is sent to the client' => [ + ['private' => true, 'max-age' => '0'], + ['max-age' => 0, 'private' => true], + [ + ['max-age' => 60, 'private' => true], + ], + ]; + + yield 'max-age is relative to age' => [ + ['max-age' => '240', 'age' => 60], + ['max-age' => 180], + [ + ['max-age' => 600, 'age' => 60], + ], + ]; + + yield 'retains lowest age of all responses' => [ + ['max-age' => '160', 'age' => 60], + ['max-age' => 600, 'age' => 60], + [ + ['max-age' => 120, 'age' => 20], + ], + ]; + + yield 'max-age can be less than age, essentially expiring the response' => [ + ['age' => 120, 'max-age' => '90'], + ['max-age' => 90, 'age' => 120], + [ + ['max-age' => 120, 'age' => 60], + ], + ]; + + yield 'max-age is 0 regardless of age' => [ + ['max-age' => '0'], + ['max-age' => 60], + [ + ['max-age' => 0, 'age' => 60], + ], + ]; + + yield 'max-age is not negative' => [ + ['max-age' => '0'], + ['max-age' => 0], + [ + ['max-age' => 0, 'age' => 60], + ], + ]; + + yield 'calculates lowest Expires header' => [ + ['expires' => 60], + ['expires' => 60], + [ + ['expires' => 120], + ], + ]; + + yield 'calculates Expires header relative to age' => [ + ['expires' => 210, 'age' => 120], + ['expires' => 90], + [ + ['expires' => 600, 'age' => '120'], + ], + ]; + } } From 0362368c761cb8d9c79e56ab0db61d2c692db594 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 3 Mar 2019 19:52:34 +0100 Subject: [PATCH 150/294] updated VERSION for 3.4.23 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c97924b778..1a985a4c91 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.23-DEV'; + const VERSION = '3.4.23'; const VERSION_ID = 30423; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 23; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From bd7ccec98c8c73f0f9159f5c47590de3a9a29d18 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 3 Mar 2019 20:25:29 +0100 Subject: [PATCH 151/294] bumped Symfony version to 3.4.24 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1a985a4c91..58beb73542 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.23'; - const VERSION_ID = 30423; + const VERSION = '3.4.24-DEV'; + const VERSION_ID = 30424; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 23; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 24; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 263e4f0e55577cb88784ec35d83a0c986fe4c9a7 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Sat, 9 Mar 2019 08:26:56 -0500 Subject: [PATCH 152/294] Change default log level for output streams --- Log/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Log/Logger.php b/Log/Logger.php index 6cfc759490..e174587d15 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -40,7 +40,7 @@ class Logger extends AbstractLogger public function __construct($minLevel = null, $output = 'php://stderr', callable $formatter = null) { if (null === $minLevel) { - $minLevel = LogLevel::WARNING; + $minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING; if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { From 07988ddcd622eb68c24cf5a5f52885f8d3d19431 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Fri, 22 Mar 2019 10:27:33 +0100 Subject: [PATCH 153/294] SCA: minor code tweaks --- EventListener/DebugHandlersListener.php | 2 +- HttpCache/ResponseCacheStrategy.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index 77f9e2f618..fed9e7e3fe 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -105,7 +105,7 @@ public function configure(Event $event = null) if (method_exists($kernel = $event->getKernel(), 'terminateWithException')) { $request = $event->getRequest(); $hasRun = &$this->hasTerminatedWithException; - $this->exceptionHandler = function (\Exception $e) use ($kernel, $request, &$hasRun) { + $this->exceptionHandler = static function (\Exception $e) use ($kernel, $request, &$hasRun) { if ($hasRun) { throw $e; } diff --git a/HttpCache/ResponseCacheStrategy.php b/HttpCache/ResponseCacheStrategy.php index 862bac557d..1efad607e8 100644 --- a/HttpCache/ResponseCacheStrategy.php +++ b/HttpCache/ResponseCacheStrategy.php @@ -215,7 +215,7 @@ private function storeRelativeAgeDirective($directive, $value, $age) } if (false !== $this->ageDirectives[$directive]) { - $value = $value - $age; + $value -= $age; $this->ageDirectives[$directive] = null !== $this->ageDirectives[$directive] ? min($this->ageDirectives[$directive], $value) : $value; } } From 30a9e48839413e6a6a8dc8989da0e7dd76c8fcf8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 2 Apr 2019 15:47:51 +0200 Subject: [PATCH 154/294] updated VERSION for 3.4.24 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 58beb73542..f283f0c7bd 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.24-DEV'; + const VERSION = '3.4.24'; const VERSION_ID = 30424; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 24; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 5de0a2239d872e355a3b97aaa202550fcae61493 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 2 Apr 2019 21:03:08 +0200 Subject: [PATCH 155/294] bumped Symfony version to 3.4.25 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index f283f0c7bd..0f98fdf0d7 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.24'; - const VERSION_ID = 30424; + const VERSION = '3.4.25-DEV'; + const VERSION_ID = 30425; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 24; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 25; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From fb41c5e2d03ccac43c1fb2285d7fef1612a04241 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 3 Apr 2019 12:07:21 +0200 Subject: [PATCH 156/294] [HttpKernel] Fix DebugHandlersListener constructor docblock --- EventListener/DebugHandlersListener.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index fed9e7e3fe..df9df09c0b 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -19,6 +19,7 @@ use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -40,13 +41,13 @@ class DebugHandlersListener implements EventSubscriberInterface private $hasTerminatedWithException; /** - * @param callable|null $exceptionHandler A handler that will be called on Exception - * @param LoggerInterface|null $logger A PSR-3 logger - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants - * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value - * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged - * @param string|array $fileLinkFormat The format for links to source files - * @param bool $scope Enables/disables scoping mode + * @param callable|null $exceptionHandler A handler that will be called on Exception + * @param LoggerInterface|null $logger A PSR-3 logger + * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants + * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value + * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged + * @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) { From 6be2e0fd9ca9ac9bdf181b0c05dd0886b72b116a Mon Sep 17 00:00:00 2001 From: Lynn Date: Wed, 10 Apr 2019 13:41:44 +0200 Subject: [PATCH 157/294] Show more accurate message in profiler when missing stopwatch --- DataCollector/TimeDataCollector.php | 9 +++++++++ Tests/DataCollector/TimeDataCollectorTest.php | 2 ++ 2 files changed, 11 insertions(+) diff --git a/DataCollector/TimeDataCollector.php b/DataCollector/TimeDataCollector.php index 99149ab0be..f48db70568 100644 --- a/DataCollector/TimeDataCollector.php +++ b/DataCollector/TimeDataCollector.php @@ -47,6 +47,7 @@ public function collect(Request $request, Response $response, \Exception $except 'token' => $response->headers->get('X-Debug-Token'), 'start_time' => $startTime * 1000, 'events' => [], + 'stopwatch_installed' => \class_exists(Stopwatch::class, false), ]; } @@ -139,6 +140,14 @@ public function getStartTime() return $this->data['start_time']; } + /** + * @return bool whether or not the stopwatch component is installed + */ + public function isStopwatchInstalled() + { + return $this->data['stopwatch_installed']; + } + /** * {@inheritdoc} */ diff --git a/Tests/DataCollector/TimeDataCollectorTest.php b/Tests/DataCollector/TimeDataCollectorTest.php index cf6a86695d..793fbd319f 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\Stopwatch\Stopwatch; /** * @group time-sensitive @@ -51,5 +52,6 @@ public function testCollect() $c->collect($request, new Response()); $this->assertEquals(123456000, $c->getStartTime()); + $this->assertSame(\class_exists(Stopwatch::class, false), $c->isStopwatchInstalled()); } } From 259eac9d5fbef33302a6cdbfcbf74329a0775607 Mon Sep 17 00:00:00 2001 From: Martijn Cuppens Date: Thu, 11 Apr 2019 11:29:09 +0200 Subject: [PATCH 158/294] Optimize SVGs --- Resources/welcome.html.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Resources/welcome.html.php b/Resources/welcome.html.php index caac7fd6eb..8fdc00506c 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -51,21 +51,7 @@