It is also possible to do reflection from within the class and get the methods for instance.
<?php
class test
{
private $test = "";
public function setTest($test)
{
$this->test = $test;
return $this;
}
public function getTest()
{
return $this->test;
}
public function run(){
$class = new ReflectionClass('test');
$methods = $class->getMethods();
var_dump($methods);
}
}
Called from another php file you get the proper result:
array(3) {
[0]=>
&object(ReflectionMethod)#3 (2) {
["name"]=>
string(8) "setTest"
["class"]=>
string(4) "test"
}
[1]=>
&object(ReflectionMethod)#4 (2) {
["name"]=>
string(8) "getTest"
["class"]=>
string(4) "test"
}
[2]=>
&object(ReflectionMethod)#5 (2) {
["name"]=>
string(3) "run"
["class"]=>
string(4) "test"
}
}