From ff3d5eea2c9019c34794a26aa8d48fabe8503581 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 6 Feb 2019 19:04:48 +0100 Subject: [PATCH] [DI] Fix dumping Doctrine-like service graphs (bis) --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 0a1385ecc4a0a..f5c52e8f6168a 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -661,7 +661,6 @@ private function addService($id, Definition $definition, &$file = null) $autowired = $definition->isAutowired() ? ' autowired' : ''; if ($definition->isLazy()) { - unset($this->circularReferences[$id]); $lazyInitialization = '$lazyLoad = true'; } else { $lazyInitialization = ''; @@ -807,11 +806,13 @@ private function addInlineService($id, Definition $definition, Definition $inlin if ('instance' === $name) { $code .= $this->addServiceInstance($id, $definition, $isSimpleInstance); + $forConstructor = false; } else { $code .= $this->addNewInstance($inlineDef, '$'.$name, ' = ', $id); + $forConstructor = $forConstructor && $this->proxyDumper instanceof NullDumper && $this->container->getDefinition($id)->isLazy(); } - if ('' !== $inline = $this->addInlineVariables($id, $definition, $arguments, false)) { + if ('' !== $inline = $this->addInlineVariables($id, $definition, $arguments, $forConstructor)) { $code .= "\n".$inline."\n"; } elseif ($arguments && 'instance' === $name) { $code .= "\n";