Skip to content

Remove deprecated .. range syntax from characters parameter of trim attributes #136

Description

@vjik

The .. range syntax (e.g. a..z) in the characters parameter of Trim, LeftTrim, RightTrim attributes and their resolvers was deprecated in #131. It should be removed.

Native trim() supports ranges, but mb_trim() doesn't, so supporting ranges in multibyte mode requires custom range expansion. Dropping ranges makes characters behave the same way in both modes.

If .. is just passed as is, existing code like #[Trim(characters: 'a..z')] will silently change its behavior
and strip only a, . and z. To make the change explicit, an exception should be thrown when characters
contains ... It doesn't limit users, since characters is a set of characters, and a single . is enough to strip
dots.

To do:

  • Remove range expansion and the deprecation notice (TrimCharacters::expandRanges(),
    TrimCharacters::checkDeprecatedRanges() and related helpers).
  • Throw InvalidArgumentException when characters contains .. in the constructors of Trim, LeftTrim,
    RightTrim attributes and their resolvers. In multibyte mode, .. should be detected in the specified encoding.
  • Pass characters as is to trim() / mb_trim() and other functions.
  • Update PHPDoc and docs/guide/en/typecasting.md.
  • Add an upgrade note.

⚠️ Don't implement it before start version 2.0 development

Activity

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions