fork download
  1. <?php
  2. class Test {
  3. public function Test1(
  4. ?Category $category = null,
  5. ?string $name = null,
  6. ?string $description = null,
  7. ?int $price = null,
  8. ?bool $active = null) { }
  9. }
  10.  
  11. //get the information about a specific method.
  12. $rm = new ReflectionMethod('Test', 'Test1');
  13.  
  14. //get all parameter names and parameter types of the method.
  15. foreach ($rm->getParameters() as $parameter) {
  16. echo 'Name: '.$parameter->getName().' - Type: '.$parameter->getType()."\n";
  17. }
Success #stdin #stdout 0.03s 25832KB
stdin
Standard input is empty
stdout
Name: category - Type: Category
Name: name - Type: string
Name: description - Type: string
Name: price - Type: int
Name: active - Type: bool