From 3d14b79dadb77c54d0cd0928572d386a3ee2f4a4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 9 Sep 2019 08:40:31 +0200 Subject: [PATCH 01/15] Require exact match when reading from stdin with a dash --- src/Symfony/Bridge/Twig/Command/LintCommand.php | 4 ++-- .../Component/Translation/Command/XliffLintCommand.php | 4 ++-- src/Symfony/Component/Yaml/Command/LintCommand.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index b4016eec99..8828bab1d1 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -77,9 +77,9 @@ EOF { $io = new SymfonyStyle($input, $output); $filenames = $input->getArgument('filename'); - $hasStdin = '-' === ($filenames[0] ?? ''); + $hasStdin = ['-'] === $filenames; - if ($hasStdin || 0 === \count($filenames)) { + if ($hasStdin || !$filenames) { if ($hasStdin || 0 === ftell(STDIN)) { // remove 0 === ftell(STDIN) check in 5.0 if (!$hasStdin) { @trigger_error('Calling to the "lint:twig" command providing pipe file content to STDIN without passing the dash symbol "-" explicitly is deprecated since Symfony 4.4.', E_USER_DEPRECATED); diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index 8137415e99..e7575155bd 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -83,9 +83,9 @@ EOF $filenames = (array) $input->getArgument('filename'); $this->format = $input->getOption('format'); $this->displayCorrectFiles = $output->isVerbose(); - $hasStdin = '-' === ($filenames[0] ?? ''); + $hasStdin = ['-'] === $filenames; - if ($hasStdin || 0 === \count($filenames)) { + if ($hasStdin || !$filenames) { if (!$hasStdin && 0 !== ftell(STDIN)) { // remove 0 !== ftell(STDIN) check in 5.0 throw new RuntimeException('Please provide a filename or pipe file content to STDIN.'); } diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index 2f3193ba1d..d2a216b919 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -86,9 +86,9 @@ EOF $this->format = $input->getOption('format'); $this->displayCorrectFiles = $output->isVerbose(); $flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0; - $hasStdin = '-' === ($filenames[0] ?? ''); + $hasStdin = ['-'] === $filenames; - if ($hasStdin || 0 === \count($filenames)) { + if ($hasStdin || !$filenames) { if (!$hasStdin && 0 !== ftell(STDIN)) { // remove 0 !== ftell(STDIN) check in 5.0 throw new RuntimeException('Please provide a filename or pipe file content to STDIN.'); } From 600bde956244203c72843437e7c1a87d6ab89a63 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 9 Sep 2019 12:09:16 +0200 Subject: [PATCH 02/15] do not perform string operations on null --- src/Symfony/Component/HttpClient/HttpClientTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index b42d2369c3..49229576bf 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -506,7 +506,9 @@ trait HttpClientTrait private static function shouldBuffer(array $headers): bool { - $contentType = $headers['content-type'][0] ?? null; + if (null === $contentType = $headers['content-type'][0] ?? null) { + return false; + } if (false !== $i = strpos($contentType, ';')) { $contentType = substr($contentType, 0, $i); From 6a7b77ecb2f4ee77e640cea9241c53ebba406273 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Sep 2019 08:36:23 +0200 Subject: [PATCH 03/15] [HttpClient] fix php notice on push --- src/Symfony/Component/HttpClient/Response/CurlResponse.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index a6ebfec61f..b95a81ab28 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -64,7 +64,7 @@ final class CurlResponse implements ResponseInterface } if (null === $content = &$this->content) { - $content = true === $options['buffer'] ? fopen('php://temp', 'w+') : null; + $content = null === $options || true === $options['buffer'] ? fopen('php://temp', 'w+') : null; } else { // Move the pushed response to the activity list if (ftell($content)) { @@ -349,7 +349,7 @@ final class CurlResponse implements ResponseInterface return 0; } - if ($options['buffer'] instanceof \Closure && !$content && $options['buffer']($headers)) { + if (null !== $options && $options['buffer'] instanceof \Closure && !$content && $options['buffer']($headers)) { $content = fopen('php://temp', 'w+'); } From 0e28518b332ebf157174e89c528641495922856e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Sep 2019 10:07:32 +0200 Subject: [PATCH 04/15] [HttpClient] fix calling the buffer-enabling callback --- .../HttpClient/Response/CurlResponse.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index b95a81ab28..8e69b8cdc7 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -67,11 +67,23 @@ final class CurlResponse implements ResponseInterface $content = null === $options || true === $options['buffer'] ? fopen('php://temp', 'w+') : null; } else { // Move the pushed response to the activity list - if (ftell($content)) { - rewind($content); - $multi->handlesActivity[$id][] = stream_get_contents($content); + $buffer = $options['buffer']; + + if ('headers' !== curl_getinfo($ch, CURLINFO_PRIVATE)) { + if ($options['buffer'] instanceof \Closure) { + [$content, $buffer] = [null, $content]; + [$content, $buffer] = [$buffer, (bool) $options['buffer']($headers)]; + } + + if (ftell($content)) { + rewind($content); + $multi->handlesActivity[$id][] = stream_get_contents($content); + } + } + + if (true !== $buffer) { + $content = null; } - $content = true === $options['buffer'] ? $content : null; } curl_setopt($ch, CURLOPT_HEADERFUNCTION, static function ($ch, string $data) use (&$info, &$headers, $options, $multi, $id, &$location, $resolveRedirect, $logger, &$content): int { @@ -349,11 +361,11 @@ final class CurlResponse implements ResponseInterface return 0; } - if (null !== $options && $options['buffer'] instanceof \Closure && !$content && $options['buffer']($headers)) { + curl_setopt($ch, CURLOPT_PRIVATE, 'content'); + + if (!$content && $options['buffer'] instanceof \Closure && $options['buffer']($headers)) { $content = fopen('php://temp', 'w+'); } - - curl_setopt($ch, CURLOPT_PRIVATE, 'content'); } elseif (null !== $info['redirect_url'] && $logger) { $logger->info(sprintf('Redirecting: "%s %s"', $info['http_code'], $info['redirect_url'])); } From 4cc86413261e79b5a65157ca4edf38e748ffbfe5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Sep 2019 11:11:45 +0200 Subject: [PATCH 05/15] [DI] fix Preloader --- .../DependencyInjection/Dumper/Preloader.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php b/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php index eb3a69d702..8c2ab387f2 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/Preloader.php @@ -38,8 +38,7 @@ class Preloader $prev = $classes; foreach ($classes as $c) { if (!isset($preloaded[$c])) { - $preloaded[$c] = true; - self::doPreload($c); + self::doPreload($c, $preloaded); } } $classes = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits()); @@ -49,12 +48,14 @@ class Preloader } } - private static function doPreload(string $class) + private static function doPreload(string $class, array &$preloaded) { - if (\in_array($class, ['self', 'static', 'parent'], true)) { + if (isset($preloaded[$class]) || \in_array($class, ['self', 'static', 'parent'], true)) { return; } + $preloaded[$class] = true; + try { $r = new \ReflectionClass($class); @@ -68,7 +69,7 @@ class Preloader if (\PHP_VERSION_ID >= 70400) { foreach ($r->getProperties() as $p) { if (($t = $p->getType()) && !$t->isBuiltin()) { - self::doPreload($t->getName()); + self::doPreload($t->getName(), $preloaded); } } } @@ -79,17 +80,17 @@ class Preloader $c = $p->getDefaultValueConstantName(); if ($i = strpos($c, '::')) { - self::doPreload(substr($c, 0, $i)); + self::doPreload(substr($c, 0, $i), $preloaded); } } if (($t = $p->getType()) && !$t->isBuiltin()) { - self::doPreload($t->getName()); + self::doPreload($t->getName(), $preloaded); } } if (($t = $m->getReturnType()) && !$t->isBuiltin()) { - self::doPreload($t->getName()); + self::doPreload($t->getName(), $preloaded); } } } catch (\ReflectionException $e) { From 9665d7633de2137b14d10ae7e0def9da754ff82b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 10 Sep 2019 12:13:59 +0200 Subject: [PATCH 06/15] Remove Google references when not needed --- .../AbstractBootstrap3LayoutTest.php | 8 ++--- .../Component/BrowserKit/Tests/CookieTest.php | 4 +-- .../Form/Tests/AbstractLayoutTest.php | 8 ++--- .../Component/HttpKernel/Tests/ClientTest.php | 4 +-- .../Tests/Constraints/UrlValidatorTest.php | 30 +++++++++---------- .../VarDumper/Tests/Caster/SplCasterTest.php | 6 ++-- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index 5763345afd..f04372c542 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -2396,7 +2396,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testUrlWithDefaultProtocol() { - $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; + $url = 'http://www.example.com?foo1=bar1&foo2=bar2'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => 'http']); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], @@ -2404,7 +2404,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest [@type="text"] [@name="name"] [@class="my&class form-control"] - [@value="http://www.google.com?foo1=bar1&foo2=bar2"] + [@value="http://www.example.com?foo1=bar1&foo2=bar2"] [@inputmode="url"] ' ); @@ -2412,7 +2412,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest public function testUrlWithoutDefaultProtocol() { - $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; + $url = 'http://www.example.com?foo1=bar1&foo2=bar2'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => null]); $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], @@ -2420,7 +2420,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest [@type="url"] [@name="name"] [@class="my&class form-control"] - [@value="http://www.google.com?foo1=bar1&foo2=bar2"] + [@value="http://www.example.com?foo1=bar1&foo2=bar2"] ' ); } diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php index 694b164851..1404da9a1c 100644 --- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -44,10 +44,10 @@ class CookieTest extends TestCase return [ ['foo=bar; path=/'], ['foo=bar; path=/foo'], - ['foo=bar; domain=google.com; path=/'], + ['foo=bar; domain=example.com; path=/'], ['foo=bar; domain=example.com; path=/; secure', 'https://example.com/'], ['foo=bar; path=/; httponly'], - ['foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'], + ['foo=bar; domain=example.com; path=/foo; secure; httponly', 'https://example.com/'], ['foo=bar=baz; path=/'], ['foo=bar%3Dbaz; path=/'], ]; diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 8fc2c4002e..0165552f73 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -2189,14 +2189,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase public function testUrlWithDefaultProtocol() { - $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; + $url = 'http://www.example.com?foo1=bar1&foo2=bar2'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => 'http']); $this->assertWidgetMatchesXpath($form->createView(), [], '/input [@type="text"] [@name="name"] - [@value="http://www.google.com?foo1=bar1&foo2=bar2"] + [@value="http://www.example.com?foo1=bar1&foo2=bar2"] [@inputmode="url"] ' ); @@ -2204,14 +2204,14 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase public function testUrlWithoutDefaultProtocol() { - $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; + $url = 'http://www.example.com?foo1=bar1&foo2=bar2'; $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\UrlType', $url, ['default_protocol' => null]); $this->assertWidgetMatchesXpath($form->createView(), [], '/input [@type="url"] [@name="name"] - [@value="http://www.google.com?foo1=bar1&foo2=bar2"] + [@value="http://www.example.com?foo1=bar1&foo2=bar2"] ' ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index 86a51ce765..b141c16d64 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -39,8 +39,8 @@ class ClientTest extends TestCase $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request'); $this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request'); - $client->request('GET', 'http://www.example.com/?parameter=http://google.com'); - $this->assertEquals('http://www.example.com/?parameter='.urlencode('http://google.com'), $client->getRequest()->getUri(), '->doRequest() uses the request handler to make the request'); + $client->request('GET', 'http://www.example.com/?parameter=http://example.com'); + $this->assertEquals('http://www.example.com/?parameter='.urlencode('http://example.com'), $client->getRequest()->getUri(), '->doRequest() uses the request handler to make the request'); } public function testGetScript() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index e54a936685..ab845d45db 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -67,11 +67,11 @@ class UrlValidatorTest extends ConstraintValidatorTestCase { return [ ['http://a.pl'], - ['http://www.google.com'], - ['http://www.google.com.'], - ['http://www.google.museum'], - ['https://google.com/'], - ['https://google.com:80/'], + ['http://www.example.com'], + ['http://www.example.com.'], + ['http://www.example.museum'], + ['https://example.com/'], + ['https://example.com:80/'], ['http://www.example.coop/'], ['http://www.test-example.com/'], ['http://www.symfony.com/'], @@ -148,15 +148,15 @@ class UrlValidatorTest extends ConstraintValidatorTestCase public function getInvalidUrls() { return [ - ['google.com'], - ['://google.com'], - ['http ://google.com'], - ['http:/google.com'], - ['http://goog_le.com'], - ['http://google.com::aa'], - ['http://google.com:aa'], - ['ftp://google.fr'], - ['faked://google.fr'], + ['example.com'], + ['://example.com'], + ['http ://example.com'], + ['http:/example.com'], + ['http://examp_le.com'], + ['http://example.com::aa'], + ['http://example.com:aa'], + ['ftp://example.fr'], + ['faked://example.fr'], ['http://127.0.0.1:aa/'], ['ftp://[::1]/'], ['http://[::1'], @@ -189,7 +189,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase public function getValidCustomUrls() { return [ - ['ftp://google.com'], + ['ftp://example.com'], ['file://127.0.0.1'], ['git://[::1]/'], ]; diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php index 984b340c6d..a146a2f6b9 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php @@ -50,12 +50,12 @@ SplFileInfo { %A} EOTXT ], - ['https://google.com/about', <<<'EOTXT' + ['https://example.com/about', <<<'EOTXT' SplFileInfo { -%Apath: "https://google.com" +%Apath: "https://example.com" filename: "about" basename: "about" - pathname: "https://google.com/about" + pathname: "https://example.com/about" extension: "" realPath: false %A} From a549069a49b7959d7fd83fab2b95c03c9cae2ecc Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 9 Sep 2019 13:39:48 +0200 Subject: [PATCH 07/15] don't dump a scalar tag value on its own line --- src/Symfony/Component/Yaml/Dumper.php | 6 +----- .../Component/Yaml/Tests/DumperTest.php | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 7f38a5435c..a496dcc88e 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -115,15 +115,11 @@ class Dumper if ($value instanceof TaggedValue) { $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); - if ($inline - 1 <= 0) { + if ($inline - 1 <= 0 || null === $value->getValue() || is_scalar($value->getValue())) { $output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n"; } else { $output .= "\n"; $output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags); - - if (is_scalar($value->getValue())) { - $output .= "\n"; - } } continue; diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index d4554392a2..1a1ef25a5a 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -532,10 +532,21 @@ YAML; 'user2' => new TaggedValue('user', 'john'), ]; $expected = <<assertSame($expected, $this->dumper->dump($data, 2)); + } + + public function testDumpingNotInlinedNullTaggedValue() + { + $data = [ + 'foo' => new TaggedValue('bar', null), + ]; + $expected = << Date: Tue, 10 Sep 2019 11:15:55 +0200 Subject: [PATCH 08/15] Simplify usage of dirname() --- .php_cs.dist | 1 + .../Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php | 2 +- src/Symfony/Bundle/FrameworkBundle/Client.php | 2 +- .../DependencyInjection/FrameworkExtension.php | 2 +- .../Command/CacheClearCommand/CacheClearCommandTest.php | 2 +- .../DependencyInjection/Compiler/ExtensionPass.php | 2 +- src/Symfony/Component/Config/Resource/ComposerResource.php | 2 +- .../ClassNotFoundFatalErrorHandlerTest.php | 2 +- .../DependencyInjection/Tests/Dumper/PhpDumperTest.php | 2 +- .../Component/Form/Tests/Resources/TranslationFilesTest.php | 6 +++--- src/Symfony/Component/HttpKernel/Client.php | 2 +- .../Security/Core/Tests/Resources/TranslationFilesTest.php | 6 +++--- .../Validator/Tests/Resources/TranslationFilesTest.php | 6 +++--- src/Symfony/Component/VarDumper/Caster/LinkStub.php | 2 +- 14 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 6206f7144a..789e3a5d0b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -21,6 +21,7 @@ return PhpCsFixer\Config::create() 'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true], // Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'combine_nested_dirname' => true, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index 2d6aa29224..8879606722 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -269,7 +269,7 @@ class Deprecation foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); + $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { self::$vendors[] = $v; $loader = require $v.'/autoload.php'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 3e395a4904..6450a4ec00 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -169,7 +169,7 @@ class Client extends HttpKernelBrowser foreach (get_declared_classes() as $class) { if (0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; + $file = \dirname($r->getFileName(), 2).'/autoload.php'; if (file_exists($file)) { $requires .= 'require_once '.var_export($file, true).";\n"; } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 1b5fea6564..8cb3fdd242 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1114,7 +1114,7 @@ class FrameworkExtension extends Extension if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) { $r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException'); - $dirs[] = $transPaths[] = \dirname(\dirname($r->getFileName())).'/Resources/translations'; + $dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations'; } $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); $rootDir = $container->getParameter('kernel.root_dir'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index d70f92b7e6..118a14e84e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -64,7 +64,7 @@ class CacheClearCommandTest extends TestCase // check that app kernel file present in meta file of container's cache $containerClass = $this->kernel->getContainer()->getParameter('kernel.container_class'); $containerRef = new \ReflectionClass($containerClass); - $containerFile = \dirname(\dirname($containerRef->getFileName())).'/'.$containerClass.'.php'; + $containerFile = \dirname($containerRef->getFileName(), 2).'/'.$containerClass.'.php'; $containerMetaFile = $containerFile.'.meta'; $kernelRef = new \ReflectionObject($this->kernel); $kernelFile = $kernelRef->getFileName(); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 79a6ad9ae8..e9138535e5 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -44,7 +44,7 @@ class ExtensionPass implements CompilerPassInterface $container->getDefinition('twig.extension.form')->addTag('twig.extension'); $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); - $coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form'; + $coreThemePath = \dirname($reflClass->getFileName(), 2).'/Resources/views/Form'; $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', [$coreThemePath]); $paths = $container->getDefinition('twig.template_iterator')->getArgument(2); diff --git a/src/Symfony/Component/Config/Resource/ComposerResource.php b/src/Symfony/Component/Config/Resource/ComposerResource.php index 183ffabebd..822766b75b 100644 --- a/src/Symfony/Component/Config/Resource/ComposerResource.php +++ b/src/Symfony/Component/Config/Resource/ComposerResource.php @@ -60,7 +60,7 @@ class ComposerResource implements SelfCheckingResourceInterface foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); + $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json'); } diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php index 7287fa7735..f3fd16e2ac 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -32,7 +32,7 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase } if ($function[0] instanceof ComposerClassLoader) { - $function[0]->add('Symfony_Component_Debug_Tests_Fixtures', \dirname(\dirname(\dirname(\dirname(\dirname(__DIR__)))))); + $function[0]->add('Symfony_Component_Debug_Tests_Fixtures', \dirname(__DIR__, 5)); break; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 8839db3335..073f57d369 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -105,7 +105,7 @@ class PhpDumperTest extends TestCase $container->setParameter('foo', 'wiz'.\dirname(__DIR__)); $container->setParameter('bar', __DIR__); $container->setParameter('baz', '%bar%/PhpDumperTest.php'); - $container->setParameter('buz', \dirname(\dirname(__DIR__))); + $container->setParameter('buz', \dirname(__DIR__, 2)); $container->compile(); $dumper = new PhpDumper($container); diff --git a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php index 49e69ef190..e45fed8554 100644 --- a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php @@ -29,15 +29,15 @@ class TranslationFilesTest extends TestCase { return array_map( function ($filePath) { return (array) $filePath; }, - glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf') + glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf') ); } public function testNorwegianAlias() { $this->assertFileEquals( - \dirname(\dirname(__DIR__)).'/Resources/translations/validators.nb.xlf', - \dirname(\dirname(__DIR__)).'/Resources/translations/validators.no.xlf', + \dirname(__DIR__, 2).'/Resources/translations/validators.nb.xlf', + \dirname(__DIR__, 2).'/Resources/translations/validators.no.xlf', 'The NO locale should be an alias for the NB variant of the Norwegian language.' ); } diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index d4ae5f8e65..fba2562a6c 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -90,7 +90,7 @@ class Client extends AbstractBrowser foreach (get_declared_classes() as $class) { if (0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; + $file = \dirname($r->getFileName(), 2).'/autoload.php'; if (file_exists($file)) { $requires .= 'require_once '.var_export($file, true).";\n"; } diff --git a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php index bc21d272fc..8dce5c80b3 100644 --- a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php @@ -29,15 +29,15 @@ class TranslationFilesTest extends TestCase { return array_map( function ($filePath) { return (array) $filePath; }, - glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf') + glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf') ); } public function testNorwegianAlias() { $this->assertFileEquals( - \dirname(\dirname(__DIR__)).'/Resources/translations/security.nb.xlf', - \dirname(\dirname(__DIR__)).'/Resources/translations/security.no.xlf', + \dirname(__DIR__, 2).'/Resources/translations/security.nb.xlf', + \dirname(__DIR__, 2).'/Resources/translations/security.no.xlf', 'The NO locale should be an alias for the NB variant of the Norwegian language.' ); } diff --git a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php index 56ff24d2fd..26f93293c7 100644 --- a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php +++ b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php @@ -29,15 +29,15 @@ class TranslationFilesTest extends TestCase { return array_map( function ($filePath) { return (array) $filePath; }, - glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf') + glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf') ); } public function testNorwegianAlias() { $this->assertFileEquals( - \dirname(\dirname(__DIR__)).'/Resources/translations/validators.nb.xlf', - \dirname(\dirname(__DIR__)).'/Resources/translations/validators.no.xlf', + \dirname(__DIR__, 2).'/Resources/translations/validators.nb.xlf', + \dirname(__DIR__, 2).'/Resources/translations/validators.no.xlf', 'The NO locale should be an alias for the NB variant of the Norwegian language.' ); } diff --git a/src/Symfony/Component/VarDumper/Caster/LinkStub.php b/src/Symfony/Component/VarDumper/Caster/LinkStub.php index 84a8b10d40..d18b359ea1 100644 --- a/src/Symfony/Component/VarDumper/Caster/LinkStub.php +++ b/src/Symfony/Component/VarDumper/Caster/LinkStub.php @@ -71,7 +71,7 @@ class LinkStub extends ConstStub foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); + $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { self::$vendorRoots[] = $v.\DIRECTORY_SEPARATOR; } From 1517d1682feec4cb28bfc63fc193cd0211df84cb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 10 Sep 2019 13:27:19 +0200 Subject: [PATCH 09/15] Remove Google references when not needed --- .../Tests/Constraints/UrlValidatorTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index b1d26ff7f3..31dacc4613 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -91,7 +91,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase public function getValidRelativeUrls() { return [ - ['//google.com'], + ['//example.com'], ['//symfony.fake/blog/'], ['//symfony.com/search?type=&q=url+validator'], ]; @@ -166,11 +166,11 @@ class UrlValidatorTest extends ConstraintValidatorTestCase public function getValidUrlsWithWhitespaces() { return [ - ["\x20http://www.google.com"], - ["\x09\x09http://www.google.com."], + ["\x20http://www.example.com"], + ["\x09\x09http://www.example.com."], ["http://symfony.fake/blog/\x0A"], ["http://symfony.com/search?type=&q=url+validator\x0D\x0D"], - ["\x00https://google.com:80\x00"], + ["\x00https://example.com:80\x00"], ["\x0B\x0Bhttp://username:password@symfony.com\x0B\x0B"], ]; } @@ -214,10 +214,10 @@ class UrlValidatorTest extends ConstraintValidatorTestCase public function getInvalidRelativeUrls() { return [ - ['/google.com'], - ['//goog_le.com'], - ['//google.com::aa'], - ['//google.com:aa'], + ['/example.com'], + ['//examp_le.com'], + ['//example.com::aa'], + ['//example.com:aa'], ['//127.0.0.1:aa/'], ['//[::1'], ['//hello.☎/'], From 51ffc18b6d6f2e6c7659ac99fa4aa3f4280dfe26 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 10 Sep 2019 13:34:21 +0200 Subject: [PATCH 10/15] Simplify usage of dirname() --- .../FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/ErrorHandler/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/src/Symfony/Component/ErrorHandler/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php index 39de29150a..a84c0dce97 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php +++ b/src/Symfony/Component/ErrorHandler/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -32,7 +32,7 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase } if ($function[0] instanceof ComposerClassLoader) { - $function[0]->add('Symfony_Component_ErrorHandler_Tests_Fixtures', \dirname(\dirname(\dirname(\dirname(\dirname(__DIR__)))))); + $function[0]->add('Symfony_Component_ErrorHandler_Tests_Fixtures', \dirname(__DIR__, 5)); break; } } From 2eae30053766181acd502a11bcf8689a335d26bf Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 10 Sep 2019 12:03:35 +0200 Subject: [PATCH 11/15] [DI] use dirname() when possible --- .../DependencyInjection/Dumper/PhpDumper.php | 75 +++++++++++++------ .../php/container_alias_deprecation.php | 1 - ...er_class_constructor_without_arguments.php | 1 - ...s_with_mandatory_constructor_arguments.php | 1 - ...ss_with_optional_constructor_arguments.php | 1 - ...om_container_class_without_constructor.php | 1 - .../Tests/Fixtures/php/services1-1.php | 1 - .../Tests/Fixtures/php/services1.php | 1 - .../Tests/Fixtures/php/services10.php | 1 - .../Tests/Fixtures/php/services12.php | 23 ++---- .../Tests/Fixtures/php/services13.php | 1 - .../Tests/Fixtures/php/services19.php | 1 - .../Tests/Fixtures/php/services24.php | 1 - .../Tests/Fixtures/php/services26.php | 8 +- .../Tests/Fixtures/php/services33.php | 1 - .../Tests/Fixtures/php/services8.php | 1 - .../Tests/Fixtures/php/services9_as_files.txt | 11 +-- .../Tests/Fixtures/php/services9_compiled.php | 1 - .../php/services9_inlined_factories.txt | 21 +++--- .../php/services9_lazy_inlined_factories.txt | 11 +-- .../Tests/Fixtures/php/services_adawson.php | 1 - .../php/services_almost_circular_private.php | 1 - .../php/services_almost_circular_public.php | 1 - .../Fixtures/php/services_array_params.php | 24 ++---- .../Fixtures/php/services_base64_env.php | 1 - .../Tests/Fixtures/php/services_csv_env.php | 1 - .../php/services_dedup_lazy_proxy.php | 1 - .../Fixtures/php/services_deep_graph.php | 1 - .../Fixtures/php/services_default_env.php | 1 - .../Tests/Fixtures/php/services_env_in_id.php | 1 - .../php/services_errored_definition.php | 1 - .../Fixtures/php/services_inline_requires.php | 19 ++--- .../Fixtures/php/services_inline_self_ref.php | 1 - .../Tests/Fixtures/php/services_json_env.php | 1 - .../Tests/Fixtures/php/services_locator.php | 1 - .../Fixtures/php/services_non_shared_lazy.php | 1 - .../php/services_non_shared_lazy_as_files.txt | 9 +-- .../Fixtures/php/services_private_frozen.php | 1 - .../php/services_private_in_expression.php | 1 - .../php/services_query_string_env.php | 1 - .../Tests/Fixtures/php/services_rot13_env.php | 1 - .../php/services_service_locator_argument.php | 1 - .../Fixtures/php/services_subscriber.php | 1 - .../Tests/Fixtures/php/services_tsantos.php | 1 - .../php/services_uninitialized_ref.php | 1 - .../php/services_unsupported_characters.php | 1 - .../Tests/Fixtures/php/services_url_env.php | 1 - .../Tests/Fixtures/php/services_wither.php | 1 - 48 files changed, 92 insertions(+), 148 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 26b1842063..eca801fa87 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -11,6 +11,8 @@ namespace Symfony\Component\DependencyInjection\Dumper; +use Composer\Autoload\ClassLoader; +use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader; use Symfony\Component\DependencyInjection\Argument\ArgumentInterface; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; @@ -36,6 +38,7 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ServiceLocator as BaseServiceLocator; use Symfony\Component\DependencyInjection\TypedReference; use Symfony\Component\DependencyInjection\Variable; +use Symfony\Component\ErrorHandler\DebugClassLoader; use Symfony\Component\ExpressionLanguage\Expression; use Symfony\Component\HttpKernel\Kernel; @@ -296,8 +299,11 @@ EOF; $namespaceLine = $this->namespace ? "\nnamespace {$this->namespace};\n" : ''; $time = $options['build_time']; $id = hash('crc32', $hash.$time); + $this->asFiles = false; + + if ($preload && null !== $autoloadFile = $this->getAutoloadFile()) { + $autoloadFile = substr($this->export($autoloadFile), 2, -1); - if ($preload) { $code[$options['class'].'.preload.php'] = <<inlineFactories) { $this->inlinedRequires[$file] = true; } - $file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file); $code .= sprintf("include_once %s;\n", $file); } @@ -553,7 +558,6 @@ EOF; } foreach (array_diff_key(array_flip($lineage), $this->inlinedRequires) as $file => $class) { - $file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file); $code .= sprintf(" include_once %s;\n", $file); } } @@ -562,7 +566,6 @@ EOF; if ($file = $def->getFile()) { $file = $this->dumpValue($file); $file = '(' === $file[0] ? substr($file, 1, -1) : $file; - $file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file); $code .= sprintf(" include_once %s;\n", $file); } } @@ -1076,27 +1079,21 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class $class extends $baseClass { private \$parameters = []; - private \$targetDirs = []; public function __construct() { EOF; - if (null !== $this->targetDirRegex) { - $dir = $this->asFiles ? '$this->targetDirs[0] = \\dirname($containerDir)' : '__DIR__'; - $code .= <<targetDirMaxMatches}; ++\$i) { - \$this->targetDirs[\$i] = \$dir = \\dirname(\$dir); - } - -EOF; - } if ($this->asFiles) { $code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $code); $code = str_replace('__construct()', '__construct(array $buildParameters = [], $containerDir = __DIR__)', $code); $code .= " \$this->buildParameters = \$buildParameters;\n"; $code .= " \$this->containerDir = \$containerDir;\n"; + + if (null !== $this->targetDirRegex) { + $code = str_replace('$parameters', "\$targetDir;\n private \$parameters", $code); + $code .= ' $this->targetDir = \\dirname($containerDir);'."\n"; + } } if (Container::class !== $this->baseClass) { @@ -1350,12 +1347,11 @@ EOF; foreach ($lineage as $file) { if (!isset($this->inlinedRequires[$file])) { $this->inlinedRequires[$file] = true; - $file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file); $code .= sprintf("\n include_once %s;", $file); } } - return $code ? sprintf("\n \$this->privates['service_container'] = static function () {%s\n };\n", $code) : ''; + return $code ? sprintf("\n \$this->privates['service_container'] = function () {%s\n };\n", $code) : ''; } private function addDefaultParametersMethod(): string @@ -1374,7 +1370,7 @@ EOF; $export = $this->exportParameters([$value]); $export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2); - if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $export[1])) { + if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDir\.'')/", $export[1])) { $dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]); } else { $php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]); @@ -1776,7 +1772,7 @@ EOF; return $dumpedValue; } - if (!preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $dumpedValue)) { + if (!preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDir\.'')/", $dumpedValue)) { return sprintf('$this->parameters[%s]', $this->doExport($name)); } } @@ -1977,8 +1973,10 @@ EOF; $dirname = $this->asFiles ? '$this->containerDir' : '__DIR__'; $offset = 1 + $this->targetDirMaxMatches - \count($matches); - if ($this->asFiles || 0 < $offset) { - $dirname = sprintf('$this->targetDirs[%d]', $offset); + if (0 < $offset) { + $dirname = sprintf('\dirname(__DIR__, %d)', $offset + (int) $this->asFiles); + } elseif ($this->asFiles) { + $dirname = "\$this->targetDir.''"; // empty string concatenation on purpose } if ($prefix || $suffix) { @@ -2027,4 +2025,37 @@ EOF; return $export; } + + private function getAutoloadFile(): ?string + { + if (null === $this->targetDirRegex) { + return null; + } + + foreach (spl_autoload_functions() as $autoloader) { + if (!\is_array($autoloader)) { + continue; + } + + if ($autoloader[0] instanceof DebugClassLoader || $autoloader[0] instanceof LegacyDebugClassLoader) { + $autoloader = $autoloader[0]->getClassLoader(); + } + + if (!\is_array($autoloader) || !$autoloader[0] instanceof ClassLoader || !$autoloader[0]->findFile(__CLASS__)) { + continue; + } + + foreach (get_declared_classes() as $class) { + if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) { + $file = (new \ReflectionClass($class))->getFileName(); + + if (preg_match($this->targetDirRegex.'A', $file)) { + return $file; + } + } + } + } + + return null; + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php index 5b415ef0f3..3434cfc618 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_alias_deprecation.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Aliases_Deprecation extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php index 0066ebcac5..33d30ef9db 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_constructor_without_arguments.php @@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithoutArgumentsContainer { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php index e065fce008..197e4c99f0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_mandatory_constructor_arguments.php @@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithMandatoryArgumentsContainer { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php index c3fe6abea1..c56f8d7048 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_with_optional_constructor_arguments.php @@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithOptionalArgumentsContainer { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php index 1c007a5f1c..464b75a597 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/custom_container_class_without_constructor.php @@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\NoConstructorContainer { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index a42d778518..a3b402c1e7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index af24b8cf44..29d01cf81d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index 9dbeb0eae1..bc5a096746 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 02f2469abc..3dfa8bdd6d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { - $dir = __DIR__; - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -61,7 +56,7 @@ class ProjectServiceContainer extends Container */ protected function getTestService() { - return $this->services['test'] = new \stdClass(('wiz'.$this->targetDirs[1]), [('wiz'.$this->targetDirs[1]) => ($this->targetDirs[2].'/')]); + return $this->services['test'] = new \stdClass(('wiz'.\dirname(__DIR__, 1)), [('wiz'.\dirname(__DIR__, 1)) => (\dirname(__DIR__, 2).'/')]); } public function getParameter($name) @@ -103,29 +98,21 @@ class ProjectServiceContainer extends Container return $this->parameterBag; } - private $loadedDynamicParameters = [ - 'foo' => false, - 'buz' => false, - ]; + private $loadedDynamicParameters = []; private $dynamicParameters = []; private function getDynamicParameter(string $name) { - switch ($name) { - case 'foo': $value = ('wiz'.$this->targetDirs[1]); break; - case 'buz': $value = $this->targetDirs[2]; break; - default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name)); - } - $this->loadedDynamicParameters[$name] = true; - - return $this->dynamicParameters[$name] = $value; + throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name)); } protected function getDefaultParameters(): array { return [ + 'foo' => ('wiz'.\dirname(__DIR__, 1)), 'bar' => __DIR__, 'baz' => (__DIR__.'/PhpDumperTest.php'), + 'buz' => \dirname(__DIR__, 2), ]; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index 8e62b81ab2..2622869080 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index d5482b1dde..b5ff25acb8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index 7be80e1856..c7e8ba7072 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index ccf7e7ddde..063ebfd14d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_EnvParameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { - $dir = __DIR__; - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -119,7 +114,6 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container 'baz' => false, 'json' => false, 'db_dsn' => false, - 'env(json_file)' => false, ]; private $dynamicParameters = []; @@ -130,7 +124,6 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container case 'baz': $value = $this->getEnv('int:Baz'); break; case 'json': $value = $this->getEnv('json:file:json_file'); break; case 'db_dsn': $value = $this->getEnv('resolve:DB'); break; - case 'env(json_file)': $value = ($this->targetDirs[1].'/array.json'); break; default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name)); } $this->loadedDynamicParameters[$name] = true; @@ -144,6 +137,7 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container 'project_dir' => '/foo/bar', 'env(FOO)' => 'foo', 'env(DB)' => 'sqlite://%project_dir%/var/data.db', + 'env(json_file)' => (\dirname(__DIR__, 1).'/array.json'), ]; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index 9c30be1b97..e872e4818a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 93c7ff4514..7ffc2b49c3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index 7c8ddf8f08..2bbf46c906 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -265,7 +265,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; // This file has been auto-generated by the Symfony Dependency Injection Component for internal use. // Returns the public 'method_call1' shared service. -include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php'; +include_once $this->targetDir.''.'/Fixtures/includes/foo.php'; $this->services['method_call1'] = $instance = new \Bar\FooClass(); @@ -300,7 +300,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; // This file has been auto-generated by the Symfony Dependency Injection Component for internal use. // Returns the public 'non_shared_foo' service. -include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php'; +include_once $this->targetDir.''.'/Fixtures/includes/foo.php'; $this->factories['non_shared_foo'] = function () { return new \Bar\FooClass(); @@ -374,17 +374,14 @@ class ProjectServiceContainer extends Container { private $buildParameters; private $containerDir; + private $targetDir; private $parameters = []; - private $targetDirs = []; public function __construct(array $buildParameters = [], $containerDir = __DIR__) { - $dir = $this->targetDirs[0] = \dirname($containerDir); - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->buildParameters = $buildParameters; $this->containerDir = $containerDir; + $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 24c9b6f55f..512994ef12 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt index 693845baf4..808a1c5d07 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_inlined_factories.txt @@ -40,17 +40,14 @@ class ProjectServiceContainer extends Container { private $buildParameters; private $containerDir; + private $targetDir; private $parameters = []; - private $targetDirs = []; public function __construct(array $buildParameters = [], $containerDir = __DIR__) { - $dir = $this->targetDirs[0] = \dirname($containerDir); - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->buildParameters = $buildParameters; $this->containerDir = $containerDir; + $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -90,8 +87,8 @@ class ProjectServiceContainer extends Container 'decorated' => 'decorator_service_with_name', ]; - $this->privates['service_container'] = static function () { - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php'; + $this->privates['service_container'] = function () { + include_once $this->targetDir.''.'/Fixtures/includes/foo.php'; }; } @@ -287,7 +284,7 @@ class ProjectServiceContainer extends Container */ protected function getFoo_BazService() { - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/classes.php'; + include_once $this->targetDir.''.'/Fixtures/includes/classes.php'; $this->services['foo.baz'] = $instance = \BazClass::getInstance(); @@ -331,7 +328,7 @@ class ProjectServiceContainer extends Container */ protected function getLazyContextService() { - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/classes.php'; + include_once $this->targetDir.''.'/Fixtures/includes/classes.php'; return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () { yield 'k1' => ($this->services['foo.baz'] ?? $this->getFoo_BazService()); @@ -348,7 +345,7 @@ class ProjectServiceContainer extends Container */ protected function getLazyContextIgnoreInvalidRefService() { - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/classes.php'; + include_once $this->targetDir.''.'/Fixtures/includes/classes.php'; return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () { yield 0 => ($this->services['foo.baz'] ?? $this->getFoo_BazService()); @@ -364,7 +361,7 @@ class ProjectServiceContainer extends Container */ protected function getMethodCall1Service() { - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php'; + include_once $this->targetDir.''.'/Fixtures/includes/foo.php'; $this->services['method_call1'] = $instance = new \Bar\FooClass(); @@ -399,7 +396,7 @@ class ProjectServiceContainer extends Container */ protected function getNonSharedFooService() { - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php'; + include_once $this->targetDir.''.'/Fixtures/includes/foo.php'; return new \Bar\FooClass(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt index 2811e280e3..2b5409a39f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt @@ -30,17 +30,14 @@ class ProjectServiceContainer extends Container { private $buildParameters; private $containerDir; + private $targetDir; private $parameters = []; - private $targetDirs = []; public function __construct(array $buildParameters = [], $containerDir = __DIR__) { - $dir = $this->targetDirs[0] = \dirname($containerDir); - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->buildParameters = $buildParameters; $this->containerDir = $containerDir; + $this->targetDir = \dirname($containerDir); $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -92,7 +89,7 @@ class ProjectServiceContainer extends Container }); } - include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo_lazy.php'; + include_once $this->targetDir.''.'/Fixtures/includes/foo_lazy.php'; return new \Bar\FooClass(new \Bar\FooLazyClass()); } @@ -161,7 +158,7 @@ class ProjectServiceContainer extends Container ]; } } -include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php'; +include_once $this->targetDir.''.'/Fixtures/includes/foo.php'; class FooClass_%s extends \Bar\FooClass implements \ProxyManager\Proxy\VirtualProxyInterface { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php index 4c584f4aa4..abf047cb94 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_adawson.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index ca85686f6e..7df41fb810 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index f7eb154f09..dda3f7b497 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index 2b6664cf85..4e704e469c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { - $dir = __DIR__; - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -63,7 +58,7 @@ class ProjectServiceContainer extends Container { $this->services['bar'] = $instance = new \BarClass(); - $instance->setBaz($this->parameters['array_1'], $this->getParameter('array_2'), '%array_1%', $this->parameters['array_1']); + $instance->setBaz($this->parameters['array_1'], $this->parameters['array_2'], '%array_1%', $this->parameters['array_1']); return $instance; } @@ -107,22 +102,12 @@ class ProjectServiceContainer extends Container return $this->parameterBag; } - private $loadedDynamicParameters = [ - 'array_2' => false, - ]; + private $loadedDynamicParameters = []; private $dynamicParameters = []; private function getDynamicParameter(string $name) { - switch ($name) { - case 'array_2': $value = [ - 0 => ($this->targetDirs[2].'/Dumper'), - ]; break; - default: throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name)); - } - $this->loadedDynamicParameters[$name] = true; - - return $this->dynamicParameters[$name] = $value; + throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name)); } protected function getDefaultParameters(): array @@ -131,6 +116,9 @@ class ProjectServiceContainer extends Container 'array_1' => [ 0 => 123, ], + 'array_2' => [ + 0 => (\dirname(__DIR__, 2).'/Dumper'), + ], ]; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php index ca1292a214..fe5a60a0df 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php index cb25eb4f99..4fbb831885 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_CsvParameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php index 47112f5745..2ec9a4d090 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dedup_lazy_proxy.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php index fca5c8504f..1f5b36fe9c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Deep_Graph extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php index 56f50dd220..582ac453af 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_DefaultParameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php index c5c5536ebf..3d381cabd1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php index 01ec2e8580..3e84e304a7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Errored_Definition extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index 177062d986..14bbc1ff31 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -18,14 +18,9 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { - $dir = __DIR__; - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->parameters = $this->getDefaultParameters(); $this->services = $this->privates = []; @@ -37,11 +32,11 @@ class ProjectServiceContainer extends Container $this->aliases = []; - $this->privates['service_container'] = static function () { - include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/I1.php'; - include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/P1.php'; - include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/T1.php'; - include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/C1.php'; + $this->privates['service_container'] = function () { + include_once \dirname(__DIR__, 1).'/includes/HotPath/I1.php'; + include_once \dirname(__DIR__, 1).'/includes/HotPath/P1.php'; + include_once \dirname(__DIR__, 1).'/includes/HotPath/T1.php'; + include_once \dirname(__DIR__, 1).'/includes/HotPath/C1.php'; }; } @@ -91,8 +86,8 @@ class ProjectServiceContainer extends Container */ protected function getC2Service() { - include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/C2.php'; - include_once \dirname(__DIR__, 0 + 1).'/includes/HotPath/C3.php'; + include_once \dirname(__DIR__, 1).'/includes/HotPath/C2.php'; + include_once \dirname(__DIR__, 1).'/includes/HotPath/C3.php'; return $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3()); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php index 55de46ff12..bc0ea4fdcc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_self_ref.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Inline_Self_Ref extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php index 7d8cb9bfc0..18b5253092 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_JsonParameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php index 3855cc45dc..0febbec9bd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php index 243596005d..d71bb40972 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt index 35582196c6..1c1d998845 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; // This file has been auto-generated by the Symfony Dependency Injection Component for internal use. // Returns the public 'non_shared_foo' service. -include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo_lazy.php'; +include_once $this->targetDir.''.'/Fixtures/includes/foo_lazy.php'; $this->factories['non_shared_foo'] = function ($lazyLoad = true) { return new \Bar\FooLazyClass(); @@ -46,17 +46,14 @@ class ProjectServiceContainer extends Container { private $buildParameters; private $containerDir; + private $targetDir; private $parameters = []; - private $targetDirs = []; public function __construct(array $buildParameters = [], $containerDir = __DIR__) { - $dir = $this->targetDirs[0] = \dirname($containerDir); - for ($i = 1; $i <= 5; ++$i) { - $this->targetDirs[$i] = $dir = \dirname($dir); - } $this->buildParameters = $buildParameters; $this->containerDir = $containerDir; + $this->targetDir = \dirname($containerDir); $this->services = $this->privates = []; $this->fileMap = [ 'non_shared_foo' => 'getNonSharedFooService.php', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php index 6c49882199..c5db0bfdc6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php index f058ae8bdb..b63c8bc782 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php index 64fef86a84..be3d8dcadb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_QueryStringParameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php index 3dc9a9263f..3234234641 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container { private $parameters = []; - private $targetDirs = []; private $getService; public function __construct() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php index 19617f2cc5..5615be83cf 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_service_locator_argument.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Service_Locator_Argument extends Container { private $parameters = []; - private $targetDirs = []; private $getService; public function __construct() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index b8126d5427..7b25658742 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; private $getService; public function __construct() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php index 099a6e0b66..6b1042a4cb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_tsantos.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ProjectServiceContainer extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php index 5accf7553d..be690dc417 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php index b1cb22986c..a958e8ee05 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_Unsupported_Characters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php index abe0e39a34..1ef02e372c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Test_UrlParameters extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php index 545638d90f..0e1eeb9767 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class Symfony_DI_PhpDumper_Service_Wither extends Container { private $parameters = []; - private $targetDirs = []; public function __construct() { From 329a74fe47b78d52b489c24ea6af29ae186504c3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Sep 2019 16:46:44 +0200 Subject: [PATCH 12/15] [WebProfilerBundle] Assign automatic colors to custom Stopwatch categories --- .../Resources/views/Collector/time.css.twig | 41 ---------- .../Resources/views/Collector/time.html.twig | 23 ++---- .../Resources/views/Collector/time.js | 76 ++++++++++++++++--- 3 files changed, 75 insertions(+), 65 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.css.twig index ca46eafb9a..b64b6ff869 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.css.twig @@ -1,15 +1,3 @@ -/* Variables */ - -.sf-profiler-timeline { - --color-default: #777; - --color-section: #999; - --color-event-listener: #00B8F5; - --color-template: #66CC00; - --color-doctrine: #FF6633; - --color-messenger-middleware: #BDB81E; - --color-controller-argument-value-resolver: #8c5de6; -} - /* Legend */ .sf-profiler-timeline .legends .timeline-category { @@ -31,14 +19,6 @@ display: inline-block; } -.sf-profiler-timeline .legends .{{ classnames.default|raw }} { border-color: var(--color-default); } -.sf-profiler-timeline .legends .{{ classnames.section|raw }} { border-color: var(--color-section); } -.sf-profiler-timeline .legends .{{ classnames.event_listener|raw }} { border-color: var(--color-event-listener); } -.sf-profiler-timeline .legends .{{ classnames.template|raw }} { border-color: var(--color-template); } -.sf-profiler-timeline .legends .{{ classnames.doctrine|raw }} { border-color: var(--color-doctrine); } -.sf-profiler-timeline .legends .{{ classnames['messenger.middleware']|raw }} { border-color: var(--color-messenger-middleware); } -.sf-profiler-timeline .legends .{{ classnames['controller.argument_value_resolver']|raw }} { border-color: var(--color-controller-argument-value-resolver); } - .timeline-graph { margin: 1em 0; width: 100%; @@ -82,24 +62,3 @@ .timeline-graph .timeline-period { stroke-width: 0; } -.timeline-graph .{{ classnames.default|raw }} .timeline-period { - fill: var(--color-default); -} -.timeline-graph .{{ classnames.section|raw }} .timeline-period { - fill: var(--color-section); -} -.timeline-graph .{{ classnames.event_listener|raw }} .timeline-period { - fill: var(--color-event-listener); -} -.timeline-graph .{{ classnames.template|raw }} .timeline-period { - fill: var(--color-template); -} -.timeline-graph .{{ classnames.doctrine|raw }} .timeline-period { - fill: var(--color-doctrine); -} -.timeline-graph .{{ classnames['messenger.middleware']|raw }} .timeline-period { - fill: var(--color-messenger-middleware); -} -.timeline-graph .{{ classnames['controller.argument_value_resolver']|raw }} .timeline-period { - fill: var(--color-controller-argument-value-resolver); -} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index 20b72098dc..62187dbab4 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -2,16 +2,6 @@ {% import _self as helper %} -{% set classnames = { - 'default': 'timeline-category-default', - 'section': 'timeline-category-section', - 'event_listener': 'timeline-category-event-listener', - 'template': 'timeline-category-template', - 'doctrine': 'timeline-category-doctrine', - 'messenger.middleware': 'timeline-category-messenger-middleware', - 'controller.argument_value_resolver': 'timeline-category-controller-argument-value-resolver', -} %} - {% block toolbar %} {% set has_time_events = collector.events|length > 0 %} {% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %} @@ -128,7 +118,7 @@ {% endif %} - {{ helper.display_timeline(token, classnames, collector.events, collector.events.__section__.origin) }} + {{ helper.display_timeline(token, collector.events, collector.events.__section__.origin) }} {% if profile.children|length %}

Note: sections with a striped background correspond to sub-requests.

@@ -142,7 +132,7 @@ {{ events.__section__.duration }} ms - {{ helper.display_timeline(child.token, classnames, events, collector.events.__section__.origin) }} + {{ helper.display_timeline(child.token, events, collector.events.__section__.origin) }} {% endfor %} {% endif %} @@ -154,7 +144,7 @@