feat(routing): Route::get/post, Route::behind and HandlerReference::of — the verb once, the door once - #21
Merged
Merged
Conversation
…roup Route::get() and Route::post() build the very Route the constructor builds, with the verb said once — as the method name — and the handler named the way a controller is named, [Controller::class, 'method'], through HandlerReference::of(), which refuses any other shape by naming what it received. Route::behind($middleware, ...$routes) prepends one door to a group of routes; Route::withMiddleware() is the wither behind it. Only the verbs and the handler shape with a consumer in the family exist here: put/patch/delete and a bare Controller::class arrive with their first caller. Measured in the greenhouse: agent-workspace's five routes rewritten with this produce a byte-identical routes:list on fresh cattle; only the declaration order moves, and a test declares it (greenhouse decisions/0386, evidence/0704).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Route::get()/Route::post()build the veryRoutethe constructor builds, the verb said once as the method name and the handler named[Controller::class, 'method'].HandlerReference::of()derives the reference from that pair and refuses any other shape by naming what it received (eight malformed cases tested, non-UTF-8 included).Route::behind($middleware, ...$routes)prepends one door to a group;Route::withMiddleware()is the wither behind it.GET/ 19POST/ 0 other verbs acrossgetmilpa-*/src):put/patch/deleteand a bareController::classarrive with their first caller (greenhouse decisions/0213).Why
A plugin author paid five
new Route(path:, methods:, name:, middleware:, handler: new HandlerReference(...))blocks for information that fits one line each, and repeated the gate on every route. The constructor stays the canon; nothing is invented (greenhouse decisions/0212).Measured
Consumer in the same arc:
getmilpa/agent-workspaceroutes()rewritten with this (48 lines → 13). On fresh cattleroutes:list --jsonis byte-identical to the published tree; only the declaration order moves (the public assets route last), which the Router's segment matching makes harmless and a test now declares. Full record: greenhousedecisions/0386,evidence/0704.Gates
55 tests / 151 assertions · line coverage 100.00 % (92/92), floor 100 · PHPStan 6 clean · docblocks OK · php-cs-fixer 0/28 · attribution OK.
Release
Additive API →
feat:→ 0.5.0 underbump-minor-pre-major.getmilpa/agent-workspacerequires>=0.5 <1.0and waits for this tag.