I am looking for a way to return multiple parameters in a function. I am building a routing system for my MVC framework. And currently I am working on a way to get unlimited arguments in a function, based on an HTTP request;
This is the part I am stuck on. Look on the bottom of the code $controller->{$route->getMethod()}();
The controller calls a function, and now I need to get a solution to add values in de function. I can do $controller->{$route->getMethod()}($route->getArgs();
But then only the first argument will be set. How can I return more than one argument in that function?
public function dispatchRoute(Route $route)
{
if(!file_exists($this->pathToController . '/' . ucfirst($route->getController()) . 'Controller.php'))
throw new \Exception(
sprintf('Cannot find %sController.php in directory %s', $route->getController(), $this->pathToController));
require_once($this->pathToController . '/' . ucfirst($route->getController()) . 'Controller.php');
$controller = $route->getController() . 'Controller';
$controller = new $controller();
if(!method_exists($controller, $route->getMethod()))
throw new \Exception(sprintf('Method %s is not found in %sController', $route->getMethod(), $route->getController()));
$dataHandler = new RequestDataHandler();
$dataHandler->getRequestArguments();
$controller->{$route->getMethod()}();
}