本文整理汇总了PHP中Token::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::getContent方法的具体用法?PHP Token::getContent怎么用?PHP Token::getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::getContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: precedence
/**
* Verificação da Precedência
* @param Token $tokenA Token para Verificação
* @param Token $tokenB Token para Verificação
* @throws Exception Token de Tipo Não Operador
* @return int Comparação de Precedências dos Tokens
*/
public function precedence($tokenA, $tokenB)
{
/* @todo Checar Precedência */
$precedenceA = $this->_mapper[$tokenA->getContent()];
$precedenceB = $this->_mapper[$tokenB->getContent()];
return $precedenceA - $precedenceB;
}
示例2: _getParseTokenFromToken
protected function _getParseTokenFromToken(Token $token)
{
$code = $token->getCode();
if ($code === "WHILE_START") {
$code = "WHILE";
}
return new ParseToken($code, $token->getContent(), $token->getChar(), $token->getLine());
}
示例3: nest
/**
* Given the set of matches, nest them according to their types
*
* @param \ArrayIterator $result Iterator of match results
* @param \SalesforceEng\Breakout\Token $latest Token instance
* @return array Set of nested token instances (arrays)
*/
public function nest(&$result, $latest = null)
{
$container = [];
if (!$result instanceof \ArrayIterator) {
$result = new \ArrayIterator($result);
}
while ($result->valid()) {
$current = new Token($result->current());
$result->next();
if ($current->getType() == 'block') {
// see if we're closing it out
$content = trim($current->getContent());
if ($content !== 'endif' && $content !== 'endfor' && $content !== 'else' && $content !== 'endraw') {
$group = [$current];
$found = $this->nest($result, $current);
$current = array_merge($group, $found);
} else {
if ($latest !== null) {
$latestType = explode(' ', trim($latest->getContent()))[0];
if ($latestType == 'if' && trim($current->getContent()) == 'endif') {
$container[] = $current;
return $container;
} elseif ($latestType == 'for' && trim($current->getContent()) == 'endfor') {
$container[] = $current;
return $container;
} elseif ($latestType == 'raw' && trim($current->getContent()) == 'endraw') {
$container[] = $current;
return $container;
}
}
}
}
$container[] = $current;
}
return $container;
}