dimanche 15 octobre 2017

PHP ReflectionMethod does not get default boolean value of param

When I try to get the value of a boolean param, with ReflectionMethod, that have a default value set, I got empty result.

With this code:

    public function GetOrderBook($symbol = null, $limit = 100, $async = false)
    {
        if ($symbol !== null) {

            $params = [];
            $ref = new \ReflectionMethod($this, 'GetOrderBook');

            foreach ($ref->getParameters() as $param) {
                $name = $param->name;
                $params[$name] = $$name;
            }

            print_r($params);
        }
    }

I get this:

 Array ( 
      [symbol] => ETHBTC 
      [limit] => 100 
      [async] => 
 ) 

Is there a way to get the default value of a param with reflection?





Aucun commentaire:

Enregistrer un commentaire