diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index aeebbf0bf1..e734aebb27 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -113,6 +113,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe return $value; } $this->currentDefinition = $value; + } elseif ($this->currentDefinition === $value) { + return $value; } $this->lazy = false; diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 249dfc8787..45a1d24ebe 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -1479,6 +1479,22 @@ class ContainerBuilderTest extends TestCase $container->set('foo', (object) array(123)); $this->assertEquals((object) array('foo' => (object) array(123)), $container->get('bar')); } + + public function testDecoratedSelfReferenceInvolvingPrivateServices() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass') + ->setPublic(false) + ->setProperty('bar', new Reference('foo')); + $container->register('baz', 'stdClass') + ->setPublic(false) + ->setProperty('inner', new Reference('baz.inner')) + ->setDecoratedService('foo'); + + $container->compile(); + + $this->assertSame(array('service_container'), array_keys($container->getDefinitions())); + } } class FooClass