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

Reads SQL text from left to right, one token at a time.

Properties§

public string $source

Methods§

public function __construct(public string $source)

Parameters

$sourcestringThe whole SQL text
public function eof(): bool

Reports whether everything has been read.

Returns

bool True at the end of the text
Test cases 3
Calls 1
public function peek(int $ahead = 0): string

Answers the byte at a distance ahead without consuming it.

Parameters

$aheadintDistance from the current position

Returns

string The byte, or an empty string past the end
Test cases 3
Called from 1
public function seek(int $offset): void

Moves to a byte offset.

Parameters

$offsetintOffset to move to
Test cases 1
Called from 1
public function startsWith(string $prefix): bool

Reports whether the unread text starts with a string.

Parameters

$prefixstringText to look for

Returns

bool True when the next bytes spell the prefix
Test cases 1
Calls 2
public function startsWithIgnoringCase(string $prefix): bool

Reports whether the unread text starts with a string, regardless of case.

Parameters

$prefixstringText to look for

Returns

bool True when the next bytes spell the prefix in any case
Test cases 1
Calls 2
public function take(int $length): string

Consumes a number of bytes and answers them.

Parameters

$lengthintHow many bytes to consume

Returns

string The consumed bytes
Test cases 6
Called from 1
Calls 2
public function match(string $pattern): string|null

Consumes what a pattern matches at the current position.

Parameters

$patternstringRegular expression without anchors or delimiters

Returns

string|null The matched text, or null when nothing matches here
Test cases 1
Calls 3
public function lookingAt(string $pattern): bool

Reports whether a pattern matches at the current position, without consuming it.

Parameters

$patternstringRegular expression without anchors or delimiters

Returns

bool True when it matches here
Test cases 1
Calls 2
public function skipPastOrEnd(string $needle): bool

Consumes everything up to and including a delimiter, or to the end when it is missing.

Parameters

$needlestringText that ends the run

Returns

bool True when the delimiter was found
Test cases 1
Calls 2
public function takeQuoted(string $quote, bool $backslashEscapes = false): string|null

Consumes a quoted run whose quote escapes itself by doubling, and optionally by a backslash.

Parameters

$quotestringThe quote character the run opens with
$backslashEscapesboolWhether a backslash escapes the next byte

Returns

string|null The run including both quotes, or null when it never closes
Test cases 2
Called from 1
Calls 2

Private surface 1§

Implementation details, listed for orientation only.

private int $offset = 0

Test cases 96§

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

Dedicated tests 12
Other tests reaching this symbol 84

Relations§

Instantiated in 4
Method calls 7
Type declarations 5