Skip to content

CachedTransformer and SlugifyTransformer fail with a raw PHP error on edge cases; TypeSetterTransformer has a dead error branch #204

Closed

Description

@njoubert-cleverage

Description

Three transformers handle edge cases badly:

  • cached rejects any non-string input with a TypeError, before key_transformers can convert it to a string, while the documentation says that a non-string key value just skips the cache.
  • slugify accepts an invalid transliterator identifier, then fails on the first value with Call to a member function transliterate() on null.
  • type_setter has a TransformerException branch for settype() returning false that can never run in PHP 8: invalid types are already rejected by setAllowedValues, and settype() never returns false for the allowed types.

Reproduction

clever_age_process:
    configurations:
        demo.transformers_edge.cached:
            tasks:
                extract:
                    service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
                    options:
                        output: 42
                    outputs: [ transform ]
                transform:
                    service: '@CleverAge\ProcessBundle\Task\TransformerTask'
                    options:
                        transformers:
                            cached:
                                cache_key: demo_edge
                                key_transformers:
                                    cast: { type: string }
                                transformers:
                                    cast: { type: string }
                    outputs: [ debug ]
                debug:
                    service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'

        demo.transformers_edge.slugify:
            tasks:
                extract:
                    service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
                    options:
                        output: 'Hélène Dupont'
                    outputs: [ transform ]
                transform:
                    service: '@CleverAge\ProcessBundle\Task\TransformerTask'
                    options:
                        transformers:
                            slugify:
                                transliterator: 'Not-A-Real-Transliterator'
                    outputs: [ debug ]
                debug:
                    service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
$ bin/console cleverage:process:execute demo.transformers_edge.cached
CRITICAL [cleverage_process_task] Transformation 'cached' have failed: CleverAge\ProcessBundle\Transformer\CachedTransformer::generateCacheKey(): Argument #2 ($value) must be of type string, int given, called in .../src/Transformer/CachedTransformer.php on line 67

$ bin/console cleverage:process:execute demo.transformers_edge.slugify
CRITICAL [cleverage_process_task] Transformation 'slugify' have failed: Call to a member function transliterate() on null

Tested on main (c1a2804), PHP 8.5, Symfony 7.4.

Cause

Proposed fix

  • CachedTransformer::generateCacheKey() takes a mixed $value: a key value that is still not a string after key_transformers skips the cache, as documented.
  • The slugify transliterator normalizer throws an InvalidOptionsException (with the intl error message) when \Transliterator::create() returns null, so the error shows up when the options are resolved.
  • Remove the dead TransformerException branch from TypeSetterTransformer::transform().
  • Update the reference documentation, add unit tests.

Requirements

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

Breaking changes

None for configurations. A subclass of CachedTransformer overriding generateCacheKey() with a string $value parameter must widen it to mixed.

Activity

  1. added 4 commits that reference this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions