-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
[Str] add grarpheme support #74
Conversation
ac837f8
to
bdfca5e
Compare
bdfca5e
to
05b6b3c
Compare
src/Psl/Str/Grapheme/length.php
Outdated
*/ | ||
function length(string $string): int | ||
{ | ||
return (int) grapheme_strlen($string); |
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 think there's a case where grapheme_strlen returns null
, not sure how to handle that.
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.
The docs state it always returns an int though:
https://www.php.net/manual/en/function.grapheme-strlen.php
(We could keep it - just to be sure :) )
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 learned to never belive the documentation 😆
see:
- https://github.com/php/php-src/blob/e73bf01f9d0c23dd5baed4445b37c93ec4e0ab29/ext/intl/php_intl.stub.php#L246
- https://github.com/php/php-src/blob/7af24eaedd310911940643d7a5f412393b973389/ext/intl/grapheme/grapheme_string.c#L84
- https://github.com/php/php-src/blob/7af24eaedd310911940643d7a5f412393b973389/ext/intl/grapheme/grapheme_string.c#L96
not sure how to handle these cases ...
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 added invariant violation checks.
a1d030c
to
9ec32cb
Compare
/cc @veewee If you think we can move ahead with this, let's merge it. |
9ec32cb
to
9f0bb13
Compare
Pull Request Test Coverage Report for Build 715
💛 - Coveralls |
9f0bb13
to
33fd4e2
Compare
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.
Besides the conflicts, it Looks OK to me...
src/Psl/Str/Grapheme/length.php
Outdated
*/ | ||
function length(string $string): int | ||
{ | ||
return (int) grapheme_strlen($string); |
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.
The docs state it always returns an int though:
https://www.php.net/manual/en/function.grapheme-strlen.php
(We could keep it - just to be sure :) )
3b0c554
to
f322e91
Compare
f322e91
to
bba7f5f
Compare
closes #62
refs #63