1: | <?php declare(strict_types=1); |
2: | |
3: | namespace PhpParser\Lexer\TokenEmulator; |
4: | |
5: | use PhpParser\Lexer\Emulative; |
6: | |
7: | final class ReadonlyTokenEmulator extends KeywordEmulator |
8: | { |
9: | public function getPhpVersion(): string |
10: | { |
11: | return Emulative::PHP_8_1; |
12: | } |
13: | |
14: | public function getKeywordString(): string |
15: | { |
16: | return 'readonly'; |
17: | } |
18: | |
19: | public function getKeywordToken(): int |
20: | { |
21: | return \T_READONLY; |
22: | } |
23: | |
24: | protected function isKeywordContext(array $tokens, int $pos): bool |
25: | { |
26: | if (!parent::isKeywordContext($tokens, $pos)) { |
27: | return false; |
28: | } |
29: | |
30: | return !(isset($tokens[$pos + 1]) && |
31: | ($tokens[$pos + 1][0] === '(' || |
32: | ($tokens[$pos + 1][0] === \T_WHITESPACE && |
33: | isset($tokens[$pos + 2]) && |
34: | $tokens[$pos + 2][0] === '('))); |
35: | } |
36: | } |
37: | |