本文整理匯總了PHP中Twig_Token::getType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Token::getType方法的具體用法?PHP Twig_Token::getType怎麽用?PHP Twig_Token::getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twig_Token
的用法示例。
在下文中一共展示了Twig_Token::getType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: expect
private function expect($filename, \Twig_Token $token, $type, $value = null)
{
if ($token->getType() !== $type) {
throw new \RuntimeException(sprintf('Parse error in %s at line %d. Expected %s%s, got %s.', $filename, $token->getLine(), \Twig_Token::typeToEnglish($type), $value !== null ? ' "' . $value . '"' : '', \Twig_Token::typeToEnglish($token->getType())));
}
}
示例2: parseStringAttribute
/**
* Parses a string attribute token, saving it as either the title, link URL, or link text
*
* @param \Twig_Token $token The token to parse
* @param \Twig_TokenStream $stream The token stream being traversed
* @return void
*/
protected function parseStringAttribute(\Twig_Token $token, \Twig_TokenStream $stream)
{
if (!$token->test(\Twig_Token::STRING_TYPE)) {
throw new RuntimeException(sprintf("Expected string token but received '%s' instead", \Twig_Token::typeToEnglish($token->getType())), $stream->getCurrent()->getLine(), $stream->getFilename());
}
// If any of these values has already been set, then set the next
// property with this string. The string order that must be followed
// in the codeblock tag is: title, url, link text
if (empty($this->attributes['title'])) {
$this->attributes['title'] = $token->getValue();
} elseif (empty($this->attributes['linkUrl'])) {
$this->attributes['linkUrl'] = $token->getValue();
} elseif (empty($this->attributes['linkText'])) {
$this->attributes['linkText'] = $token->getValue();
}
}