[DI] fix dumping lazy services

This commit is contained in:
Nicolas Grekas 2018-09-19 09:18:46 +02:00
parent 4eb4089255
commit 7cf1505a5b
2 changed files with 10 additions and 28 deletions

View File

@ -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(); $this->circularReferences = array();
$checkedNodes = array(); $checkedNodes = array();
foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) { foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) {

View File

@ -134,17 +134,11 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
*/ */
protected function getConnectionService() protected function getConnectionService()
{ {
$a = ${($_ = isset($this->services['dispatcher']) ? $this->services['dispatcher'] : $this->getDispatcherService()) && false ?: '_'}; $a = new \stdClass();
if (isset($this->services['connection'])) { $this->services['connection'] = $instance = new \stdClass(${($_ = isset($this->services['dispatcher']) ? $this->services['dispatcher'] : $this->getDispatcherService()) && false ?: '_'}, $a);
return $this->services['connection'];
}
$b = new \stdClass(); $a->logger = ${($_ = isset($this->services['logger']) ? $this->services['logger'] : $this->getLoggerService()) && false ?: '_'};
$this->services['connection'] = $instance = new \stdClass($a, $b);
$b->logger = ${($_ = isset($this->services['logger']) ? $this->services['logger'] : $this->getLoggerService()) && false ?: '_'};
return $instance; return $instance;
} }
@ -156,21 +150,15 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
*/ */
protected function getConnection2Service() protected function getConnection2Service()
{ {
$a = ${($_ = isset($this->services['dispatcher2']) ? $this->services['dispatcher2'] : $this->getDispatcher2Service()) && false ?: '_'}; $a = new \stdClass();
if (isset($this->services['connection2'])) { $this->services['connection2'] = $instance = new \stdClass(${($_ = isset($this->services['dispatcher2']) ? $this->services['dispatcher2'] : $this->getDispatcher2Service()) && false ?: '_'}, $a);
return $this->services['connection2'];
}
$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); $a->logger2 = $b;
$c->handler2 = new \stdClass(${($_ = isset($this->services['manager2']) ? $this->services['manager2'] : $this->getManager2Service()) && false ?: '_'});
$b->logger2 = $c;
return $instance; return $instance;
} }
@ -380,12 +368,6 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
*/ */
protected function getSubscriberService() protected function getSubscriberService()
{ {
$a = ${($_ = isset($this->services['manager']) ? $this->services['manager'] : $this->getManagerService()) && false ?: '_'}; return $this->services['subscriber'] = new \stdClass(${($_ = 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);
} }
} }