[7.x] Add split() to Stringable class#32713
Merged
Merged
Conversation
added 2 commits
May 7, 2020 11:28
Collaborator
|
I think you will need to first add this method to the Str class. |
GrahamCampbell
requested changes
May 7, 2020
| */ | ||
| public function split($pattern, $limit = -1, $flags = 0) | ||
| { | ||
| $keywords = preg_split($pattern, $this->value, $limit, $flags); |
Collaborator
There was a problem hiding this comment.
What about error handling?
Author
There was a problem hiding this comment.
preg_split returns false on failing
Collaborator
There was a problem hiding this comment.
Yes, and then you hide the error? Fail doesn't mean no matches, it means that the pattern was invalid, but you hide this.
Author
There was a problem hiding this comment.
Ok get it! What's the recommended handling in this case? Removing the condition? Errors seem to be ignored for most methods
eg:
Author
As it was similar to |
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.
Add a
split()method to Stringable as a proxy topreg_split()to allow splitting by regex in addition ofexplode()Example