Skip to content

Commit d4b4e18

Browse files
lighetaylorotwell
authored andcommitted
resolve aliases from container when using parameters (#19071)
* resolve aliases from container when using parameters * Fix code style issue by removing empty spaces. * Add test for resolving aliases from the container with parameters. * Fix styling issue in testAliasesWithArrayOfParameters()
1 parent 6dfdb4d commit d4b4e18

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Illuminate/Container/Container.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,10 @@ public function make($abstract)
576576
*/
577577
protected function resolve($abstract, $parameters = [])
578578
{
579+
$abstract = $this->getAlias($abstract);
580+
579581
$needsContextualBuild = ! empty($parameters) || ! is_null(
580-
$this->getContextualConcrete($abstract = $this->getAlias($abstract))
582+
$this->getContextualConcrete($abstract)
581583
);
582584

583585
// If an instance of the type is currently being managed as a singleton we'll

tests/Container/ContainerTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ public function testAliases()
121121
$this->assertEquals('bar', $container->make('bat'));
122122
}
123123

124+
public function testAliasesWithArrayOfParameters()
125+
{
126+
$container = new Container;
127+
$container->bind('foo', function ($app, $config) {
128+
return $config;
129+
});
130+
$container->alias('foo', 'baz');
131+
$this->assertEquals([1, 2, 3], $container->makeWith('baz', [1, 2, 3]));
132+
}
133+
124134
public function testBindingsCanBeOverridden()
125135
{
126136
$container = new Container;

0 commit comments

Comments
 (0)