Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
Fix issue with parameter order
Browse files Browse the repository at this point in the history
For more information see
laravel/framework#22687
  • Loading branch information
tssge committed Jan 8, 2018
1 parent 2168ecc commit d696633
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion BoundMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use ReflectionMethod;
use ReflectionFunction;
use InvalidArgumentException;
use Illuminate\Contracts\Container\BindingResolutionException;

class BoundMethod
{
Expand Down Expand Up @@ -116,7 +117,7 @@ protected static function getMethodDependencies($container, $callback, array $pa
static::addDependencyForCallParameter($container, $parameter, $parameters, $dependencies);
}

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

/**
Expand Down Expand Up @@ -156,6 +157,11 @@ protected static function addDependencyForCallParameter($container, $parameter,
$dependencies[] = $container->make($parameter->getClass()->name);
} elseif ($parameter->isDefaultValueAvailable()) {
$dependencies[] = $parameter->getDefaultValue();
} elseif (is_numeric(key($parameters))) {
$dependencies[] = array_shift($parameters);
} else {
$message = "Unresolvable dependency resolving [$parameter]";
throw new BindingResolutionException($message);
}
}

Expand Down

0 comments on commit d696633

Please sign in to comment.