/** * Parses the given token reader * * @param \vc\Data\Signature $signature The base data from which to build * the method * @param \vc\Tokens\Access $access The token stream * @return \vc\Data\Routine\Method */ public function parseMethod(\vc\Data\Signature $signature, \vc\Tokens\Access $access) { $method = $signature->buildMethod(); // Continue iterating until we encounter a Function token while (TRUE) { $token = $access->peekToRequired(array(Token::T_STATIC, Token::T_ABSTRACT, Token::T_FINAL, Token::T_PUBLIC, Token::T_PROTECTED, Token::T_PRIVATE, Token::T_FUNCTION)); // We don't want to consume the function token because the routine // parser looks for it. Break before we get a chance to pop it off // the stream if ($token->is(Token::T_FUNCTION)) { break; } $access->popToken(); if ($token->is(array(Token::T_PUBLIC, Token::T_PROTECTED, Token::T_PRIVATE))) { $method->setVisibility(\vc\Data\Visibility::fromToken($token)); } else { if ($token->is(Token::T_STATIC)) { $method->setStatic(TRUE); } else { if ($token->is(Token::T_ABSTRACT)) { $method->setAbstract(TRUE); } else { if ($token->is(Token::T_FINAL)) { $method->setFinal(TRUE); } } } } } $this->routine->parseRoutine($method, $access); return $method; }
/** * Parse a function out of the given token reader * * @param \vc\Tokens\Access $access The token access * @return \vc\Data\Routine\Func */ public function parseFunc(\vc\Tokens\Access $access) { $token = $access->peekToRequired(array(Token::T_FUNCTION)); $func = new \vc\Data\Routine\Func($token->getLine(), $access->getComment()); $this->routine->parseRoutine($func, $access); return $func; }