I’m making an MVC-framework in PHP and am trying to recreate a beautiful feature from C# MVC 4. As follows:
class MyController
{
public function MyFunction ($id, $name)
{
// Do something with id and name
}
}
This function is an example function inside a controller. The id and name should contain the same as $_GET[“id”] etc. To make it so i need to know the names of the function parameters from outside of the function.
Pseudocode:
$myController = new MyController();
$controllerArgumentsArray = functionToGetArgumentNames($myController->MyFunction());
print_r($controllerArgumentsArray)
array([0] = "id", [1] = "name")
From here I could now use the “call_user_func_array” to set the values in the function to its correct relatives in the $_GET variable.
Is there any possible way to achieve this?
See: http://php.net/manual/class.reflectionmethod.php