-
-
Notifications
You must be signed in to change notification settings - Fork 56
Support explicitly injecting internal RouteHandler into App or load from Container
#291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 adds support for explicitly injecting a RouteHandler into the App constructor or loading it from the Container. The primary goal is to make the framework's internal architecture more flexible while cleaning up tests by avoiding reflection calls.
Key changes:
RouteHandlerconstructor now requires aContainerparameter (previously optional)Containercan now automatically instantiateRouteHandlerwith itself as dependencyAppconstructor acceptsRouteHandlerinstances or class names, with validation that it must be last in the middleware chain
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Io/RouteHandler.php | Made Container parameter mandatory in constructor (breaking change for internal use only) |
| src/Container.php | Added fallback to auto-instantiate RouteHandler with self-reference, similar to existing Container self-reference pattern |
| src/App.php | Added logic to accept explicit RouteHandler instances/class names and validate they appear last in middleware chain |
| tests/Io/RouteHandlerTest.php | Updated all tests to pass Container instance to RouteHandler constructor |
| tests/ContainerTest.php | Added tests verifying RouteHandler can be loaded from container with proper container injection |
| tests/AppTest.php | Simplified tests by injecting mocked RouteHandler directly instead of using reflection; added tests for new RouteHandler injection feature |
| tests/AppMiddlewareTest.php | Simplified all HTTP method tests by injecting mocked RouteHandler instead of using reflection |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This changeset adds support for injecting the internal
RouteHandlerinto theAppexplicitly or default to loading it from theContainer. This is only used internally at the moment, but may be exposed as part of our public API in a follow-up. This also allows us to clean up the tests and avoid a number of reflection calls in our tests.Builds on top of #290, #289, #282, #94, #42, and others