Skip to content

RFC: remove AspectKernel::getInstance() service-locator coupling from runtime classes #637

Description

@lisachenko

Problem

AspectKernel is a classic singleton (protected static ?self $instance, final protected function __construct()src/Core/AspectKernel.php:74,94-101), and five runtime classes statically pull the container out of it:

  • src/Aop/Framework/InterceptorInjector.php:31,137-141
  • src/Aop/Framework/AbstractInterceptor.php:145
  • src/Aop/Pointcut/PointcutReference.php:61
  • src/Instrument/Transformer/FilterInjectorTransformer.php:88
  • src/Instrument/Transformer/MagicConstantTransformer.php:86

This blocks parallel kernels, embedding (e.g. a Symfony bundle with its own lifecycle), and test isolation.

Proposed design (for discussion)

  • Introduce an explicit Go\Core\Runtime holder bound once at kernel boot; woven code and runtime classes receive it (or the container) by injection instead of AspectKernel::getInstance()->getContainer().
  • Keep getInstance() as a thin deprecated BC shim delegating to the bound runtime.
  • Decide the woven-code contract carefully: generated proxies reference these entry points by name, so the static surface that cached files call must stay stable across a cache warm.

Effort L, risk med-high (public API + woven code shape). Needs design discussion before implementation. Related: the advisor-cache RFC removes two of these call sites on its own.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions