本文整理匯總了PHP中Symfony\CS\Tokenizer\Token::isGivenKind方法的典型用法代碼示例。如果您正苦於以下問題:PHP Token::isGivenKind方法的具體用法?PHP Token::isGivenKind怎麽用?PHP Token::isGivenKind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\CS\Tokenizer\Token
的用法示例。
在下文中一共展示了Token::isGivenKind方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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()));
}
}
示例2: 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()));
}
}
}
示例3: 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()));
}
}
示例4: 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()));
}
}
示例5: 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()));
}
}
示例6: transformIntoDynamicPropBraces
private function transformIntoDynamicPropBraces(Tokens $tokens, Token $token, $index)
{
if (!$token->isGivenKind(T_OBJECT_OPERATOR)) {
return;
}
if (!$tokens[$index + 1]->equals('{')) {
return;
}
$openIndex = $index + 1;
$closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $openIndex);
$tokens[$openIndex]->override(array(CT_DYNAMIC_PROP_BRACE_OPEN, '{'));
$tokens[$closeIndex]->override(array(CT_DYNAMIC_PROP_BRACE_CLOSE, '}'));
}
示例7: fixByToken
private function fixByToken(Token $token, $index)
{
foreach ($this->tokenCallbackMap as $kind => $callback) {
if (!$token->isGivenKind($kind)) {
continue;
}
$callback = $this->tokenCallbackMap[$kind];
$this->{$callback}($index);
return;
}
}
示例8: isStructuralElement
private function isStructuralElement(Token $token)
{
static $skip = array(
T_PRIVATE,
T_PROTECTED,
T_PUBLIC,
T_FUNCTION,
T_ABSTRACT,
T_CONST,
T_NAMESPACE,
T_REQUIRE,
T_REQUIRE_ONCE,
T_INCLUDE,
T_INCLUDE_ONCE,
T_FINAL,
T_STATIC,
);
return $token->isClassy() || $token->isGivenKind($skip);
}