Support explicitly injecting internal RouteHandler into App or load from Container#291
Merged
Support explicitly injecting internal RouteHandler into App or load from Container#291
RouteHandler into App or load from Container#291Conversation
There was a problem hiding this comment.
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.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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