Fix passing parameters to a controller method with default values for parameters
Fix passing parameters to a controller method with default values for parameters

For a route that looks like this:

  $app->get('/test/{param1}', 'TestController@test');

and a TestController method with a default parameter:

  public function test($param1 = 'default') {

visiting the URL "/test/param1Value" will cause Lumen to call the
method with the following parameters:

  TestController->test('default', 'param1Value');

The value in the URL will not replace $param1 default value, even
though the name in the route parameter is the same: {param1}.

The reason for that is that when this method is called:

  protected function addDependencyForCallParameter(ReflectionParameter $parameter, array &$parameters, &$dependencies)

the $parameters array contains only numeric keys. So this condition
in addDependencyForCallParameter() will never match:

if (array_key_exists($parameter->name, $parameters))
{
    $dependencies[] = $parameters[$parameter->name];

    unset($parameters[$parameter->name]);
}

Removing array_values() call on the $parameters array in the callControllerAction() method seems to fix this issue.
laravel/lumen-framework,cnanney/lumen-framework,orchestral/lumen,xiphiaz/lumen-framework,crynobone/lumen-framework,Beanhunter/lumen-framework,callam/lumen-framework,scrubmx/lumen-framework,Jaspur/lumen-framework,rlacerda83/lumen-framework,rakaaditya/lumen-framework,piokom123/lumen-framework,lasselehtinen/lumen-framework,SelimSalihovic/lumen-framework