fork download
  1. <?php
  2. class Test {
  3. public function Test1(int $number, string $str) { }
  4. public function Test2(bool $boolean) { }
  5. public function Test3($value) { }
  6. }
  7.  
  8. //get the information of the class.
  9. $rf = new ReflectionClass('Test');
  10.  
  11. //run through all methods.
  12. foreach ($rf->getMethods() as $method) {
  13. echo $method->name."\n";
  14.  
  15. //run through all parameters of the method.
  16. foreach ($method->getParameters() as $parameter) {
  17. echo "\t".'Name: '.$parameter->getName().' - Type: '.$parameter->getType()."\n";
  18. }
  19. }
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Test1
	Name: number - Type: int
	Name: str - Type: string
Test2
	Name: boolean - Type: bool
Test3
	Name: value - Type: