Skip to content

Move injector invocation into CallableFactory - #332

Merged
vjik merged 2 commits into
masterfrom
injector-callable-factory
Sep 8, 2026
Merged

Move injector invocation into CallableFactory#332
vjik merged 2 commits into
masterfrom
injector-callable-factory

Conversation

@vjik

@vjik vjik commented Sep 5, 2026

Copy link
Copy Markdown
Member
Q A
Is bugfix?
New feature?
Breaks BC? ✔️
Tests pass? ✔️

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.51%. Comparing base (60b7343) to head (d70f8e8).

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Comment thread src/Middleware/CallableFactory.php
@vjik
vjik requested a review from a team September 5, 2026 11:55
@vjik vjik added the status:code review The pull request needs review. label Sep 5, 2026
@vjik
vjik merged commit 63d7524 into master Sep 8, 2026
28 of 29 checks passed
@vjik
vjik deleted the injector-callable-factory branch September 8, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:code review The pull request needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants