[DI] Fix infinite loop in InlineServiceDefinitionsPass
This commit is contained in:
parent
8555c0b550
commit
b988aa7c59
@ -61,10 +61,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||||||
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
|
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
|
||||||
$this->inlinedServiceIds[$id][] = $this->currentId;
|
$this->inlinedServiceIds[$id][] = $this->currentId;
|
||||||
|
|
||||||
if ($definition->isShared()) {
|
return $definition->isShared() ? $definition : clone $definition;
|
||||||
return $definition;
|
|
||||||
}
|
|
||||||
$value = clone $definition;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,25 @@ class InlineServiceDefinitionsPassTest extends TestCase
|
|||||||
$this->assertNotSame($container->getDefinition('bar'), $arguments[2]);
|
$this->assertNotSame($container->getDefinition('bar'), $arguments[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessInlinesMixedServicesLoop()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container
|
||||||
|
->register('foo')
|
||||||
|
->addArgument(new Reference('bar'))
|
||||||
|
->setShared(false)
|
||||||
|
;
|
||||||
|
$container
|
||||||
|
->register('bar')
|
||||||
|
->setPublic(false)
|
||||||
|
->addMethodCall('setFoo', array(new Reference('foo')))
|
||||||
|
;
|
||||||
|
|
||||||
|
$this->process($container);
|
||||||
|
|
||||||
|
$this->assertEquals($container->getDefinition('foo')->getArgument(0), $container->getDefinition('bar'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testProcessInlinesIfMultipleReferencesButAllFromTheSameDefinition()
|
public function testProcessInlinesIfMultipleReferencesButAllFromTheSameDefinition()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
Reference in New Issue
Block a user