From 1d0145289e1c617d4f6ea81ea910ad3a253fd6da Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 13 Jan 2023 08:47:26 +0100 Subject: [PATCH] [DependencyInjection] Fix dump order of inlined deps --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 2 +- .../Fixtures/php/services_almost_circular_private.php | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 9d662d5ed26ec..dd548f3c123d1 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -497,7 +497,7 @@ private function collectCircularReferences(string $sourceId, array $edges, array $loop = []; } } - $this->addCircularReferences($first, $loop, true); + $this->addCircularReferences($first, $loop, $loopByConstructor); break; } } 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 1dbcdb10ed01c..33a45361a866f 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 @@ -421,17 +421,16 @@ protected function getMonologInline_LoggerService() */ protected function getPAService() { - $a = new \stdClass(); - - $b = ($this->privates['pC'] ?? $this->getPCService()); + $a = ($this->privates['pC'] ?? $this->getPCService()); if (isset($this->services['pA'])) { return $this->services['pA']; } + $b = new \stdClass(); - $this->services['pA'] = $instance = new \stdClass($a, $b); + $this->services['pA'] = $instance = new \stdClass($b, $a); - $a->d = ($this->privates['pD'] ?? $this->getPDService()); + $b->d = ($this->privates['pD'] ?? $this->getPDService()); return $instance; }