final class Token
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

One token of a grammar file.

The text is what the token stands for: a directive without its percent sign, a literal decoded, code without its braces, a tag without its angle brackets. The raw spelling is kept only where a directive has several.

Properties§

public TokenKind $kind
public string $text
public Location $location
public string $raw = ''

Methods§

public function __construct(
    public TokenKind $kind,
    public string $text,
    public Location $location,
    public string $raw = '',
)

Parameters

$kindTokenKindWhat the token is
$textstringWhat it stands for
$locationLocationWhere it begins
$rawstringThe directive, number or literal as written; empty for other tokens
public function isDirective(string $name): bool

Reports whether the token is a given directive.

Parameters

$namestringCanonical directive name without the percent sign

Returns

bool True for that directive
Test cases 1
Calls 1
public function describe(): string

Describes the token for an error message.

Returns

string The kind, and the text when it helps
Test cases 1
Called from 1
Calls 9

Test cases 25§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3
Other tests reaching this symbol 22

Relations§

Instantiated in 18
Method calls 8
Type declarations 17