Move injector invocation into CallableFactory - #332
Conversation
vjik
commented
Sep 5, 2026
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ❌ |
| Breaks BC? | ✔️ |
| Tests pass? | ✔️ |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #332 +/- ##
============================================
- Coverage 92.53% 92.51% -0.03%
- Complexity 382 383 +1
============================================
Files 59 59
Lines 1018 1015 -3
============================================
- Hits 942 939 -3
Misses 76 76 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The new callable wrapper breaks positional scalar arguments and lacks coverage for its secondary dependency container.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Centralizes dependency-injected callable invocation in CallableFactory and simplifies middleware factory construction.
Changes:
- Moves injector ownership and invocation into
CallableFactory. - Updates middleware factories, handlers, tests, benchmarks, and documentation.
- Adds optional separation between definition and dependency containers.
File summaries
| File | Description |
|---|---|
src/Middleware/CallableFactory.php |
Centralizes injected invocation. |
src/Middleware/MiddlewareFactory.php |
Internally creates the callable factory. |
src/Middleware/Consume/ConsumeMiddlewareFactory.php |
Directly invokes prepared callbacks. |
src/Middleware/Push/PushMiddlewareFactory.php |
Directly invokes prepared callbacks. |
src/Middleware/FailureHandling/FailureMiddlewareFactory.php |
Directly invokes prepared callbacks. |
src/Message/Handler/HandlerResolver.php |
Delegates injection to CallableFactory. |
tests/Unit/Middleware/CallableFactoryTest.php |
Updates callable invocation arguments. |
tests/Unit/Middleware/Consume/MiddlewareFactoryTest.php |
Updates factory construction. |
tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php |
Updates dispatcher setup. |
tests/Unit/Middleware/Push/MiddlewareFactoryTest.php |
Updates factory construction. |
tests/Unit/Middleware/Push/MiddlewareDispatcherTest.php |
Updates dispatcher setup. |
tests/Unit/Middleware/FailureHandling/MiddlewareFactoryTest.php |
Updates factory construction. |
tests/Unit/Middleware/FailureHandling/MiddlewareDispatcherTest.php |
Updates dispatcher setup. |
tests/Integration/MiddlewareTest.php |
Updates integration wiring. |
tests/TestCase.php |
Simplifies shared test setup. |
tests/Benchmark/QueueBench.php |
Updates benchmark wiring. |
docs/guide/en/configuration-manual.md |
Simplifies configuration examples. |
Review details
- Files reviewed: 17/17 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| $callable = $this->resolve($definition); | ||
|
|
||
| return fn(mixed ...$params): mixed => $this->injector->invoke($callable, $params); |
There was a problem hiding this comment.
CallableFactory is @internal, and its only two consumers (HandlerResolver and the *MiddlewareFactory classes) always invoke the resolved callable with positional objects ($message, or $request/$handler) — never with positional scalars. So create('strlen')('foo') wasn't exercising any real usage pattern of this class, just a synthetic case in the unit test.