isTokenKindFound() public method

Check if token kind given as argument is found.
public isTokenKindFound ( integer | string $tokenKind ) : boolean
$tokenKind integer | string
return boolean
示例#1
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     // handle `T_ELSE T_WHITESPACE T_IF` treated as single `T_ELSEIF` by HHVM
     // see https://github.com/facebook/hhvm/issues/4796
     if (defined('HHVM_VERSION') && $tokens->isTokenKindFound(T_ELSEIF)) {
         return true;
     }
     return $tokens->isAllTokenKindsFound(array(T_IF, T_ELSE));
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_OBJECT_OPERATOR);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(CT::T_ARRAY_SQUARE_BRACE_OPEN);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_OPEN_TAG_WITH_ECHO) || defined('HHVM_VERSION') && $tokens->isTokenKindFound(T_ECHO);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_START_HEREDOC);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(CT_ARRAY_INDEX_CURLY_BRACE_OPEN);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_DOC_COMMENT);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_IS_NOT_EQUAL);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(CT::T_CLASS_CONSTANT);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_OPEN_TAG_WITH_ECHO);
 }
 private function assertTokens(Tokens $expectedTokens, Tokens $inputTokens)
 {
     foreach ($expectedTokens as $index => $expectedToken) {
         $inputToken = $inputTokens[$index];
         $this->assertTrue($expectedToken->equals($inputToken), sprintf('The token at index %d must be %s, got %s', $index, $expectedToken->toJson(), $inputToken->toJson()));
     }
     $this->assertSame($expectedTokens->count(), $inputTokens->count(), 'The collection must have the same length than the expected one.');
     $foundTokenKinds = array_keys(AccessibleObject::create($expectedTokens)->foundTokenKinds);
     foreach ($foundTokenKinds as $tokenKind) {
         $this->assertTrue($inputTokens->isTokenKindFound($tokenKind), sprintf('The token kind %s must be found in fixed tokens collection.', $tokenKind));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_DOUBLE_ARROW);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound($this->candidateTokenType);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return PHP_VERSION_ID >= 70000 && $tokens->isTokenKindFound(CT::T_TYPE_COLON);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_ARRAY);
 }
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_FUNCTION);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_DECLARE);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_CLOSE_TAG);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_CONSTANT_ENCAPSED_STRING);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_NAMESPACE);
 }
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     // minimal candidate to fix is seven tokens: pow(x,x);
     return PHP_VERSION_ID >= 50600 && $tokens->count() > 7 && $tokens->isTokenKindFound(T_STRING);
 }