本文整理汇总了PHP中Symfony\CS\Tokenizer\Token::override方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::override方法的具体用法?PHP Token::override怎么用?PHP Token::override使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\CS\Tokenizer\Token
的用法示例。
在下文中一共展示了Token::override方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* {@inheritdoc}
*/
public function process(Tokens $tokens, Token $token, $index)
{
if ($token->isGivenKind(T_USE) && $this->isUseForLambda($tokens, $index)) {
$token->override(array(CT_USE_LAMBDA, $token->getContent()));
}
if (!$token->isClassy()) {
return;
}
$prevTokenIndex = $tokens->getPrevMeaningfulToken($index);
$prevToken = $prevTokenIndex === null ? null : $tokens[$prevTokenIndex];
if ($prevToken->isGivenKind(T_DOUBLE_COLON)) {
return;
}
// Skip whole class braces content.
// That way we can skip whole tokens in class declaration, therefore skip `T_USE` for traits.
$index = $tokens->getNextTokenOfKind($index, array('{'));
$innerLimit = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
while ($index < $innerLimit) {
$token = $tokens[++$index];
if (!$token->isGivenKind(T_USE)) {
continue;
}
if ($this->isUseForLambda($tokens, $index)) {
$token->override(array(CT_USE_LAMBDA, $token->getContent()));
} else {
$token->override(array(CT_USE_TRAIT, $token->getContent()));
}
}
}
示例2: override
public function override($other)
{
$prototype = $other instanceof self ? $other->getPrototype() : $other;
if (!$this->equals($prototype)) {
$this->messages = array();
}
parent::override($other);
}
示例3: process
/**
* {@inheritdoc}
*/
public function process(Tokens $tokens, Token $token, $index)
{
if (!$this->isShortArray($tokens, $index)) {
return;
}
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_INDEX_SQUARE_BRACE, $index);
$token->override(array(CT_ARRAY_SQUARE_BRACE_OPEN, '['));
$tokens[$endIndex]->override(array(CT_ARRAY_SQUARE_BRACE_CLOSE, ']'));
}
示例4: process
/**
* {@inheritdoc}
*/
public function process(Tokens $tokens, Token $token, $index)
{
if (!$token->isGivenKind(array(T_CONST, T_FUNCTION))) {
return;
}
$prevToken = $tokens[$tokens->getPrevMeaningfulToken($index)];
if ($prevToken->isGivenKind(T_USE)) {
$token->override(array($token->isGivenKind(T_FUNCTION) ? CT_FUNCTION_IMPORT : CT_CONST_IMPORT, $token->getContent()));
}
}
示例5: process
/**
* {@inheritdoc}
*/
public function process(Tokens $tokens, Token $token, $index)
{
if (!$token->isGivenKind(T_NAMESPACE)) {
return;
}
$nextIndex = $tokens->getNextMeaningfulToken($index);
$nextToken = $tokens[$nextIndex];
if ($nextToken->equals(array(T_NS_SEPARATOR))) {
$token->override(array(CT_NAMESPACE_OPERATOR, $token->getContent()));
}
}
示例6: process
/**
* {@inheritdoc}
*/
public function process(Tokens $tokens, Token $token, $index)
{
if (!$token->isGivenKind(T_CLASS)) {
return;
}
$prevIndex = $tokens->getPrevMeaningfulToken($index);
$prevToken = $tokens[$prevIndex];
if ($prevToken->isGivenKind(T_DOUBLE_COLON)) {
$token->override(array(CT_CLASS_CONSTANT, $token->getContent()));
}
}
示例7: process
/**
* {@inheritdoc}
*/
public function process(Tokens $tokens, Token $token, $index)
{
if (!$token->isGivenKind(T_ARRAY)) {
return;
}
$nextIndex = $tokens->getNextMeaningfulToken($index);
$nextToken = $tokens[$nextIndex];
if (!$nextToken->equals('(')) {
$token->override(array(CT_ARRAY_TYPEHINT, $token->getContent()));
}
}
示例8: testIsEmpty
public function testIsEmpty()
{
$braceToken = $this->getBraceToken();
$this->assertFalse($braceToken->isEmpty());
$braceToken->setContent('');
$this->assertTrue($braceToken->isEmpty());
$whitespaceToken = new Token(array(T_WHITESPACE, ' '));
$this->assertFalse($whitespaceToken->isEmpty());
$whitespaceToken->setContent('');
$this->assertTrue($whitespaceToken->isEmpty());
$whitespaceToken->override(array(null, ''));
$this->assertTrue($whitespaceToken->isEmpty());
$whitespaceToken = new Token(array(T_WHITESPACE, ' '));
$whitespaceToken->clear();
$this->assertTrue($whitespaceToken->isEmpty());
}