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

A position in the text being scanned, with the line and column it is at.

Properties§

public string $source

Methods§

public function __construct(public string $source)

Parameters

$sourcestringThe text
public function offset(): int
public function startsWith(string $prefix): bool

Reports whether the text continues with a prefix.

Parameters

$prefixstringWhat to look for

Returns

bool True when it follows
Test cases 1
Called from 1
Calls 2
public function take(int $length): string

Moves past a number of bytes.

Parameters

$lengthintHow many bytes, cut short at the end

Returns

string The bytes moved past
Test cases 11
Called from 14
Calls 4
public function match(string $pattern): string|null

Moves past a pattern when it matches here.

Parameters

$patternstringA regular expression body without delimiters

Returns

string|null The match, or null when it does not match here
Test cases 1
Called from 5
Calls 4
public function takeUntil(string $needle): string|null

Moves past everything up to and including a needle.

Parameters

$needlestringWhat to look for

Returns

string|null The text before the needle, or null when it is absent
Test cases 1
Called from 3
Calls 3

Private surface 3§

Implementation details, listed for orientation only.

private int $offset = 0
private int $line = 1
private int $column = 1

Test cases 23§

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

Dedicated tests 8
Other tests reaching this symbol 15

Relations§

Instantiated in 1
Method calls 34
Type declarations 5