From 6dcca5235227de4f293559fcdeecdd532b1998ad Mon Sep 17 00:00:00 2001 From: lighe Date: Fri, 5 May 2017 14:12:25 +0100 Subject: [PATCH 1/4] resolve aliases from container when using parameters --- src/Illuminate/Container/Container.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Container/Container.php b/src/Illuminate/Container/Container.php index 1b2bad943338..750c419fea36 100755 --- a/src/Illuminate/Container/Container.php +++ b/src/Illuminate/Container/Container.php @@ -576,8 +576,10 @@ public function make($abstract) */ protected function resolve($abstract, $parameters = []) { + $abstract = $this->getAlias($abstract); + $needsContextualBuild = ! empty($parameters) || ! is_null( - $this->getContextualConcrete($abstract = $this->getAlias($abstract)) + $this->getContextualConcrete($abstract) ); // If an instance of the type is currently being managed as a singleton we'll From 507ae7312b95220b07a69f6df68f4caa8051d515 Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Fri, 5 May 2017 14:38:37 +0100 Subject: [PATCH 2/4] Fix code style issue by removing empty spaces. --- src/Illuminate/Container/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Container/Container.php b/src/Illuminate/Container/Container.php index 750c419fea36..4fc82f1c133c 100755 --- a/src/Illuminate/Container/Container.php +++ b/src/Illuminate/Container/Container.php @@ -577,7 +577,7 @@ public function make($abstract) protected function resolve($abstract, $parameters = []) { $abstract = $this->getAlias($abstract); - + $needsContextualBuild = ! empty($parameters) || ! is_null( $this->getContextualConcrete($abstract) ); From 28decb14eb1d7dbe30189b8d31aa26fa68c1163e Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Fri, 5 May 2017 15:32:19 +0100 Subject: [PATCH 3/4] Add test for resolving aliases from the container with parameters. --- tests/Container/ContainerTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Container/ContainerTest.php b/tests/Container/ContainerTest.php index f9f15faa8910..1530ac7894f4 100755 --- a/tests/Container/ContainerTest.php +++ b/tests/Container/ContainerTest.php @@ -121,6 +121,16 @@ public function testAliases() $this->assertEquals('bar', $container->make('bat')); } + public function testAliasesWithArrayOfParameters() + { + $container = new Container; + $container->bind('foo', function($app, $config) { + return $config; + }); + $container->alias('foo', 'baz'); + $this->assertEquals([1, 2, 3], $container->makeWith('baz', [1, 2, 3])); + } + public function testBindingsCanBeOverridden() { $container = new Container; From eb8997330afaee1d5ebdbbe025ee8f684bf8806d Mon Sep 17 00:00:00 2001 From: Alexandru Lighezan Date: Fri, 5 May 2017 15:33:27 +0100 Subject: [PATCH 4/4] Fix styling issue in testAliasesWithArrayOfParameters() --- tests/Container/ContainerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Container/ContainerTest.php b/tests/Container/ContainerTest.php index 1530ac7894f4..7156080dc24f 100755 --- a/tests/Container/ContainerTest.php +++ b/tests/Container/ContainerTest.php @@ -124,7 +124,7 @@ public function testAliases() public function testAliasesWithArrayOfParameters() { $container = new Container; - $container->bind('foo', function($app, $config) { + $container->bind('foo', function ($app, $config) { return $config; }); $container->alias('foo', 'baz');