refactor: replace the in-tree DI container with internal/container - #116
Merged
Conversation
Swap DLoad's own Container, ObjectContainer and Factoriable for the internal/container package, which is the same code extracted and grown. Config hydration stops being a hard-coded namespace check inside the container's make(): it moves into a ConfigInflector registered as an Internal\Container\Inflector, and config classes opt in through the new #[InflectableConfig] marker attribute instead of the Module\Config\Schema\ prefix. Input\Build and Input\Destination carry the marker too, so their #[InputOption] values are now hydrated as well. Bootstrap holds the concrete ObjectContainer because addInflector() is not part of the Container interface, and the inflector resolves the Logger lazily from the container since it is built during withConfig(), before the Logger is registered. Deleted src/Service/Container.php, src/Service/Factoriable.php, src/Module/Common/Internal/ObjectContainer.php and the old ConfigLoader (renamed into ConfigInflector); the psalm baseline is regenerated for the moved code and the cross-package @internal calls in Bootstrap. Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
7 tasks
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.
🔍 What was changed
Service\Container,Module\Common\Internal\ObjectContainer,Service\Factoriable) with theinternal/containerpackage — the same code, extracted and grown.make(). It moved into aConfigInflectorregistered as anInternal\Container\Inflector, and config classes now opt in with a#[InflectableConfig]marker attribute.Input\BuildandInput\Destinationgained the marker too, so their#[InputOption]values are now hydrated (they sat outside the oldModule\Config\Schema\prefix and were silently never hydrated before).How it works
ConfigInflectorhydrates only the ones carrying#[InflectableConfig]and returns the rest untouched.Bootstrapnow holds the concreteObjectContainer(the default), becauseaddInflector()is not part of theContainerinterface.Loggerlazily from the container: it is built duringwithConfig(), before the logger is registered, so a constructor dependency would fail.Why?
Checklist
composer testlocally — 498 passed, 4 skipped; the Acceptance suite drives the real CLI readingdload.xml, so config hydration through the inflector is covered end-to-end.composer psalmclean;composer cs:fixreports no changes.StabilityTestupdated for the movedFactoriableFQCN).Review notes
internal/containeris also bundled andreplaced bytesto/testo, whose copy still carries@internalon the class; the cross-package calls inBootstrapare therefore baselined in psalm. The lock still pins the realinternal/container1.0.1 from Packagist, so a--no-devinstall resolves it correctly.yiisoft/injectorstays inrequire; no project code imports it any more, so it could be dropped (it remains a transitive dependency ofinternal/container).