From 7cf1505a5b2118bd595684b547421903b320c1d2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 19 Sep 2018 09:18:46 +0200 Subject: [PATCH] [DI] fix dumping lazy services --- .../DependencyInjection/Dumper/PhpDumper.php | 2 +- .../php/services_almost_circular_public.php | 36 +++++-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 330170ccaa..9c1e22f638 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -154,7 +154,7 @@ class PhpDumper extends Dumper } } - (new AnalyzeServiceReferencesPass(false, !$this->getProxyDumper() instanceof NullDumper))->process($this->container); + (new AnalyzeServiceReferencesPass(false))->process($this->container); $this->circularReferences = array(); $checkedNodes = array(); foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) { 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 587bb3cf46..177160bd92 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 @@ -134,17 +134,11 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container */ protected function getConnectionService() { - $a = ${($_ = isset($this->services['dispatcher']) ? $this->services['dispatcher'] : $this->getDispatcherService()) && false ?: '_'}; + $a = new \stdClass(); - if (isset($this->services['connection'])) { - return $this->services['connection']; - } + $this->services['connection'] = $instance = new \stdClass(${($_ = isset($this->services['dispatcher']) ? $this->services['dispatcher'] : $this->getDispatcherService()) && false ?: '_'}, $a); - $b = new \stdClass(); - - $this->services['connection'] = $instance = new \stdClass($a, $b); - - $b->logger = ${($_ = isset($this->services['logger']) ? $this->services['logger'] : $this->getLoggerService()) && false ?: '_'}; + $a->logger = ${($_ = isset($this->services['logger']) ? $this->services['logger'] : $this->getLoggerService()) && false ?: '_'}; return $instance; } @@ -156,21 +150,15 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container */ protected function getConnection2Service() { - $a = ${($_ = isset($this->services['dispatcher2']) ? $this->services['dispatcher2'] : $this->getDispatcher2Service()) && false ?: '_'}; + $a = new \stdClass(); - if (isset($this->services['connection2'])) { - return $this->services['connection2']; - } + $this->services['connection2'] = $instance = new \stdClass(${($_ = isset($this->services['dispatcher2']) ? $this->services['dispatcher2'] : $this->getDispatcher2Service()) && false ?: '_'}, $a); - $b = new \stdClass(); + $b = new \stdClass($instance); - $this->services['connection2'] = $instance = new \stdClass($a, $b); + $b->handler2 = new \stdClass(${($_ = isset($this->services['manager2']) ? $this->services['manager2'] : $this->getManager2Service()) && false ?: '_'}); - $c = new \stdClass($instance); - - $c->handler2 = new \stdClass(${($_ = isset($this->services['manager2']) ? $this->services['manager2'] : $this->getManager2Service()) && false ?: '_'}); - - $b->logger2 = $c; + $a->logger2 = $b; return $instance; } @@ -380,12 +368,6 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container */ protected function getSubscriberService() { - $a = ${($_ = isset($this->services['manager']) ? $this->services['manager'] : $this->getManagerService()) && false ?: '_'}; - - if (isset($this->services['subscriber'])) { - return $this->services['subscriber']; - } - - return $this->services['subscriber'] = new \stdClass($a); + return $this->services['subscriber'] = new \stdClass(${($_ = isset($this->services['manager']) ? $this->services['manager'] : $this->getManagerService()) && false ?: '_'}); } }