Skip to content

[v6] #280 - TransformerRegistry: require the code tag attribute and remove eager transformer registration - #515

Merged
njoubert-cleverage merged 1 commit into
dev-v6from
280
Dec 2, 2026
Merged

njoubert-cleverage merged 1 commit into
dev-v6from
280

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #280 (v6.0 step of #276): the code of a transformer is only given by the code attribute of its cleverage.transformer tag, or by #[AsTransformer(code: '...')], and the eager registration deprecated in 5.4 is removed:

  • TransformerLocatorCompilerPass: a service tagged cleverage.transformer without any code fails the container compilation with an explicit message (a dedicated one for a transformer of the bundle redeclared by the application, which loses the tag of the bundle). The code-less tag added by the autoconfiguration of TransformerInterface is ignored next to the tag of #[AsTransformer]. An abstract definition is skipped without code and rejected with a code (its children must be tagged);
  • TransformerRegistry: addTransformer() is removed, the service locator is a required constructor argument, getTransformer() / hasTransformer() / getTransformers() only give the transformers of the locator (in its order), the check "code of the locator === getCode()" is removed. TransformerRegistryInterface::getTransformerCodes(): list<string> gives the codes without instantiating the transformers (getTransformers() is kept);
  • TransformerInterface::getCode() is removed, as well as the getCode() method of the 37 transformers of the bundle (GenericTransformer and UnavailableTransformer keep their own, outside of the interface);
  • UnavailableServicesCompilerPass only reads the code of the tag (no more reflection on getCode()): a definition tagged without code is kept (the locator pass fails), an untagged one is replaced with its class as code;
  • RegistryCompilerPass and its test are removed;
  • tests: the codes of the 38 transformers of the bundle are pinned (TransformerCodesTest), non-regression with the real autoconfiguration (TransformerAutoconfigurationTest), compiler passes and registry cases;
  • documentation (quick start, custom transformers, common setup cookbook), CHANGELOG, UPGRADE.md (tag without code and how to opt out of autoconfiguration, redeclared transformers of the bundle, #[\Override] / parent::getCode(), addTransformer() in tests with a ServiceLocator, new interface method, subclasses of the registry).

Also covers items of #292 (eager registration, RegistryCompilerPass, getCode(), reflection fallback of UnavailableServicesCompilerPass); CheckSerializerCompilerPass and the $deprecatedCodes argument stay in #292.

Bridges: only soap-process-bundle has a transformer, already tagged with its code; its own getCode() (without #[\Override]) still works. Follow-up when the bridges support the core v6: soap comments/test still referring to getCode().

Checked locally: tests with pcov coverage (no risky test), PHPStan, PHP-CS-Fixer and Rector OK.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

  • Major: a service tagged cleverage.transformer without code (e.g. a transformer autoconfigured without #[AsTransformer]) fails the container compilation.
  • Major: TransformerInterface::getCode(), the getCode() method of the transformers of the bundle, TransformerRegistry::addTransformer() and RegistryCompilerPass are removed; the locator is required by the TransformerRegistry constructor; TransformerRegistryInterface declares getTransformerCodes().

See UPGRADE.md.

🤖 Generated with Claude Code

… eager transformer registration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage requested a review from a team as a code owner December 2, 2026 09:56
@njoubert-cleverage njoubert-cleverage added this to the v6.0 milestone Dec 2, 2026
@njoubert-cleverage
njoubert-cleverage merged commit df4adeb into dev-v6 Dec 2, 2026
15 checks passed
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