Пример #1
0
 /**
  * Get the return type of the function as defined by the doc comment.
  *
  * @return string[]
  *   The types as defined by phpdoc standard. Default is ['void'].
  */
 public function getReturnTypes()
 {
     $types = ['void'];
     $doc_comment = $this->getDocComment();
     if (!$doc_comment) {
         return $types;
     }
     $return_tag = $doc_comment->getReturn();
     if (!$return_tag) {
         return $types;
     }
     $types = Types::normalize($return_tag->getTypes());
     if (empty($types)) {
         $types[] = 'void';
     }
     return $types;
 }
Пример #2
0
 /**
  * Get the php doc types for parameter.
  *
  * @return string[]
  */
 public function getDocTypes()
 {
     // No type specified means type is mixed.
     $types = ['mixed'];
     // Use types from the doc comment if available.
     $doc_comment = $this->getFunction()->getDocComment();
     if (!$doc_comment) {
         return $types;
     }
     $param_tag = $doc_comment->getParameter($this->getName());
     if (!$param_tag) {
         return $types;
     }
     $types = Types::normalize($param_tag->getTypes());
     if (empty($types)) {
         $types[] = 'mixed';
     }
     return $types;
 }
Пример #3
0
 /**
  * Get the type of the members as defined by doc comment.
  *
  * @return string[]
  *   The types as defined by phpdoc standard. Default is ['mixed'].
  */
 public function getTypes()
 {
     // No type specified means type is mixed.
     $types = ['mixed'];
     // Use types from the doc comment if available.
     $doc_comment = $this->getDocComment();
     if (!$doc_comment) {
         return $types;
     }
     $doc_block = $doc_comment->getDocBlock();
     $var_tags = $doc_block->getTagsByName('var');
     if (empty($var_tags)) {
         return $types;
     }
     /** @var \phpDocumentor\Reflection\DocBlock\Tag\VarTag $var_tag */
     $var_tag = reset($var_tags);
     return Types::normalize($var_tag->getTypes());
 }