diff --git a/src/Illuminate/Container/BoundMethod.php b/src/Illuminate/Container/BoundMethod.php index e64ae960e7c7..e10edd5c7d4a 100644 --- a/src/Illuminate/Container/BoundMethod.php +++ b/src/Illuminate/Container/BoundMethod.php @@ -116,7 +116,7 @@ protected static function getMethodDependencies($container, $callback, array $pa static::addDependencyForCallParameter($container, $parameter, $parameters, $dependencies); } - return $parameters + $dependencies; + return array_merge($dependencies, $parameters); } /** @@ -162,8 +162,6 @@ protected static function addDependencyForCallParameter($container, $parameter, $dependencies[] = $container->make($parameter->getClass()->name); } elseif ($parameter->isDefaultValueAvailable()) { $dependencies[] = $parameter->getDefaultValue(); - } else { - $dependencies[] = null; } } diff --git a/tests/Container/ContainerTest.php b/tests/Container/ContainerTest.php index d54d71dc000b..07ba41ee36ee 100755 --- a/tests/Container/ContainerTest.php +++ b/tests/Container/ContainerTest.php @@ -516,77 +516,6 @@ public function testCallWithDependencies() $this->assertEquals('taylor', $result[1]); } - public function testWithDefaultParametersIndexedArraySyntax() - { - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaulty', ['foo', 'bar']); - - $this->assertEquals(['foo', 'bar', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaulty', ['foo', 'bar', 'baz']); - - $this->assertEquals(['foo', 'bar', 'baz'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaulty'); - - $this->assertEquals(['default a', 'default b', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaultyBandC', ['foo', 'bar']); - - $this->assertEquals(['foo', 'bar', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaultyBandC', ['foo']); - - $this->assertEquals(['foo', 'default b', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaultyOnlyC', ['foo', 'bar']); - - $this->assertEquals(['foo', 'bar', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@noDefault', ['foo', 'bar', 'baz']); - - $this->assertEquals(['foo', 'bar', 'baz'], $result); - } - - public function testWithDefaultParametersAssociativeSyntax() - { - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaulty', ['a' => 'foo', 'b' => 'bar']); - - $this->assertEquals(['foo', 'bar', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaulty', ['a' => 'foo', 'b' => 'bar', 'c' => 'baz']); - - $this->assertEquals(['foo', 'bar', 'baz'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaultyBandC', ['a' => 'foo', 'b' => 'bar']); - - $this->assertEquals(['foo', 'bar', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaultyBandC', ['a' => 'foo']); - - $this->assertEquals(['foo', 'default b', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@defaultyOnlyC', ['a' => 'foo', 'b' => 'bar']); - - $this->assertEquals(['foo', 'bar', 'default c'], $result); - - $container = new Container; - $result = $container->call(ContainerTestDefaultyParams::class.'@noDefault', ['a' => 'foo', 'b' => 'bar', 'c' => 'baz']); - - $this->assertEquals(['foo', 'bar', 'baz'], $result); - } - /** * @expectedException \ReflectionException * @expectedExceptionMessage Function ContainerTestCallStub() does not exist @@ -1342,26 +1271,3 @@ public function __construct() static::$instantiations++; } } - -class ContainerTestDefaultyParams -{ - public function defaulty($a = 'default a', $b = 'default b', $c = 'default c') - { - return func_get_args(); - } - - public function defaultyBandC($a, $b = 'default b', $c = 'default c') - { - return func_get_args(); - } - - public function defaultyOnlyC($a, $b, $c = 'default c') - { - return func_get_args(); - } - - public function noDefault($a, $b, $c) - { - return func_get_args(); - } -}