Repository navigation
Conversation
Since 4.0, trim(), ltrim() and rtrim() without a character list use mb_trim() and friends, which also strip the form feed, U+0085 and the Unicode space separators such as the no-break space. The update guide did not mention this. Co-Authored-By: Claude Opus 5.5 <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.
Summary of Changes
Since 4.0,
StringHelper::trim(),ltrim()andrtrim()without a character list callmb_trim(),mb_ltrim()andmb_rtrim()instead of PHP'strim()family (3.x used phputf8, which delegated to the native functions). Besides ASCII whitespace, the mb_* functions also strip the form feed, U+0085 and the Unicode space separators, including the no-break space:docs/v3-to-v4-update.mddid not mention this change. It now has a section with the full list of the additional characters and how to get the old behaviour.The review also reported that
x..yranges in$charlistno longer work. That is not a 4.x change: the 3.x phputf8 implementation built a regex character class from$charlistand treated..literally too (utf8_trim('abcz', 'a..z')returned'bc'in 3.0.4, the same as 4.x). The guide says that..does not define a range, so nothing changes in the code.Testing Instructions
Docs only. The example was checked against
4.x-dev, and the 3.x behaviour againstsrc/phputf8/trim.phpfrom tag 3.0.4.Documentation Changes Required
This is the documentation change: a new section in
docs/v3-to-v4-update.md.The owner's docs PR #72 appends two sections to the end of
docs/v3-to-v4-update.md("symfony/polyfill-mbstringis now required" and "Dependency changes"), and so does this PR, so expect a small conflict there. #72's overview already says thattrim()"also strips non-breaking spaces".🤖 Generated with Claude Code