[DI] Fix circular-aliases message
This commit is contained in:
parent
6e7e6847d9
commit
f1a7b075a6
@ -998,10 +998,14 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
$id = (string) $this->aliasDefinitions[$id];
|
||||
|
||||
if (isset($seen[$id])) {
|
||||
throw new ServiceCircularReferenceException($id, array_keys($seen));
|
||||
$seen = array_values($seen);
|
||||
$seen = array_slice($seen, array_search($id, $seen));
|
||||
$seen[] = $id;
|
||||
|
||||
throw new ServiceCircularReferenceException($id, $seen);
|
||||
}
|
||||
|
||||
$seen[$id] = true;
|
||||
$seen[$id] = $id;
|
||||
}
|
||||
|
||||
return $this->getDefinition($id);
|
||||
|
@ -1046,18 +1046,19 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
||||
* @expectedExceptionMessage Circular reference detected for service "app.test_class", path: "app.test_class -> App\TestClass".
|
||||
* @expectedExceptionMessage Circular reference detected for service "app.test_class", path: "app.test_class -> App\TestClass -> app.test_class".
|
||||
*/
|
||||
public function testThrowsCircularExceptionForCircularAliases()
|
||||
{
|
||||
$builder = new ContainerBuilder();
|
||||
|
||||
$builder->setAliases(array(
|
||||
'foo' => new Alias('app.test_class'),
|
||||
'app.test_class' => new Alias('App\\TestClass'),
|
||||
'App\\TestClass' => new Alias('app.test_class'),
|
||||
));
|
||||
|
||||
$builder->findDefinition('App\\TestClass');
|
||||
$builder->findDefinition('foo');
|
||||
}
|
||||
|
||||
public function testInitializePropertiesBeforeMethodCalls()
|
||||
|
Reference in New Issue
Block a user