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
The
..range syntax (e.g.a..z) in thecharactersparameter ofTrim,LeftTrim,RightTrimattributes and their resolvers was deprecated in #131. It should be removed.Native
trim()supports ranges, butmb_trim()doesn't, so supporting ranges in multibyte mode requires custom range expansion. Dropping ranges makescharactersbehave the same way in both modes.If
..is just passed as is, existing code like#[Trim(characters: 'a..z')]will silently change its behaviorand strip only
a,.andz. To make the change explicit, an exception should be thrown whencharacterscontains
... It doesn't limit users, sincecharactersis a set of characters, and a single.is enough to stripdots.
To do:
TrimCharacters::expandRanges(),TrimCharacters::checkDeprecatedRanges()and related helpers).InvalidArgumentExceptionwhencharacterscontains..in the constructors ofTrim,LeftTrim,RightTrimattributes and their resolvers. In multibyte mode,..should be detected in the specified encoding.charactersas is totrim()/mb_trim()and other functions.docs/guide/en/typecasting.md.