Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fixes route model binding when additional non reflected parameters are present #52261

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Illuminate/Routing/ResolvesRouteDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA
{
$instanceCount = 0;

// filters out non-reflected parameters
$parameters = array_filter($parameters, function ($index) use ($reflector) {
return in_array($index, array_map(fn ($parameter) => $parameter->name, $reflector->getParameters()));
}, ARRAY_FILTER_USE_KEY);

$values = array_values($parameters);

$skippableValue = new stdClass;
Expand Down Expand Up @@ -73,7 +78,7 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA
protected function transformDependency(ReflectionParameter $parameter, $parameters, $skippableValue)
{
$className = Reflector::getParameterClassName($parameter);

dd($className);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be causing tests to fail

// If the parameter has a type-hinted class, we will check to see if it is already in
// the list of parameters. If it is we will just skip it as it is probably a model
// binding and we do not want to mess with those; otherwise, we resolve it here.
Expand Down
Loading