File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -993,8 +993,15 @@ public function findDefinition($id)
993
993
{
994
994
$ id = $ this ->normalizeId ($ id );
995
995
996
+ $ seen = array ();
996
997
while (isset ($ this ->aliasDefinitions [$ id ])) {
997
998
$ id = (string ) $ this ->aliasDefinitions [$ id ];
999
+
1000
+ if (isset ($ seen [$ id ])) {
1001
+ throw new ServiceCircularReferenceException ($ id , array_keys ($ seen ));
1002
+ }
1003
+
1004
+ $ seen [$ id ] = true ;
998
1005
}
999
1006
1000
1007
return $ this ->getDefinition ($ id );
Original file line number Diff line number Diff line change @@ -1044,6 +1044,22 @@ public function testInlinedDefinitions()
1044
1044
$ this ->assertNotSame ($ bar ->foo , $ barUser ->foo );
1045
1045
}
1046
1046
1047
+ /**
1048
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
1049
+ * @expectedExceptionMessage Circular reference detected for service "app.test_class", path: "app.test_class -> App\TestClass".
1050
+ */
1051
+ public function testThrowsCircularExceptionForCircularAliases ()
1052
+ {
1053
+ $ builder = new ContainerBuilder ();
1054
+
1055
+ $ builder ->setAliases (array(
1056
+ 'app.test_class ' => new Alias ('App \\TestClass ' ),
1057
+ 'App \\TestClass ' => new Alias ('app.test_class ' ),
1058
+ ]);
1059
+
1060
+ $ builder ->findDefinition ('App \\TestClass ' );
1061
+ }
1062
+
1047
1063
public function testInitializePropertiesBeforeMethodCalls ()
1048
1064
{
1049
1065
$ container = new ContainerBuilder ();
You can’t perform that action at this time.
0 commit comments