Skip to content

Commit

Permalink
Make alias resolution recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Jun 14, 2016
1 parent 163efce commit d236b89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Container/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
});
Expand Down

0 comments on commit d236b89

Please sign in to comment.