Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
 */
150 lars 15
final class Token
148 lars 16
{
17
    /**
18
     * The string value of the token in the input string
19
     *
20
     * @readonly
21
     * @var V
22
     */
150 lars 23
    public string|int $value;
148 lars 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
     */
150 lars 38
    public int $position;
148 lars 39
 
40
    /**
41
     * @param V      $value
42
     * @param T|null $type
43
     */
150 lars 44
    public function __construct(string|int $value, $type, int $position)
148 lars 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
}