EnumTokenEmulator.php 701 B

1234567891011121314151617181920212223242526
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Lexer\TokenEmulator;
  3. use PhpParser\PhpVersion;
  4. final class EnumTokenEmulator extends KeywordEmulator {
  5. public function getPhpVersion(): PhpVersion {
  6. return PhpVersion::fromComponents(8, 1);
  7. }
  8. public function getKeywordString(): string {
  9. return 'enum';
  10. }
  11. public function getKeywordToken(): int {
  12. return \T_ENUM;
  13. }
  14. protected function isKeywordContext(array $tokens, int $pos): bool {
  15. return parent::isKeywordContext($tokens, $pos)
  16. && isset($tokens[$pos + 2])
  17. && $tokens[$pos + 1]->id === \T_WHITESPACE
  18. && $tokens[$pos + 2]->id === \T_STRING;
  19. }
  20. }