In PHP Consider this function:
function test($name, $age) {}
I need to somehow extract the parameter names (for generating custom documenta
It's 2019 and no one said this?
Just use get_defined_vars():
get_defined_vars()
class Foo { public function bar($a, $b) { var_dump(get_defined_vars()); } } (new Foo)->bar('first', 'second');
Result:
array(2) { ["a"]=> string(5) "first" ["b"]=> string(6) "second" }