/** * Get the type of the parameter as defined by type hinting or doc comment. * * @return string[] * The types as defined by phpdoc standard. Default is ['mixed']. */ public function getTypes() { // If type hint is set then that is the type of the parameter. if ($this->typeHint) { if ($this->typeHint instanceof TokenNode) { if ($this->typeHint->getType() === T_ARRAY) { $docTypes = $this->getDocTypes(); foreach ($docTypes as $docType) { if ($docType !== 'array' && substr($docType, -2) !== '[]') { return [$this->typeHint->getText()]; } } return $docTypes; } else { return [$this->typeHint->getText()]; } } else { return [$this->typeHint->getAbsolutePath()]; } } return $this->getDocTypes(); }
public function visitTokenNode(TokenNode $node) { switch ($node->getType()) { case T_DOUBLE_ARROW: $this->spaceBefore($node); $this->spaceAfter($node); break; } }
/** * Move iterator to next non hidden token. * @param bool $capture_doc_comment */ private function nextToken($capture_doc_comment = FALSE) { $this->iterator->next(); $capture_doc_comment ? $this->skipHiddenCaptureDocComment() : $this->skipHidden(); $this->current = $this->iterator->current(); if ($this->current) { $this->currentType = $this->current->getType(); } else { $this->currentType = NULL; } }