fork download
  1. <?php
  2.  
  3. class X
  4. {
  5. public function a($x, $y = null)
  6. {
  7.  
  8. }
  9. }
  10.  
  11. $z = new ReflectionMethod('X', 'a');
  12.  
  13. $p = $z->getParameters();
  14.  
  15. var_dump($p, $p[1]->isOptional());
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  &object(ReflectionParameter)#2 (1) {
    ["name"]=>
    string(1) "x"
  }
  [1]=>
  object(ReflectionParameter)#3 (1) {
    ["name"]=>
    string(1) "y"
  }
}
bool(true)