Skip to content

Replace illuminate/container with entropy container#13

Open
TomasVotruba wants to merge 1 commit into
mainfrom
migrate-container-to-entropy
Open

Replace illuminate/container with entropy container#13
TomasVotruba wants to merge 1 commit into
mainfrom
migrate-container-to-entropy

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Jun 8, 2026

Copy link
Copy Markdown
Member

Migrates the dependency-injection container from illuminate/container to entropy/entropy's container, and removes illuminate/container (and its patch) entirely.

Uses entropy/entropy ^0.4 (0.4.0), which ships the extendable container required here (entropy#8). Scope is DI only — the console/command layer is untouched and still uses symfony/console; a console migration is a separate, later PR.

What changed

  • ECSConfig now extends Entropy\Container\Container.
    • Checkers are not registered as container services. They live in ECSConfig's own registry (checkerConfiguration + registration order), exactly as before, and are autowired on demand.
    • make() is overridden: a checker class is returned fully configured (autowired via parent::make(), then whitespace config + configure()/sniff-property setup applied, built once and shared); every other class is resolved by the parent container.
    • findByContract() is overridden to return checkers in registration order, keeping duplicates (a class declared in both a set and explicitly appears twice, sharing one instance, last config wins — discussion #198) and honouring compiler-pass removals.
  • Compiler passes use ECSConfig::getCheckerClasses() / removeChecker() instead of getBindings() / offsetUnset() / tags reflection.
  • LazyContainerFactory registers custom-factory services with service(); output formatters are eager-autowired (make()) so OutputFormatterCollector can collect them by contract.
  • FileHashComputer hashes getCheckerConfiguration() (checkers + their config) instead of getBindings().
  • Collectors (FixerFileProcessor, SniffFileProcessor, OutputFormatterCollector) keep their @param X[] docblocks and are autowired through docblock array injection.
  • Removed illuminate/container from composer.json and deleted patches/illuminate-container-container-php.patch.
  • Bumped tomasvotruba/class-leak to ^2.1.7 (first release compatible with entropy ^0.4).

No new container primitives

Checkers and output formatters are built with entropy's existing make() (reflection autowiring) — no build() / factory-bypass method is needed. This avoids registering a service factory keyed by a class only to re-construct that same class inside it.

Scope note — symfony/console is NOT removed

symfony/console is a transitive dependency of friendsofphp/php-cs-fixer and symplify/easy-parallel, so it cannot be removed from the install tree. This PR is container-only.

Verification

All green locally (PHP 8.4): PHPStan level 8, Rector (dry-run), bin/ecs check, PHPUnit (94 tests), class-leak check bin src. End-to-end bin/ecs check verified.

ECSConfig now extends Entropy\Container\Container instead of Illuminate's:

- Checkers are registered as container service factories that autowire (via
  Container::build()) then apply their configuration; collectors receive them
  through docblock array autowiring / findByContract instead of Laravel tags
  and contextual bindings (when()->needs()->giveTagged()).
- findByContract() is overridden to preserve checker registration order and the
  documented duplicate-in-set behaviour (discussion #198).
- Compiler passes operate on ECSConfig::getCheckerClasses()/removeChecker()
  instead of Laravel getBindings()/offsetUnset()/tags reflection.
- LazyContainerFactory registers custom-factory services via service(); plain
  services are autowired and cached by the container.

Removes the illuminate/container dependency and its patch. entropy/entropy is
temporarily pinned to the feature branch (TomasVotruba/entropy#8) via a VCS
repository until that PR is merged.

symfony/console is intentionally untouched: it remains a transitive dependency
of friendsofphp/php-cs-fixer and symplify/easy-parallel, so it cannot be
removed from the install tree.
@TomasVotruba TomasVotruba force-pushed the migrate-container-to-entropy branch from 1973b5d to 245e4c8 Compare June 9, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant