Skip to content

ext/intl: GH-17006 part 1, NumberFormat and NumberFormatter co-existing. #17073

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Dec 6, 2024

Those APIs are not particularly 1:1, here using NumberFormatter for NumberFormatter::format/numft_format at the moment, trying to assess what's possible for next.

…sting.

Those APIs are not particularly 1:1, here using NumberFormatter for
NumberFormatter::format/numft_format at the moment, trying to assess
what's possible for next.
@devnexen devnexen force-pushed the gh17006 branch 2 times, most recently from 8177c3b to c5000b0 Compare December 6, 2024 23:41
@devnexen devnexen force-pushed the gh17006 branch 2 times, most recently from 097ce25 to a180872 Compare December 9, 2024 08:55
Calling just ::format is more straightforward.
@devnexen
Copy link
Member Author

cc @cmb69 when you get the chance .. no need to be too "pedantic" about details for now just to know if I m heading in the right direction(s).

@devnexen devnexen requested a review from cmb69 January 18, 2025 11:57
@cmb69
Copy link
Member

cmb69 commented Jan 23, 2025

Hmm, not sure whether this approach is the best idea. Maybe it's better to postpone using NumberFormatter to PHP 9 (what might be next after 8.5), and than to require ICU >= 60.1, and let userland handle the BC break.

Another option might be to additionally support NumberFormatter for 8.5, but as explicit opt-in from userland (and of course only possible with ICU >= 60.1).

Perhaps this should be discussed on the internal mailing list first.

@devnexen
Copy link
Member Author

Thanks for your time. I would rather aim 9.0 but ideally there should be no change in the php POV, do not know if writing to ML is enough in that case ?

@BogdanUngureanu
Copy link
Contributor

@devnexen Imo, having both implementations in the same PHP class might cause some complications if we'll try to implement other ICU classes/functions that depend on the NumberFormatter.

Some ICU classes like RelativeDateTimeFormatter accepts the old NumberFormat, while newer classes like NumberRangeFormatter use the newer NumberFormatter.

I mean, sure, there might be some checks at runtime that validates if the right NF is used, but imho this sounds like a bad API design and a bit opaque.

What do you think if we do the same thing ICU did and implement a separate class? For example, we could namespace it like Intl\NumberFormatter and leave the existing one as it is.

@devnexen
Copy link
Member Author

Seeing that both do not match feature wise and NumberFormat is going to be obsolete, it makes more sense to separate them. Only needs to work out future missing features (e.g. currency parsing I believe).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants