本文整理汇总了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();
}
}