Question: i'm testing php's reflection with default params like this...

```
class Test{

  public function testMethod($class,$methodName){
     // the returned values
     $data = array();

    // get the method of the class passed by params
    $funcHandler = new ReflectionMethod($class,$methodName);

    // iterates through the parameters to catch de default values
    foreach ($funcHandler->getParameters() as $param){
      // instance the params to get the properties for that method
      $paramDetail = new ReflectionParameter(array($class, $method),$param->name);
      // check if that param is or has a default value attached like (public function method($a,$b,$c = false, $d = null)
      $data[$param->name] = ($paramDetail->isDefaultValueAvailable) ? funcHandler->getDefaultValue : '';

        return $data;
      }
   }

//let's test the reflection with the method params...
class Foo{

    public function method1($a,$b,$c = false, $d = null, $e = 'hello'){
     // instance of the Test Class
     $obj = new Test();

     // calling the test method with this class and method names
     print_r($obj->testMethod(__CLASS__,__FUNCTION__));

    }

}

```

The problem is that the line "new ReflectionParameter(array($class, $method),$param->name);"
 when executing "$data[$param->name] = ($paramDetail->isDefaultValueAvailable) ? "
says that has no isDefaultValueAvailable nor isOptional.

Any ideas how to extract from a class method optional params?
It seems to work fine with functions.

Answer: 
The [ReflectionParameter](http://php.net/manual/en/class.reflectionparameter.php) class has an [isOptional()](http://php.net/manual/en/reflectionparameter.isoptional.php) method, that will tell you if the parameter is optional or not (and it can be optional only if it has a default value), if it is optional, you can call the [getDefaultValue()](http://php.net/manual/en/reflectionparameter.getdefaultvalue.php) to extract the default.

here's your code patched to use them:

```
<?php
class Test {

    public function testMethod($class,$methodName){
        // the returned values
        $data = array();

        // get the method of the class passed by params
        $funcHandler = new ReflectionMethod($class,$methodName);

        // iterates through the parameters to catch de default values
        foreach ($funcHandler->getParameters() as $param){
            // the new ReflectionParameter ... not needed, getParameters() already give you ReflectionParameter instances
            // check if that param (a ReflectionParameter instance) has a default value attached like (public function method($a,$b,$c = false, $d = null)
            $data[$param->name] = ($param->isOptional()) ? $param->getDefaultValue() : '';
        }
        return $data;
    }
}

//let's test the reflection with the method params...
class Foo{

    public function method1($a,$b,$c = false, $d = null, $e = 'hello'){
        // instance of the Test Class
        $obj = new Test();

        // calling the test method with this class and method names
        var_dump($obj->testMethod(__CLASS__,__FUNCTION__));

    }

}

$f = new Foo;
$f->method1('a', 'b');

```

output:

```
array(5) {
  ["a"]=>
  string(0) ""
  ["b"]=>
  string(0) ""
  ["c"]=>
  bool(false)
  ["d"]=>
  NULL
  ["e"]=>
  string(5) "hello"
}

```
isOptional and isDefaultValueAvailable are both methods not properties.