Skip to content

#398 - Transformers edge cases: trim, convert_value, multi_replace, conditions, hash, options validated with the configuration - #399

Merged
njoubert-cleverage merged 2 commits into
mainfrom
398
Nov 3, 2026
Merged

njoubert-cleverage merged 2 commits into
mainfrom
398

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #398.

  • trim: a charlist containing multibyte characters (non-ASCII bytes) is applied with mb_trim() (symfony/polyfill-php84). Until now, trim() removed bytes, producing invalid UTF-8. A single-byte charlist still uses trim(), ranges a..z included.
  • convert_value: with keep_missing and auto_cast, the input itself is returned, as documented, not its value cast to string. The existing test that pinned the old behaviour is updated.
  • multi_replace: the keys and the replacements are cast to string, so a numeric key (an int in PHP) no longer throws a TypeError. A replacement that is not a scalar (or null) is rejected with the configuration.
  • Conditions (ConditionTrait): the property paths are cast to string, so numeric keys no longer throw a TypeError. The list form of empty / not_empty (not_empty: ['[email]']), already described by the documentation, is normalized to the map form: an int key with a string value is taken as the property path.
  • hash: an array or a non-Stringable object throws an UnexpectedValueException. Until now, every array was hashed as the string Array, and an object threw a raw Error. New test class.
  • Options checked with the configuration:
    • explode: the empty delimiter.
    • sprintf: the format, by a trial vsprintf() with enough empty arguments (positional ones included) that catches the \ValueError of an invalid format. @codeCoverageIgnore is removed from configureOptions().
    • instantiate: the existence of the class. The existing test expected a ReflectionException with the first value.

The input policy of slugify and date_parser (#202 of the audit) goes with their own tickets.

Requirements

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

Breaking changes

None in the API. A configuration with an empty explode delimiter, an invalid sprintf format, an unknown instantiate class or a non-scalar multi_replace replacement now fails when the options are resolved, instead of failing with the first value (or never, without data). convert_value with keep_missing and auto_cast returns the input instead of its string cast, as documented. hash rejects arrays.

🤖 Generated with Claude Code

…rt_value keep_missing, numeric keys of multi_replace and conditions, hash of an array, options validated with the configuration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage requested a review from a team as a code owner November 3, 2026 09:40
@njoubert-cleverage
njoubert-cleverage merged commit f580b8d into main Nov 3, 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

1 participant