/** * Put together the namespace path and get an access object for reading the * namespace * * Collect the path to this namespace until an ending token is found. This * ending token denotes whether this namespace is wrapped in curlies or not. * * @param \vc\Data\NSpace $nspace The namespace to append to * @param \vc\Tokens\Access $access The token access * @return \vc\Tokens\Access The access object for reading the namespace */ private function buildNS(\vc\Data\NSpace $nspace, \vc\Tokens\Access $access) { $nspace->setNamespace($this->path->parsePath($access)); $token = $access->findRequired(array(Token::T_SEMICOLON, Token::T_CURLY_OPEN)); if ($token->is(Token::T_CURLY_OPEN)) { return $access->untilBlockEnds(); } else { return $access->untilTokens(array(Token::T_NAMESPACE)); } }
/** * Parses the given token reader * * @param \vc\Data\NSpace $nspace The namespace to parse data into * @param \vc\Tokens\Search $access The token access * @return NULL */ public function parseNSpace(\vc\Data\NSpace $nspace, \vc\Tokens\Access $access) { $last = NULL; // Keep looking until we have consumed all the tokens in this namespace while (TRUE) { $token = $access->peekToSkipping(array(Token::T_CLASS, Token::T_ABSTRACT, Token::T_CONST, Token::T_INTERFACE, Token::T_FUNCTION, Token::T_USE)); if (!$token) { break; } if ($token === $last) { throw new \RuntimeException('Possible Infinite Loop Detected. ' . 'Current token has already been parsed'); } $last = $token; if ($token->is(array(Token::T_CLASS, Token::T_ABSTRACT))) { $nspace->addType($this->object->parseClass($access)); } else { if ($token->is(Token::T_FUNCTION)) { $func = $this->func->parseFunc($access); // Anonymous functions have a very limited scope, so we don't // care about documenting them if (!$func->isAnonymous()) { $nspace->addFunction($func); } } else { if ($token->is(Token::T_INTERFACE)) { $nspace->addType($this->iface->parseIFace($access)); } else { if ($token->is(Token::T_CONST)) { $nspace->addConstant($this->constant->parseConstant($access)); } else { if ($token->is(Token::T_USE)) { $nspace->addAlias($this->alias->parseAlias($access)); } } } } } } }