Permalink
Browse files

bug #28672 [DI] fix error in dumped container (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[DI] fix error in dumped container

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #28658
| License       | MIT
| Doc PR        | -

(test case on its way)

Commits
-------

2d0aba6 [DI] fix error in dumped container
  • Loading branch information...
nicolas-grekas committed Oct 2, 2018
2 parents caf37ca + 2d0aba6 commit 22aec2490ca3e06f9307a2e47b51087c2129720d
@@ -751,7 +751,7 @@ private function addInlineReference(&$head, &$tail, $id, $targetId, $forConstruc
EOTXT
,
$this->container->getDefinition($id)->isPublic() ? 'services' : 'privates',
'services',
$id
);
@@ -1385,6 +1385,9 @@ public function testAlmostCircular($visibility)
$manager = $container->get('manager2');
$this->assertEquals(new \stdClass(), $manager);
$foo6 = $container->get('foo6');
$this->assertEquals((object) array('bar6' => (object) array()), $foo6);
}
public function provideAlmostCircular()
@@ -830,6 +830,9 @@ public function testAlmostCircular($visibility)
$manager = $container->get('manager2');
$this->assertEquals(new \stdClass(), $manager);
$foo6 = $container->get('foo6');
$this->assertEquals((object) array('bar6' => (object) array()), $foo6);
}
public function provideAlmostCircular()
@@ -101,4 +101,18 @@
$container->register('subscriber2', 'stdClass')->setPublic(false)
->addArgument(new Reference('manager2'));
// private service involved in a loop
$container->register('foo6', 'stdClass')
->setPublic(true)
->setProperty('bar6', new Reference('bar6'));
$container->register('bar6', 'stdClass')
->setPublic(false)
->addArgument(new Reference('foo6'));
$container->register('baz6', 'stdClass')
->setPublic(true)
->setProperty('bar6', new Reference('bar6'));
return $container;
@@ -25,17 +25,23 @@ public function __construct()
$this->methodMap = array(
'bar2' => 'getBar2Service',
'bar3' => 'getBar3Service',
'bar6' => 'getBar6Service',
'baz6' => 'getBaz6Service',
'connection' => 'getConnectionService',
'connection2' => 'getConnection2Service',
'foo' => 'getFooService',
'foo2' => 'getFoo2Service',
'foo5' => 'getFoo5Service',
'foo6' => 'getFoo6Service',
'foobar4' => 'getFoobar4Service',
'logger' => 'getLoggerService',
'manager' => 'getManagerService',
'manager2' => 'getManager2Service',
'subscriber' => 'getSubscriberService',
);
$this->privates = array(
'bar6' => true,
);
$this->aliases = array();
}
@@ -47,6 +53,7 @@ public function getRemovedIds()
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
'bar' => true,
'bar5' => true,
'bar6' => true,
'config' => true,
'config2' => true,
'dispatcher' => true,
@@ -107,6 +114,20 @@ protected function getBar3Service()
return $instance;
}
/**
* Gets the public 'baz6' shared service.
*
* @return \stdClass
*/
protected function getBaz6Service()
{
$this->services['baz6'] = $instance = new \stdClass();
$instance->bar6 = ${($_ = isset($this->services['bar6']) ? $this->services['bar6'] : $this->getBar6Service()) && false ?: '_'};
return $instance;
}
/**
* Gets the public 'connection' shared service.
*
@@ -203,6 +224,20 @@ protected function getFoo5Service()
return $instance;
}
/**
* Gets the public 'foo6' shared service.
*
* @return \stdClass
*/
protected function getFoo6Service()
{
$this->services['foo6'] = $instance = new \stdClass();
$instance->bar6 = ${($_ = isset($this->services['bar6']) ? $this->services['bar6'] : $this->getBar6Service()) && false ?: '_'};
return $instance;
}
/**
* Gets the public 'foobar4' shared service.
*
@@ -286,4 +321,20 @@ protected function getSubscriberService()
return $this->services['subscriber'] = new \stdClass($a);
}
/**
* Gets the private 'bar6' shared service.
*
* @return \stdClass
*/
protected function getBar6Service()
{
$a = ${($_ = isset($this->services['foo6']) ? $this->services['foo6'] : $this->getFoo6Service()) && false ?: '_'};
if (isset($this->services['bar6'])) {
return $this->services['bar6'];
}
return $this->services['bar6'] = new \stdClass($a);
}
}
@@ -26,6 +26,8 @@ public function __construct()
'bar' => 'getBarService',
'bar3' => 'getBar3Service',
'bar5' => 'getBar5Service',
'bar6' => 'getBar6Service',
'baz6' => 'getBaz6Service',
'connection' => 'getConnectionService',
'connection2' => 'getConnection2Service',
'dispatcher' => 'getDispatcherService',
@@ -34,6 +36,7 @@ public function __construct()
'foo2' => 'getFoo2Service',
'foo4' => 'getFoo4Service',
'foo5' => 'getFoo5Service',
'foo6' => 'getFoo6Service',
'foobar' => 'getFoobarService',
'foobar2' => 'getFoobar2Service',
'foobar3' => 'getFoobar3Service',
@@ -43,6 +46,9 @@ public function __construct()
'manager2' => 'getManager2Service',
'subscriber' => 'getSubscriberService',
);
$this->privates = array(
'bar6' => true,
);
$this->aliases = array();
}
@@ -53,6 +59,7 @@ public function getRemovedIds()
'Psr\\Container\\ContainerInterface' => true,
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
'bar2' => true,
'bar6' => true,
'config' => true,
'config2' => true,
'logger2' => true,
@@ -127,6 +134,20 @@ protected function getBar5Service()
return $instance;
}
/**
* Gets the public 'baz6' shared service.
*
* @return \stdClass
*/
protected function getBaz6Service()
{
$this->services['baz6'] = $instance = new \stdClass();
$instance->bar6 = ${($_ = isset($this->services['bar6']) ? $this->services['bar6'] : $this->getBar6Service()) && false ?: '_'};
return $instance;
}
/**
* Gets the public 'connection' shared service.
*
@@ -251,6 +272,20 @@ protected function getFoo5Service()
return $instance;
}
/**
* Gets the public 'foo6' shared service.
*
* @return \stdClass
*/
protected function getFoo6Service()
{
$this->services['foo6'] = $instance = new \stdClass();
$instance->bar6 = ${($_ = isset($this->services['bar6']) ? $this->services['bar6'] : $this->getBar6Service()) && false ?: '_'};
return $instance;
}
/**
* Gets the public 'foobar' shared service.
*
@@ -370,4 +405,20 @@ protected function getSubscriberService()
{
return $this->services['subscriber'] = new \stdClass(${($_ = isset($this->services['manager']) ? $this->services['manager'] : $this->getManagerService()) && false ?: '_'});
}
/**
* Gets the private 'bar6' shared service.
*
* @return \stdClass
*/
protected function getBar6Service()
{
$a = ${($_ = isset($this->services['foo6']) ? $this->services['foo6'] : $this->getFoo6Service()) && false ?: '_'};
if (isset($this->services['bar6'])) {
return $this->services['bar6'];
}
return $this->services['bar6'] = new \stdClass($a);
}
}

0 comments on commit 22aec24

Please sign in to comment.