You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bundle route + matchedPath + arguments into immutable RouteMatch
The framework was juggling three separate context keys ('route',
'matchedPath', 'arguments') for state that's logically one thing:
"how this request was routed and what its action received." Replace
them with a single immutable RouteMatch value class set on the
context as 'match'.
Shape:
final class RouteMatch {
public function __construct(
public readonly Route $route,
public readonly string $matchedPath,
public readonly array $arguments = [],
) {}
public function withArguments(array $arguments): self;
}
Lifecycle:
- Router::match() now returns ?RouteMatch (was ?array{Route, string})
- Http::match() stores it on the context as 'match' (or null on miss)
- Http::execute() reads it, calls withArguments() once the route's
params are resolved, and re-stores. Synthesizes a RouteMatch if
execute() is called directly without prior match() (test path).
- Wildcard branch in runInternal() builds a RouteMatch around the
cloned wildcard route.
- Telemetry attribution reads it once at the end of run().
Inject via ->inject('match') from any hook/action; access ->route,
->matchedPath, ->arguments. The previous separate 'route' /
'matchedPath' / 'arguments' keys are gone.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments