Skip to content

Inject routineLookup, increase coverage to 100%, remove dead code#182

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:lookup
Mar 29, 2026
Merged

Inject routineLookup, increase coverage to 100%, remove dead code#182
alganet merged 1 commit intoRespect:masterfrom
alganet:lookup

Conversation

@alganet
Copy link
Copy Markdown
Member

@alganet alganet commented Mar 28, 2026

  • Make NamespaceLookup a constructor dependency injected from Router into all routes and handlers, removing duplicate creation and the setRoutineLookup()/withRoutineNamespace() post-construction API
  • Add 16 targeted tests reaching 100% class/method coverage; remove two unreachable code paths (ControllerRoute::getTargetMethod HEAD fallback, Router::process empty-dispatch guard)
  • Remove unused CallbackList methods (hasKey, filterKeysContain, filterKeysNotContain, executeCallback) and their tests
  • Merge Responder::finalize() dual null-check blocks into one
  • Make compareOcurrences private and fix typo -> compareOccurrences
  • Collapse Router::__call() callable branch into single call

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.80%. Comparing base (64e698e) to head (e7baf18).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #182      +/-   ##
============================================
+ Coverage     96.35%   98.80%   +2.44%     
+ Complexity      398      394       -4     
============================================
  Files            31       31              
  Lines          1016     1004      -12     
============================================
+ Hits            979      992      +13     
+ Misses           37       12      -25     

☔ 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.

- Make NamespaceLookup a constructor dependency injected from Router
  into all routes and handlers, removing duplicate creation and the
  setRoutineLookup()/withRoutineNamespace() post-construction API
- Add 16 targeted tests reaching 100% class/method coverage; remove
  two unreachable code paths (ControllerRoute::getTargetMethod HEAD
  fallback, Router::process empty-dispatch guard)
- Remove unused CallbackList methods (hasKey, filterKeysContain,
  filterKeysNotContain, executeCallback) and their tests
- Merge Responder::finalize() dual null-check blocks into one
- Make compareOcurrences private and fix typo -> compareOccurrences
- Collapse Router::__call() callable branch into single call
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 routing/routine resolution to inject a shared NamespaceLookup into routes/handlers at construction time, removes several dead/unreachable code paths, and adds targeted tests to reach full class/method coverage.

Changes:

  • Inject NamespaceLookup from Router into all AbstractRoute subclasses and handlers; remove the post-construction routine-lookup API and introduce setBasePath().
  • Remove dead/unreachable code and simplify logic (e.g., HEAD target-method fallback logic, Router::process guard, Router::__call callable branch, Responder::finalize null-check structure).
  • Remove unused CallbackList methods and associated tests; add new tests/stubs to cover edge cases and reach 100% coverage.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Routes/AbstractRoute.php Makes routine lookup a constructor dependency; adds setBasePath; tightens mutability via private(set) properties.
src/Routes/Callback.php Updates constructor to accept injected routine lookup; tightens arguments mutability.
src/Routes/ClassName.php Updates constructor to accept injected routine lookup; tightens promoted properties.
src/Routes/Factory.php Updates constructor to accept injected routine lookup; tightens promoted properties.
src/Routes/Instance.php Updates constructor to accept injected routine lookup; tightens class mutability.
src/Routes/StaticValue.php Updates constructor to accept injected routine lookup.
src/Routes/ControllerRoute.php Simplifies HEAD target method selection logic.
src/Router.php Injects/propagates routine lookup via constructors; removes withRoutineNamespace; simplifies process and __call; makes compare helper private and fixes typo.
src/Routines/CallbackList.php Removes unused helper methods and related import.
src/Responder.php Consolidates status override logic inside the existing draft-response block.
src/Handlers/StatusHandler.php Passes routine lookup into handler route construction.
src/Handlers/ExceptionHandler.php Encapsulates exception state and adds helper methods for matching/capture/reset; passes routine lookup.
src/Handlers/ErrorHandler.php Encapsulates error collection state; passes routine lookup.
src/DispatchContext.php Uses new handler APIs (addError/hasErrors/clear*, matches/capture/clearException) instead of direct property writes.
tests/Routines/CallbackListTest.php Removes tests for deleted CallbackList APIs; adds constructor validation test.
tests/Routines/AcceptTest.php Adds coverage for skipping empty Accept segments and by() returning null.
tests/RoutinePipelineTest.php Updates route creation to pass injected routine lookup.
tests/Routes/StaticValueTest.php Updates route creation to pass injected routine lookup.
tests/Routes/InstanceTest.php Updates route creation to pass injected routine lookup; adds non-routable instance assertion.
tests/Routes/FactoryTest.php Updates route creation to pass injected routine lookup; adds non-routable factory return assertion.
tests/Routes/ClassNameTest.php Updates route creation to pass injected routine lookup.
tests/DispatchEngineTest.php Updates route creation to pass injected routine lookup.
tests/DispatchContextTest.php Updates mocked route constructor args to include injected routine lookup; adds coverage for unknown container ID and empty string conversion.
tests/RouterTest.php Adds new coverage for file-extension negotiation, array-path binding, catchall sorting, PSR-15 process delegation, explicit HEAD handling, exception-handler filtering, and magic __call controllers.
tests/Stubs/MagicMethodController.php Adds stub controller using __call for dispatch testing without reflection.
tests/Stubs/HeadWithExplicitHead.php Adds stub controller with explicit head() method.
tests/Stubs/FunkyCallbackList.php Removes stub method that depended on deleted CallbackList::executeCallback().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alganet alganet marked this pull request as ready for review March 29, 2026 02:49
@alganet alganet merged commit 3b5efc3 into Respect:master Mar 29, 2026
7 checks passed
@alganet alganet deleted the lookup branch March 29, 2026 02:49
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