Extract handlers, adopt Fluent NamespaceLookup, update docs#180
Extract handlers, adopt Fluent NamespaceLookup, update docs#180alganet merged 1 commit intoRespect:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #180 +/- ##
============================================
- Coverage 96.66% 96.40% -0.27%
- Complexity 403 407 +4
============================================
Files 31 31
Lines 1020 1028 +8
============================================
+ Hits 986 991 +5
- Misses 34 37 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors error/exception/status handling by extracting them into dedicated handler classes, updates the Router API to register these handlers fluently, and replaces reflection-based routine instantiation with Fluent’s NamespaceLookup. Documentation and examples are updated accordingly.
Changes:
- Introduce
Handlers\*Handlerclasses and replaceexceptionRoute/errorRoute/statusRoutewithonException/onError/onStatus. - Replace manual reflection routine instantiation with
Respect\Fluent\Factories\NamespaceLookupinRouterandAbstractRoute. - Update dispatch plumbing (
RouteProvider,DispatchEngine,DispatchContext) and docs/examples/tests to the new handler API.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Routes/StatusTest.php | Updates tests to use onStatus() and new handler class coverage. |
| tests/Routes/ExceptionTest.php | Updates tests to use onException() and new handler class coverage. |
| tests/Routes/ErrorTest.php | Updates tests to use onError() and new handler class coverage. |
| tests/RouterTest.php | Updates router tests to the renamed exception handler API. |
| src/Routes/AbstractRoute.php | Switches magic routine creation to NamespaceLookup and adds lookup injection. |
| src/Router.php | Adds handler registration APIs, replaces side-routes with handlers, and adds routine lookup support. |
| src/RouteProvider.php | Renames side-route accessor to getHandlers(). |
| src/Handlers/StatusHandler.php | Adds standalone status handler class under Handlers. |
| src/Handlers/ExceptionHandler.php | Adds standalone exception handler class under Handlers. |
| src/Handlers/ErrorHandler.php | Adds standalone error handler class under Handlers. |
| src/DispatchEngine.php | Wires handlers into the dispatch context via setHandlers(). |
| src/DispatchContext.php | Updates forwarding/catching logic to use handlers and avoid handler recursion. |
| example/full.php | Updates example code to use onException() / onError(). |
| docs/README.md | Updates error handling docs and adds onStatus() example. |
| composer.json | Adds respect/fluent dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move Error, Exception and Status from Routes/ to Handlers/ as standalone handler classes. Replace the internal sideRoutes array with appendHandler() on Router. Rename exceptionRoute()/errorRoute()/ statusRoute() to onException()/onError()/onStatus(). Use Fluent's NamespaceLookup for routine instantiation in AbstractRoute, replacing manual reflection-based class resolution. Update docs/README.md error handling section to reflect the new handler API and add onStatus() example.
Move Error, Exception and Status from Routes/ to Handlers/ as standalone handler classes. Replace the internal sideRoutes array with appendHandler() on Router. Rename exceptionRoute()/errorRoute()/ statusRoute() to onException()/onError()/onStatus().
Use Fluent's NamespaceLookup for routine instantiation in AbstractRoute, replacing manual reflection-based class resolution.
Update docs/README.md error handling section to reflect the new handler API and add onStatus() example.