Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Dec 27, 2025

This changeset adds support for loading a Container self-reference from the Container. On its own, this is rarely useful as the Container has no public API exposed at the moment. This is mostly done as an internal preparation at the moment, but may be exposed as part of our public API that allows us to reuse this logic for more classes in a follow-up.

Builds on top of #289, #284 and others

@clue clue added this to the v0.18.0 milestone Dec 27, 2025
@clue clue requested a review from Copilot December 27, 2025 16:42
@clue clue added maintenance new feature New feature or request labels Dec 27, 2025
Copy link

Copilot AI left a 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 loading a Container self-reference from the Container itself. This enables the container to inject itself into factory functions and allows Container::class to be used as a class name reference in routing and dependency injection contexts.

Key changes:

  • Container can now return itself when Container::class is requested via getObject()
  • Factory functions can now receive the Container as a dependency parameter
  • Container::class can be used in routing configurations and will be resolved to the actual container instance

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Container.php Implements self-reference support in loadObject() and getObject() methods, adds assertion to prevent Container in callable()
src/App.php Updates middleware loading to support Container::class as a loadable class
src/Io/RouteHandler.php Adds logic to resolve Container::class to container instance in route handlers
tests/ContainerTest.php Adds comprehensive test coverage for Container self-reference scenarios including default behavior, explicit configuration, PSR-11 adapter, and recursive detection
tests/AppTest.php Updates test expectations to account for Container::class resolution
tests/Io/RouteHandlerTest.php Adds tests for Container::class usage in routing contexts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a 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 6 out of 6 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant