Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[String] fix before/after[Last]() returning the empty string instead of the original one on non-match#38678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…of the original one on non-match
1bc1644 to22a2740Compare
javiereguiluz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I agree and I also think that this change is a "bug fix" and not a "BC break".
Nyholm left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you
The current behavior is the least useful one. Returning the original string when no match is found is the most sensible behavior. It saves code instead of requiring more.
Typical example is when removing a potential suffix:
$bar = $foo->beforeLast(['.svg', '.png']);should remove any of these extensions if found, and return the original string otherwise.