Skip to content

feat(core): make the aspect container PSR-11 compatible - #768

Merged
lisachenko merged 1 commit into
masterfrom
feat/psr-container
Oct 17, 2026
Merged

lisachenko merged 1 commit into
masterfrom
feat/psr-container

Conversation

@lisachenko

@lisachenko lisachenko commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What and why

Makes the aspect container a PSR-11 container, so it can be handed to any code that expects Psr\Container\ContainerInterface.

  • AspectContainer extends Psr\Container\ContainerInterface. getValue() is renamed to get(string $id): mixed; has() is inherited (same signature as before). The conditional @return ($id is class-string<T> ? T : mixed) is kept for PHPStan narrowing.
  • ServiceNotFoundException implements NotFoundExceptionInterface.
  • New Go\Aop\Exception\ContainerException (an InvalidConfigurationException implementing ContainerExceptionInterface) for a container entry of the wrong type in getService() / a lazy factory returning the wrong type. Existing catch (InvalidConfigurationException) / catch (ExceptionInterface) keep working. Invalid registrations (addLazyService() with a non-class id) still throw plain InvalidConfigurationException.
  • New runtime dependency psr/container ^1.1 || ^2.0 (interfaces only; both majors fit the signatures). Added to AspectKernel::RUNTIME_DEPENDENCIES so it is never woven.
  • Callers updated: The::advice() (proxy hot path calls get() directly, no alias), PointcutReference, tests. Generated proxies and compiled advisor caches never referenced getValue(), so existing caches stay valid.
  • Docs: UPGRADE-4.0.md (new "PSR-11 container" section, rename table, exception table, requirements), CHANGELOG, docs/configuration.md, src/Core/AGENTS.md.

composer test:performance:transformation before/after (touches AspectKernel): ratios 0.10/1.34/0.29 → 0.11/1.35/0.29, within noise.

Checklist

  • The title follows Conventional Commits (type(scope): summary)
  • Tests cover the change (ContainerTest: PSR interface, NotFoundExceptionInterface on unknown id, has() ⇒ get() doesn't throw for null/eager/lazy entries, ContainerExceptionInterface on type mismatch; ExceptionHierarchyTest updated)
  • composer check passes (cs, phpstan level 10, phpunit 3117 tests green with opcache.jit=disable)
  • User-facing or breaking changes are in CHANGELOG.md (and the upgrade guide for breaking changes)

🤖 Generated with Claude Code

https://claude.ai/code/session_01JzyTe7njn5wEgo3sGxfjYR

AspectContainer extends Psr\Container\ContainerInterface: getValue() is
renamed to get(), has() is inherited with the same signature.
ServiceNotFoundException implements NotFoundExceptionInterface, and a
container entry of the wrong type throws the new ContainerException
(an InvalidConfigurationException implementing ContainerExceptionInterface).

psr/container (^1.1 || ^2.0) is a new runtime dependency and is always
excluded from weaving.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JzyTe7njn5wEgo3sGxfjYR
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.82%. Comparing base (02cbe01) to head (eb27c7f).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #768   +/-   ##
=========================================
  Coverage     97.82%   97.82%           
  Complexity     1847     1847           
=========================================
  Files           105      105           
  Lines          4867     4867           
=========================================
  Hits           4761     4761           
  Misses          106      106           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lisachenko
lisachenko marked this pull request as ready for review October 17, 2026 08:45
@lisachenko
lisachenko merged commit 93f645a into master Oct 17, 2026
15 checks passed
@lisachenko
lisachenko deleted the feat/psr-container branch October 17, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants