Skip to content

refactor: replace the in-tree DI container with internal/container - #116

Merged
roxblnfk merged 1 commit into
1.xfrom
refactor-internal-container
Sep 8, 2026
Merged

refactor: replace the in-tree DI container with internal/container#116
roxblnfk merged 1 commit into
1.xfrom
refactor-internal-container

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Sep 8, 2026

Copy link
Copy Markdown
Member

🔍 What was changed

  • Replaced DLoad's in-tree DI container (Service\Container, Module\Common\Internal\ObjectContainer, Service\Factoriable) with the internal/container package — the same code, extracted and grown.
  • Config hydration is no longer a hard-coded namespace check inside the container's make(). It moved into a ConfigInflector registered as an Internal\Container\Inflector, and config classes now opt in with a #[InflectableConfig] marker attribute.
  • Input\Build and Input\Destination gained the marker too, so their #[InputOption] values are now hydrated (they sat outside the old Module\Config\Schema\ prefix and were silently never hydrated before).

How it works

  • Every object the container produces passes through the registered inflectors; ConfigInflector hydrates only the ones carrying #[InflectableConfig] and returns the rest untouched.
  • Bootstrap now holds the concrete ObjectContainer (the default), because addInflector() is not part of the Container interface.
  • The inflector resolves Logger lazily from the container: it is built during withConfig(), before the logger is registered, so a constructor dependency would fail.

Why?

  • Removes a maintenance fork of the container so both DLoad and Trap track one package, and turns the DLoad-specific namespace hook into a generic, reusable inflector.

Checklist

  • How was this tested:
    • composer test locally — 498 passed, 4 skipped; the Acceptance suite drives the real CLI reading dload.xml, so config hydration through the inflector is covered end-to-end.
    • composer psalm clean; composer cs:fix reports no changes.
    • No new unit tests added — behaviour is covered by the existing suite (StabilityTest updated for the moved Factoriable FQCN).

Review notes

  • In this dev tree internal/container is also bundled and replaced by testo/testo, whose copy still carries @internal on the class; the cross-package calls in Bootstrap are therefore baselined in psalm. The lock still pins the real internal/container 1.0.1 from Packagist, so a --no-dev install resolves it correctly.
  • yiisoft/injector stays in require; no project code imports it any more, so it could be dropped (it remains a transitive dependency of internal/container).

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>
@github-actions github-actions Bot added the tests label Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/Module/Common/Architecture.php 100.00% <ø> (ø)
src/Module/Common/OperatingSystem.php 86.66% <ø> (ø)
src/Module/Common/Stability.php 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roxblnfk
roxblnfk merged commit e0e241d into 1.x Sep 8, 2026
23 checks passed
@roxblnfk
roxblnfk deleted the refactor-internal-container branch September 8, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant