public function __construct(FunctionToken $t) { $this->functionToken = $t; $this->name = $t->getNameToken()->getValue(); $this->visibilityToken = $t->getVisibility(); $this->staticToken = $t->getStatic(); $this->abstractToken = $t->getAbstract(); $this->classDefinitionToken = $this->determineClass(); if ($this->abstractToken) { // don't fetch opening brace if this is abstract // TODO: fetch semicolon $t = $this->functionToken; while ($t = $t->next()) { if ($t->getValue() == ';') { $this->startToken = $this->abstractToken; $this->EndToken = $t; break; } } } else { $this->startToken = $t->getStartToken($this->visibilityToken, $this->staticToken); $openBrace = $t->findOpenBrace(); $this->EndToken = $openBrace->findMatchedToken('FunctionEndToken'); } $this->setOutput(new TextFunctionDefinitionOutput($this)); }
public function render() { $name = $this->Definition->getClass() ? $this->Definition->getClass() . '::' . $this->Definition->getName() : $this->Definition->getName(); $ret = ''; if ($this->Definition->getVisibility()) { $ret .= FunctionToken::visibilityName($this->Definition->getVisibility()) . ' '; } if ($this->static) { $ret .= 'static '; } $ret .= "function {$name} ("; $file = $this->Definition->getFunctionToken()->Set()->getFile(); if ($file) { $ret .= "file: {$file}; "; } $line = $this->Definition->startToken()->line(); $endLine = $this->Definition->endToken()->line(); $ret .= "line(s): {$line} to {$endLine})"; return $ret; }