Skip to content

#236 - TransformerTrait: document that any #suffix is accepted on transformer codes - #237

Merged
njoubert-cleverage merged 1 commit into
mainfrom
236
Sep 29, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
236

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #236.

The # suffix of transformer codes (used to chain the same transformer several times, as YAML keys must be unique) was documented as numeric only (callback#1), while the unanchored regex of TransformerTrait::getCleanedTransfomerCode() actually accepted any suffix. Named suffixes are useful to describe each step, so this PR makes them official:

  • document that any non-empty suffix is accepted, in the docblock and in docs/reference/traits/transformer_trait.md (with a named suffix in the example);
  • anchor the regex: /^([^#]+)#.+$/. The part before the first # is used as the transformer code if it is registered, otherwise the whole code is looked up;
  • add TransformerTraitTest (code cleaning, chaining the same transformer with numeric and named suffixes, empty suffix).

On main, only the 2 tests about the empty suffix fail (it was accepted by accident). PHPUnit (with coverage), PHPStan, PHP-CS-Fixer and Rector pass, and the changed files are valid PHP 8.2.

Requirements

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

Breaking changes

None in practice: numeric and named suffixes keep working. Only an empty suffix (callback#), accepted by accident, now throws a MissingTransformerException.

🤖 Generated with Claude Code

…#suffix is accepted on transformer codes (callback#1, callback#reverse), and anchor the matching regex (an empty suffix is no longer accepted). Update documentation, add tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit 2437a2c into main Sep 29, 2026
17 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.

TransformerTrait: document that any #suffix is accepted on transformer codes

1 participant