-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Add Helper::width() and Helper::length() #40698
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
Conversation
From https://semver.org/#spec-item-7
Should we mark the new methods as |
Oh, thank you. The PR is updated |
about the name, what about length() and width()? On 5.x, I'd be in favor of deprecating the current methods, including strlenWithoutDecoration(), and tell ppl to use removeDecoration instead. if you agree with this plan, we could skip using strlenWithoutDecoration() in this PR. WDYT? |
Agree 👍 |
$string = self::removeDecoration($formatter, $string); | ||
|
||
if (preg_match('//u', $string)) { | ||
return (new UnicodeString($string))->width(true); |
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 true
here is for "remove ansi decoration", but that is already done in self::removeDecoration
.
Thank you for the reviews. The PR is updated. |
If we deprecated |
They will no longer be internal as soon as they will be publicly introduced in 5.3, at the same time we will deprecate |
Thank you @Nyholm. |
Great. Thank you for merging |
…ength() (Nyholm) This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Console] Deprecate Helper::strlen() for width() and length() | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | yes | Deprecations? | yes | Tickets | Follow up form #40698 | License | MIT | Doc PR | This PR will deprecated `Helper::strlen()` since it is actually calculating the width. I remove the `@internal` on `Helper::width()` and a `Helper::length()`. I will also deprecate `Helper::strlenWithoutDecoration()` because you should use `Helper::removeDecoration()` instead. Commits ------- 3c24aa9 [Console] Deprecate Helper::strlen() for width() and length()
This PR will add add a Helper::strwidth() and a Helper::strlength(). Same with with the Helper::strlenWithoutDecoration(). It does not deprecate anything. That is done in #40695
With this PR we dont have to revert the emoji issue (ie close #40697)
FYI @grasmash, I used your tests from #40635