diff options
Diffstat (limited to 'vendor/doctrine/lexer/src/Token.php')
-rw-r--r-- | vendor/doctrine/lexer/src/Token.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/vendor/doctrine/lexer/src/Token.php b/vendor/doctrine/lexer/src/Token.php new file mode 100644 index 0000000..b6df694 --- /dev/null +++ b/vendor/doctrine/lexer/src/Token.php | |||
@@ -0,0 +1,56 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\Common\Lexer; | ||
6 | |||
7 | use UnitEnum; | ||
8 | |||
9 | use function in_array; | ||
10 | |||
11 | /** | ||
12 | * @template T of UnitEnum|string|int | ||
13 | * @template V of string|int | ||
14 | */ | ||
15 | final class Token | ||
16 | { | ||
17 | /** | ||
18 | * The string value of the token in the input string | ||
19 | * | ||
20 | * @readonly | ||
21 | * @var V | ||
22 | */ | ||
23 | public string|int $value; | ||
24 | |||
25 | /** | ||
26 | * The type of the token (identifier, numeric, string, input parameter, none) | ||
27 | * | ||
28 | * @readonly | ||
29 | * @var T|null | ||
30 | */ | ||
31 | public $type; | ||
32 | |||
33 | /** | ||
34 | * The position of the token in the input string | ||
35 | * | ||
36 | * @readonly | ||
37 | */ | ||
38 | public int $position; | ||
39 | |||
40 | /** | ||
41 | * @param V $value | ||
42 | * @param T|null $type | ||
43 | */ | ||
44 | public function __construct(string|int $value, $type, int $position) | ||
45 | { | ||
46 | $this->value = $value; | ||
47 | $this->type = $type; | ||
48 | $this->position = $position; | ||
49 | } | ||
50 | |||
51 | /** @param T ...$types */ | ||
52 | public function isA(...$types): bool | ||
53 | { | ||
54 | return in_array($this->type, $types, true); | ||
55 | } | ||
56 | } | ||