Get method's arguments?

34,285

You can use reflection...

$r = new ReflectionMethod($className, $methodName);
$params = $r->getParameters();
foreach ($params as $param) {
    //$param is an instance of ReflectionParameter
    echo $param->getName();
    echo $param->isOptional();
}
Share:
34,285
Rakward
Author by

Rakward

Junior Webdeveloper, Gamer, Metalhead

Updated on November 18, 2021

Comments

  • Rakward
    Rakward over 2 years

    I can check all available methods for an object like so:

    $methods = get_class_methods($object);
    

    But how can I see which arguments have to be sent to these methods?

    Is there a function for this?