Refactor and simplify App with new Container::getObject() helper#289
Merged
Refactor and simplify App with new Container::getObject() helper#289
App with new Container::getObject() helper#289Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the App and Container classes to use a new generic Container::getObject() helper method instead of the specific getAccessLogHandler() and getErrorHandler() methods. This simplification reduces code duplication and makes the codebase more maintainable by consolidating object loading logic into a single reusable method.
Key changes:
- Introduced a new generic
Container::getObject()method that can load any object type from the container - Removed the redundant
getAccessLogHandler()andgetErrorHandler()methods fromContainer - Updated
Appto use the newgetObject()method for loading handler instances - Consolidated test coverage by removing duplicate tests and testing the generic method instead
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Container.php |
Adds new getObject() method that generalizes object loading; removes specific getAccessLogHandler() and getErrorHandler() methods |
src/App.php |
Updates constructor to use Container::getObject() instead of specific handler getter methods |
tests/ContainerTest.php |
Refactors tests to use getObject() method; removes redundant ErrorHandler-specific tests; adds new test cases for interface instantiation error handling |
tests/AppTest.php |
Updates mock expectations to use getObject() instead of getAccessLogHandler() and getErrorHandler() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Dec 27, 2025
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 refactors and simplifies the
Appwith a newContainer::getObject()helper. This is only used internally at the moment, but may be exposed as part of our public API in a follow-up. This also avoids a number of redundant tests and allows us to reuse this logic for more classes in a follow-up.Builds on top of #284, #274 #175 and others