Skip to content

[DI] fix error in dumped container #28672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ private function addInlineReference(&$head, &$tail, $id, $targetId, $forConstruc

EOTXT
,
$this->container->getDefinition($id)->isPublic() ? 'services' : 'privates',
'services',
$id
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -47,6 +53,7 @@ public function getRemovedIds()
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
'bar' => true,
'bar5' => true,
'bar6' => true,
'config' => true,
'config2' => true,
'dispatcher' => true,
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function __construct()
'bar' => 'getBarService',
'bar3' => 'getBar3Service',
'bar5' => 'getBar5Service',
'bar6' => 'getBar6Service',
'baz6' => 'getBaz6Service',
'connection' => 'getConnectionService',
'connection2' => 'getConnection2Service',
'dispatcher' => 'getDispatcherService',
Expand All @@ -34,6 +36,7 @@ public function __construct()
'foo2' => 'getFoo2Service',
'foo4' => 'getFoo4Service',
'foo5' => 'getFoo5Service',
'foo6' => 'getFoo6Service',
'foobar' => 'getFoobarService',
'foobar2' => 'getFoobar2Service',
'foobar3' => 'getFoobar3Service',
Expand All @@ -43,6 +46,9 @@ public function __construct()
'manager2' => 'getManager2Service',
'subscriber' => 'getSubscriberService',
);
$this->privates = array(
'bar6' => true,
);

$this->aliases = array();
}
Expand All @@ -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,
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}
}