PhpCsFixer\Tokenizer\Tokens::getNextMeaningfulToken PHP Method

getNextMeaningfulToken() public method

Get index for closest next token that is not a whitespace or comment.
public getNextMeaningfulToken ( integer $index ) : integer | null
$index integer token index
return integer | null
    public function getNextMeaningfulToken($index)
    {
        return $this->getMeaningfulTokenSibling($index, 1);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function process(Tokens $tokens, Token $token, $index)
 {
     if (!$tokens[$index]->equals('(') || !$tokens[$tokens->getNextMeaningfulToken($index)]->equals(array(T_NEW))) {
         return;
     }
     $closeIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);
     if (!$tokens[$tokens->getNextMeaningfulToken($closeIndex)]->isGivenKind(array(T_OBJECT_OPERATOR, T_DOUBLE_COLON))) {
         return;
     }
     $tokens[$index]->override(array(CT_BRACE_CLASS_INSTANTIATION_OPEN, '('));
     $tokens[$closeIndex]->override(array(CT_BRACE_CLASS_INSTANTIATION_CLOSE, ')'));
 }
All Usage Examples Of PhpCsFixer\Tokenizer\Tokens::getNextMeaningfulToken