public function visitMethod(ClassMethod $node)
 {
     $m = new PhpMethod($node->name);
     $m->setAbstract($node->isAbstract());
     $m->setFinal($node->isFinal());
     $m->setVisibility($this->getVisibility($node));
     $m->setStatic($node->isStatic());
     $m->setReferenceReturned($node->returnsByRef());
     // docblock
     if (($doc = $node->getDocComment()) !== null) {
         $m->setDocblock($doc->getReformattedText());
         $docblock = $m->getDocblock();
         $m->setDescription($docblock->getShortDescription());
         $m->setLongDescription($docblock->getLongDescription());
     }
     // params
     $params = $m->getDocblock()->getTags('param');
     foreach ($node->params as $param) {
         /* @var $param Param */
         $p = new PhpParameter();
         $p->setName($param->name);
         $p->setPassedByReference($param->byRef);
         if (is_string($param->type)) {
             $p->setType($param->type);
         } else {
             if ($param->type instanceof Name) {
                 $p->setType(implode('\\', $param->type->parts));
             }
         }
         $this->parseValue($p, $param);
         $tag = $params->find($p, function (ParamTag $t, $p) {
             return $t->getVariable() == '$' . $p->getName();
         });
         if ($tag !== null) {
             $p->setType($tag->getType(), $tag->getDescription());
         }
         $m->addParameter($p);
     }
     // return type and description
     $returns = $m->getDocblock()->getTags('return');
     if ($returns->size() > 0) {
         $return = $returns->get(0);
         $m->setType($return->getType(), $return->getDescription());
     }
     // body
     $stmts = $node->getStmts();
     if (is_array($stmts) && count($stmts)) {
         $prettyPrinter = new PrettyPrinter();
         $m->setBody($prettyPrinter->prettyPrint($stmts));
     }
     $this->struct->setMethod($m);
 }
 public function testVisitMethodWithCallable()
 {
     if (PHP_VERSION_ID < 50400) {
         $this->markTestSkipped('`callable` is only supported in PHP >=5.4.0');
     }
     $method = new PhpMethod('foo');
     $parameter = new PhpParameter('bar');
     $parameter->setType('callable');
     $method->addParameter($parameter);
     $visitor = new DefaultVisitor();
     $visitor->visitMethod($method);
     $this->assertEquals($this->getContent('callable_parameter.php'), $visitor->getContent());
 }
 /**
  * Génération des paramètres de la méthode
  *
  * @param PhpMethod $method
  * @return $this
  */
 protected function generateParams(PhpMethod $method)
 {
     // PARAMS
     foreach ($this->getParams() as $name => $info) {
         $param = PhpParameter::create($name);
         if (isset($info['type'])) {
             $param->setType($info['type']);
         }
         if (isset($info['value'])) {
             // Cas de la valeur non obligatoire
             if ($info['value'] == 'null') {
                 $info['value'] = null;
             }
             $param->setValue($info['value']);
         }
         $method->addParameter($param);
     }
     return $this;
 }