Reputation: 3248
I'm working on a plugin system for my CMS, to make the event registering system easy I need a function that can do the following.
I need to have a function that will return all functions from a specified class with the classes of their parameters. Of course, it's fine if the function to get the functions from a class and the function to get all the class names of the parameters of a function are different.
For example if you have the following class with these functions;
class MyClass {
public function myFunction(Event $event) {
// Function code
}
}
It would be awesome if something like this could be returned;
Array() {
'myFunction' => Array() {
0 => 'Event'
}
}
Is there a way to do this?
Thanks in advance, Tim Visée
Upvotes: 2
Views: 253
Reputation: 9576
You are exactly referring to the Reflection API. Reflecting classes or methods could lead you to do what you need. For example, try that:
$class = new ReflectionClass('MyClass');
$methods = $class->getMethods();
print_r($methods);
foreach ($methods as $method) {
print_r($method->getParameters());
}
Upvotes: 4