本文整理匯總了PHP中Twig_Token::EOF方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Token::EOF方法的具體用法?PHP Twig_Token::EOF怎麽用?PHP Twig_Token::EOF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twig_Token
的用法示例。
在下文中一共展示了Twig_Token::EOF方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: nextToken
/**
* parse the nex token and return it.
*/
public function nextToken()
{
// do we have tokens pushed back? get one
if (!empty($this->pushedBack)) {
return array_shift($this->pushedBack);
}
// have we reached the end of the code?
if ($this->cursor >= $this->end) {
return Twig_Token::EOF($this->lineno);
}
// otherwise dispatch to the lexing functions depending
// on our current position in the code.
switch ($this->position) {
case self::POSITION_DATA:
$tokens = $this->lexData();
break;
case self::POSITION_BLOCK:
$tokens = $this->lexBlock();
break;
case self::POSITION_VAR:
$tokens = $this->lexVar();
break;
}
// if the return value is not an array it's a token
if (!is_array($tokens)) {
return $tokens;
} else {
if (empty($tokens)) {
return $this->nextToken();
} else {
if (count($tokens) > 1) {
$first = array_shift($tokens);
$this->pushedBack = $tokens;
return $first;
}
}
}
// otherwise return the first item of the array.
return $tokens[0];
}