PhpCsFixer\Tokenizer\CT::has PHP Method

has() public static method

Check if given custom token exists.
public static has ( integer $value ) : boolean
$value integer custom token value
return boolean
    public static function has($value)
    {
        $tokens = self::getMapById();
        return isset($tokens[$value]);
    }

Usage Example

 protected function doTest($source, array $expectedTokens = array(), array $observedKinds = array())
 {
     $tokens = Tokens::fromCode($source);
     $this->assertSame(count($expectedTokens), array_sum(array_map(function ($item) {
         return count($item);
     }, $tokens->findGivenKind(array_unique(array_merge($observedKinds, array_values($expectedTokens)))))));
     foreach ($expectedTokens as $index => $tokenId) {
         $this->assertSame(CT::has($tokenId) ? CT::getName($tokenId) : token_name($tokenId), $tokens[$index]->getName(), sprintf('Token kind should be the same at index %d.', $index));
         $this->assertSame($tokenId, $tokens[$index]->getId());
     }
 }
All Usage Examples Of PhpCsFixer\Tokenizer\CT::has