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
-------
2d0aba6ff8
[DI] fix error in dumped container
This commit is contained in:
commit
22aec2490c
@ -751,7 +751,7 @@ EOF;
|
||||
|
||||
EOTXT
|
||||
,
|
||||
$this->container->getDefinition($id)->isPublic() ? 'services' : 'privates',
|
||||
'services',
|
||||
$id
|
||||
);
|
||||
|
||||
|
@ -1385,6 +1385,9 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$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 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$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('dispatcher2', 'stdClass')->setPublic($public)
|
||||
$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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container
|
||||
$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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container
|
||||
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
|
||||
'bar' => true,
|
||||
'bar5' => true,
|
||||
'bar6' => true,
|
||||
'config' => true,
|
||||
'config2' => true,
|
||||
'dispatcher' => true,
|
||||
@ -107,6 +114,20 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container
|
||||
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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container
|
||||
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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Private extends Container
|
||||
|
||||
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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
'bar' => 'getBarService',
|
||||
'bar3' => 'getBar3Service',
|
||||
'bar5' => 'getBar5Service',
|
||||
'bar6' => 'getBar6Service',
|
||||
'baz6' => 'getBaz6Service',
|
||||
'connection' => 'getConnectionService',
|
||||
'connection2' => 'getConnection2Service',
|
||||
'dispatcher' => 'getDispatcherService',
|
||||
@ -34,6 +36,7 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
'foo2' => 'getFoo2Service',
|
||||
'foo4' => 'getFoo4Service',
|
||||
'foo5' => 'getFoo5Service',
|
||||
'foo6' => 'getFoo6Service',
|
||||
'foobar' => 'getFoobarService',
|
||||
'foobar2' => 'getFoobar2Service',
|
||||
'foobar3' => 'getFoobar3Service',
|
||||
@ -43,6 +46,9 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
'manager2' => 'getManager2Service',
|
||||
'subscriber' => 'getSubscriberService',
|
||||
);
|
||||
$this->privates = array(
|
||||
'bar6' => true,
|
||||
);
|
||||
|
||||
$this->aliases = array();
|
||||
}
|
||||
@ -53,6 +59,7 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
'Psr\\Container\\ContainerInterface' => true,
|
||||
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
|
||||
'bar2' => true,
|
||||
'bar6' => true,
|
||||
'config' => true,
|
||||
'config2' => true,
|
||||
'logger2' => true,
|
||||
@ -127,6 +134,20 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
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 @@ class Symfony_DI_PhpDumper_Test_Almost_Circular_Public extends Container
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user