Skip to content

Commit

Permalink
Merge pull request #1 from lucasmichot/fix-5925
Browse files Browse the repository at this point in the history
Fix PR alignment
  • Loading branch information
mvalim committed Sep 30, 2014
2 parents 97c1880 + 120fe49 commit 137c0db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,25 +523,28 @@ public function call($callback, array $parameters = array(), $defaultMethod = nu
return $this->callClass($callback, $parameters, $defaultMethod);
}

$dependencies = $this->getMethodDependencies($callback,$parameters);
$dependencies = $this->getMethodDependencies($callback, $parameters);

return call_user_func_array($callback, $dependencies);
}

/**
* Get all dependencies for a given method
* Get all dependencies for a given method.
*
* @param \Closure|array $callback
* @param array $parameters
* @return array
*/
protected function getMethodDependencies($callback,$parameters = array()) {
protected function getMethodDependencies($callback, $parameters = [])
{
$dependencies = [];

foreach ($this->getCallReflector($callback)->getParameters() as $key => $parameter)
{
$dependencies[] = $this->getDependencyForCallParameter($parameter, $parameters);
}

return array_merge($dependencies,$parameters);
return array_merge($dependencies, $parameters);
}

/**
Expand Down Expand Up @@ -612,7 +615,7 @@ protected function callClass($target, array $parameters = array(), $defaultMetho
// received in this method into this listener class instance's methods.
$callable = array($this->make($segments[0]), $method);

$dependencies = $this->getMethodDependencies($callable,$parameters);
$dependencies = $this->getMethodDependencies($callable, $parameters);

return call_user_func_array($callable, $dependencies);
}
Expand Down
14 changes: 8 additions & 6 deletions tests/Container/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,13 @@ public function testCallWithAtSignBasedClassReferences()

$container = new Container;
$result = $container->call('ContainerTestCallStub@inject');
$this->assertInstanceOf('ContainerConcreteStub',$result[0]);
$this->assertEquals('taylor',$result[1]);
$this->assertInstanceOf('ContainerConcreteStub', $result[0]);
$this->assertEquals('taylor', $result[1]);

$container = new Container;
$result = $container->call('ContainerTestCallStub@inject',['default'=>'foo']);
$this->assertInstanceOf('ContainerConcreteStub',$result[0]);
$this->assertEquals('foo',$result[1]);
$result = $container->call('ContainerTestCallStub@inject', ['default' => 'foo']);
$this->assertInstanceOf('ContainerConcreteStub', $result[0]);
$this->assertEquals('foo', $result[1]);

$container = new Container;
$result = $container->call('ContainerTestCallStub', ['foo', 'bar'], 'work');
Expand Down Expand Up @@ -510,7 +510,9 @@ class ContainerTestCallStub {
public function work() {
return func_get_args();
}
public function inject(ContainerConcreteStub $stub,$default = 'taylor') {

public function inject(ContainerConcreteStub $stub, $default = 'taylor')
{
return func_get_args();
}
}
Expand Down

0 comments on commit 137c0db

Please sign in to comment.