API / Minn\Front / RuleTable

RuleTable final class

Minn\Front\RuleTable · public/minn/src/Minn/Front/RuleTable.php · 100 lines

An address read as WordPress's request parse reads it (suites permalinks, request-vars, plugin-rules): against the site's rewrite rules (made and stored when there are none, a plugin's own among them, each place's endpoints too), the first rule the address fits winning, as typed or decoded; a page's rule fits only when a page stands at the path it captured, under verbose page rules. A match is the rule's query vars with the matches put in. Which of them count is the request parse's business (the public vars, after the query_vars filter).

Used by 1

Public

staticvars(string $path): ?array#

The vars the site's rules give a path, or null when no rule fits it (or the site has none: plain permalinks).

@return array<string, string>|null
staticmatch(string $path): ?array#

What the request parse makes of a path (WP::parse_request): the path under the home's, the rule it fits and that rule's query with the matches put in, and its vars; the rule and query empty when none fits. Null when the site has no rules (plain permalinks).

@return array{request: string, rule: string, query: string, vars: array<string, string>}|null

Internals 4

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatesubject(string $path): string#

The address as the rules read it: under the home's own path, without the slashes at its ends.

privatefirst(array $rules, string $subject, bool $verbosePages, Closure $pageAt): ?array#

The first rule an address fits, as typed or decoded; a page's rule only when a page is at the path it captured, under verbose page rules.

$rulesarray<mixed, mixed>regex => query
$pageAtClosure(string): boolwhether a page stands at a path
@return array{0: string, 1: string, 2: array<int|string, string>}|null
privatequeryOf(string $query, array $matches): string#

A matched rule's query with the matches put in (urlencoded, so a captured "&x=1" cannot split into extra vars).

$matchesarray<int|string, string>
privatepageAt(string $path): bool#

Whether a page stands at a path (not one in the trash).