#236 - TransformerTrait: document that any #suffix is accepted on transformer codes - #237
Merged
Merged
Conversation
…#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ofTransformerTrait::getCleanedTransfomerCode()actually accepted any suffix. Named suffixes are useful to describe each step, so this PR makes them official:docs/reference/traits/transformer_trait.md(with a named suffix in the example);/^([^#]+)#.+$/. The part before the first#is used as the transformer code if it is registered, otherwise the whole code is looked up;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
Breaking changes
None in practice: numeric and named suffixes keep working. Only an empty suffix (
callback#), accepted by accident, now throws aMissingTransformerException.🤖 Generated with Claude Code