* @since 2.0 */ class FunctionDoc extends BaseDoc { /** * @var ParamDoc[] */ public $params = []; public $exceptions = []; public $return; public $returnType; public $returnTypes; public $isReturnByReference; /** * @param \phpDocumentor\Reflection\FunctionReflector $reflector * @param array $config */ public function __construct($reflector = null, $config = []) { parent::__construct($reflector, $config); if ($reflector === null) { return; } $this->isReturnByReference = $reflector->isByRef(); foreach($reflector->getArguments() as $arg) { $arg = new ParamDoc($arg); $this->params[$arg->name] = $arg; } foreach($this->tags as $i => $tag) { if ($tag instanceof ThrowsTag) { $this->exceptions[$tag->getType()] = $tag->getDescription(); unset($this->tags[$i]); } elseif ($tag instanceof PropertyTag) { // ignore property tag } elseif ($tag instanceof ParamTag) { $paramName = $tag->getVariableName(); if (!isset($this->params[$paramName])) { echo 'undefined parameter documented: ' . $paramName . ' in ' . $this->name . "\n"; // todo add this to a log file } $this->params[$paramName]->description = ucfirst($tag->getDescription()); $this->params[$paramName]->type = $tag->getType(); $this->params[$paramName]->types = $tag->getTypes(); unset($this->tags[$i]); } elseif ($tag instanceof ReturnTag) { $this->returnType = $tag->getType(); $this->returnTypes = $tag->getTypes(); $this->return = $tag->getDescription(); unset($this->tags[$i]); } } } }