From 75a16ba85b50a8baa1ea87dfe91b826793114a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 14 Jun 2016 12:53:45 +0100 Subject: [PATCH] Make alias resolution recursive --- src/Illuminate/Container/Container.php | 7 ++++++- tests/Container/ContainerTest.php | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Container/Container.php b/src/Illuminate/Container/Container.php index ee38ee502000..9adc789da0e4 100755 --- a/src/Illuminate/Container/Container.php +++ b/src/Illuminate/Container/Container.php @@ -1062,7 +1062,12 @@ protected function isBuildable($concrete, $abstract) */ protected function getAlias($abstract) { - return isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract; + if (! isset($this->aliases[$abstract])) { + return $abstract; + } + $abstract = $this->aliases[$abstract]; + + return $this->getAlias($abstract); } /** diff --git a/tests/Container/ContainerTest.php b/tests/Container/ContainerTest.php index b0916159292b..494b9ea69b05 100755 --- a/tests/Container/ContainerTest.php +++ b/tests/Container/ContainerTest.php @@ -114,8 +114,10 @@ public function testAliases() $container = new Container; $container['foo'] = 'bar'; $container->alias('foo', 'baz'); + $container->alias('baz', 'bat'); $this->assertEquals('bar', $container->make('foo')); $this->assertEquals('bar', $container->make('baz')); + $this->assertEquals('bar', $container->make('bat')); $container->bind(['bam' => 'boom'], function () { return 'pow'; });