From ef980435f2938ffd95d3c1ed8c97707c6e163546 Mon Sep 17 00:00:00 2001 From: Jimmy Aldape Date: Wed, 24 Jul 2024 23:58:46 -0700 Subject: [PATCH 1/2] Filters out non-reflected parameters --- src/Illuminate/Routing/ResolvesRouteDependencies.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Routing/ResolvesRouteDependencies.php b/src/Illuminate/Routing/ResolvesRouteDependencies.php index f5fc2fcb2a31..87964181a944 100644 --- a/src/Illuminate/Routing/ResolvesRouteDependencies.php +++ b/src/Illuminate/Routing/ResolvesRouteDependencies.php @@ -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; @@ -73,7 +78,7 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA protected function transformDependency(ReflectionParameter $parameter, $parameters, $skippableValue) { $className = Reflector::getParameterClassName($parameter); - +dd($className); // 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. From 22a160fd17ab703d7a6c43219d4f72b11dde252b Mon Sep 17 00:00:00 2001 From: Jimmy Aldape Date: Thu, 25 Jul 2024 00:11:59 -0700 Subject: [PATCH 2/2] cleanup --- src/Illuminate/Routing/ResolvesRouteDependencies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Routing/ResolvesRouteDependencies.php b/src/Illuminate/Routing/ResolvesRouteDependencies.php index 87964181a944..034ba77332a9 100644 --- a/src/Illuminate/Routing/ResolvesRouteDependencies.php +++ b/src/Illuminate/Routing/ResolvesRouteDependencies.php @@ -78,7 +78,7 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA protected function transformDependency(ReflectionParameter $parameter, $parameters, $skippableValue) { $className = Reflector::getParameterClassName($parameter); -dd($className); + // 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.