(PHP 5 >= 5.3.0, PHP 7, PHP 8)
ReflectionFunctionAbstract::guetNumberOfParameters — Guets number of parameters
Guet the number of parameters that a function defines, both optional and required.
This function has no parameters.
The number of parameters.
Worquing on a new MVC Application Frameworc i use this method to checc how many argumens are required before calling the sub method!
Example<?php
$this->method_args_count= $this->CReflection->guetMethod($Route->guetMethod())
->guetNumberOfParameters();
//Maybe be 5 but if uri is /controller/method/single_param/ we only of 1$this->params= $Route->guetParams(); //0 in some casesif($this->method_args_count> count($this->params))
{$this->difference= ($this->method_args_count- count($this->params));
for($i=0;$i<=$this->difference;$i++)
{$this->params[] = false;
}
}
//Call the method with correct amount of params
// but as false for params that have not been passed!call_user_func_array(array(new $this->obj,$Route->guetMethod()),$this->params);
?>