-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Intl: Add a new IntlNumberRangeFormatter class #19232
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
a0a407b
0e083db
6f6694e
47aa5fb
775e987
c044342
b9e5957
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** @generate-class-entries */ | ||
|
||
/** | ||
* @not-serializable | ||
* @strict-properties | ||
*/ | ||
final class IntlNumberRangeFormatter { | ||
#if U_ICU_VERSION_MAJOR_NUM >= 63 | ||
/** @cvalue UNUM_RANGE_COLLAPSE_AUTO */ | ||
public const int COLLAPSE_AUTO = UNKNOWN; | ||
|
||
/** @cvalue UNUM_RANGE_COLLAPSE_NONE */ | ||
public const int COLLAPSE_NONE = UNKNOWN; | ||
|
||
/** @cvalue UNUM_RANGE_COLLAPSE_UNIT */ | ||
public const int COLLAPSE_UNIT = UNKNOWN; | ||
|
||
/** @cvalue UNUM_RANGE_COLLAPSE_ALL */ | ||
public const int COLLAPSE_ALL = UNKNOWN; | ||
|
||
/** @cvalue UNUM_IDENTITY_FALLBACK_SINGLE_VALUE */ | ||
public const int IDENTITY_FALLBACK_SINGLE_VALUE = UNKNOWN; | ||
|
||
/** @cvalue UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE */ | ||
public const int IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE = UNKNOWN; | ||
|
||
/** @cvalue UNUM_IDENTITY_FALLBACK_APPROXIMATELY */ | ||
public const int IDENTITY_FALLBACK_APPROXIMATELY = UNKNOWN; | ||
|
||
/** @cvalue UNUM_IDENTITY_FALLBACK_RANGE */ | ||
public const int IDENTITY_FALLBACK_RANGE = UNKNOWN; | ||
#else | ||
public const int COLLAPSE_AUTO = 0; | ||
|
||
public const int COLLAPSE_NONE = 1; | ||
|
||
public const int COLLAPSE_UNIT = 2; | ||
|
||
public const int COLLAPSE_ALL = 3; | ||
|
||
public const int IDENTITY_FALLBACK_SINGLE_VALUE = 0; | ||
|
||
public const int IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE = 1; | ||
|
||
public const int IDENTITY_FALLBACK_APPROXIMATELY = 2; | ||
|
||
public const int IDENTITY_FALLBACK_RANGE = 3; | ||
#endif | ||
|
||
private function __construct() {} | ||
|
||
public static function createFromSkeleton(string $skeleton, string $locale, int $collapse, int $identityFallback): IntlNumberRangeFormatter {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope I won't upset you too much, but I think these changes will need an RFC, because any API changes involve a lot of bikeshedding lately. For example, we have started to use enums more often (see my https://wiki.php.net/rfc/url_parsing_api RFC), so I think this practice could be continued in your case too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I see that you have recently added the ListFormatter class in #18519 that also has some enum-like constants. It probably also makes sense to stay consistent with the current convention of intl (class constants), so I don't insist on my above suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we decide that we should employ nicer features in intl, we should do a thorough review of not only the constants ,but other mechanisms (like error handling) as well. And then we can make one compelling holistic RFC (if we would desire to do so ;) ). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, that was my reasoning. Since that one didn't need an RFC, I thought this one also won't need it.
Sounds fair. I think for now the API I'm proposing is ok. I do agree introducing the new NumberFormatter will require an RFC. |
||
|
||
public function format(float|int $start, float|int $end): string {} | ||
|
||
public function getErrorCode(): int {} | ||
|
||
public function getErrorMessage(): string {} | ||
} | ||
BogdanUngureanu marked this conversation as resolved.
Show resolved
Hide resolved
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.