-
-
Notifications
You must be signed in to change notification settings - Fork 72
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new Psl\Str\reverse() function #238
Conversation
Pull Request Test Coverage Report for Build 1354621226
💛 - Coveralls |
split -> chunk. named 'encoding' parameter. Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
add @psalm-pure Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
tests are final Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
Mmmh. I think this would be better accomplished with a regex_split. With this it would be possible to capture multibyte extended unicode sequences: use Psl\Vec;
$rev_array = Vec\reverse(\preg_split('/(\X)/u', $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)); I've been testing and this would work with much more complex unicode sequences. The "problem" is that as far as I can see, we cannot pass additional flags to For a use-case like this, would using the native Also, going through |
I think that's not needed, I'm happy with the current version, and i don't think we need to overdo it here. |
Good. Thanks for all your help. Further checking shows that the regex version also seems to choke with extended unicode chars (trying with emojis like this '👩👩👦👩🏽❤️👨🏼👩🏽🏫', given my ignorance of more interesting languages). Would it be ok if I also created a PR for |
Yes, i think that would be a nice addition as well :) |
Psl\Str\Byte\reverse() exists, providing the functionality of strrev(), but there is no multibyte equivalent on the Psl\Str namespace.
This still breaks on some complex characters, as some multi byte emojis, but for that it would probably better to create a Psl\Str\Grapheme\reverse() for completion sake.