final class LexicalPattern

Reads a regular expression against a position in a statement.

A scanner asks the same two questions over and over — does this pattern match right here, and does this one character match at all — and both have an answer that has to be exact: an empty match is no match, because a scanner that accepts one never advances.

Methods§

public function matchesCharacter(string $pattern, string $character): bool

Reports whether one character matches a pattern.

Parameters

$patternstringPattern to read
$characterstringCharacter to test

Returns

bool True when it matches, and false for no character at all
Test cases 3
Called from 2
Calls 1
public function assertValid(string|null $pattern): void

Refuses a pattern that is not one preg can read.

preg reports a bad pattern as a warning rather than by raising, so the warning is turned into the refusal here; a pattern kept and used later would fail at every position instead of once, at the point it was given.

Parameters

$patternstring|nullPattern to check, or null when the dialect has none

Throws

InvalidDefinitionException When the pattern is empty or preg will not read it
Test cases 2
Called from 6
Calls 4

Test cases 23§

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

Dedicated tests 9
Other tests reaching this symbol 14

Relations§

Instantiated in 4
Method calls 12
Type declarations 4