From 1bc3b45f9f327054e2dbf25b65cd707856621302 Mon Sep 17 00:00:00 2001 From: Hans-Christian Psaar Date: Fri, 11 Feb 2022 12:36:28 +0100 Subject: [PATCH] Update http_kernel_controller_resolver.rst I stumbled upon an exception: Uncaught TypeError: LeapYearController::index(): Argument #1 ($year) must be of type int, array given, called in /var/www/web/front.php on line 32 and defined in /var/www/src/routes.php:10 This makes sense: getArguments() return indeed an array with the parameters. The index method in the LeapYearController does not expect an array at all. (new LeapYearController)->index(['year' => 2000]) is wrong, and this is happening here when an array is passed into call_user_func(). Fix: use spread operator for array destructuring / unpacking to pass in array values as variables. This is on PHP8.1 btw. --- create_framework/http_kernel_controller_resolver.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_framework/http_kernel_controller_resolver.rst b/create_framework/http_kernel_controller_resolver.rst index 12d9efead6e..b5006c6356e 100644 --- a/create_framework/http_kernel_controller_resolver.rst +++ b/create_framework/http_kernel_controller_resolver.rst @@ -78,7 +78,7 @@ resolver from HttpKernel:: $controller = $controllerResolver->getController($request); $arguments = $argumentResolver->getArguments($request, $controller); - $response = call_user_func_array($controller, $arguments); + $response = call_user_func_array($controller, ...$arguments); .. note:: @@ -190,7 +190,7 @@ Let's conclude with the new version of our framework:: $controller = $controllerResolver->getController($request); $arguments = $argumentResolver->getArguments($request, $controller); - $response = call_user_func_array($controller, $arguments); + $response = call_user_func_array($controller, ...$arguments); } catch (Routing\Exception\ResourceNotFoundException $exception) { $response = new Response('Not Found', 404); } catch (Exception $exception) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy