Skip to content

Extract handlers, adopt Fluent NamespaceLookup, update docs#180

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:fluent-2
Mar 25, 2026
Merged

Extract handlers, adopt Fluent NamespaceLookup, update docs#180
alganet merged 1 commit intoRespect:masterfrom
alganet:fluent-2

Conversation

@alganet
Copy link
Copy Markdown
Member

@alganet alganet commented Mar 25, 2026

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.

@alganet alganet requested a review from Copilot March 25, 2026 07:22
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 96.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.40%. Comparing base (0f1843b) to head (aa633a5).

Files with missing lines Patch % Lines
src/Router.php 88.88% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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\*Handler classes and replace exceptionRoute/errorRoute/statusRoute with onException/onError/onStatus.
  • Replace manual reflection routine instantiation with Respect\Fluent\Factories\NamespaceLookup in Router and AbstractRoute.
  • 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.
@alganet alganet marked this pull request as ready for review March 25, 2026 07:48
@alganet alganet merged commit 4e7f75d into Respect:master Mar 25, 2026
3 checks passed
@alganet alganet deleted the fluent-2 branch March 25, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants