Skip to content

Use rtrim() semantics for chop() on constant strings - #7012

Merged
staabm merged 1 commit into
phpstan:2.3.xfrom
SanderMuller:chop-uses-rtrim
Nov 9, 2026
Merged

staabm merged 1 commit into
phpstan:2.3.xfrom
SanderMuller:chop-uses-rtrim

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

chop() is an alias of rtrim(), but on a constant string the extension computed the result with trim(). So chop(' a ', ' ') was 'a' instead of ' a'. As a result, chop(' a ', ' ') === ' a' was reported as always false.

#5157 added 'chop' to the supported function names. This change adds it to the rtrim() condition too.

Closes phpstan/phpstan#15684

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@staabm

staabm commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

thank you!

@staabm
staabm merged commit a45093f into phpstan:2.3.x Nov 9, 2026
988 of 996 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

Development

Successfully merging this pull request may close these issues.

chop() on a constant string also removes characters from the start

2 participants