-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
ValueError: NumberFormatter::format(): Argument #3 must be a NumberFormatter::TYPE_* constant #9421
Comments
So there's two bugs here:
Notice the other syntax: numfmt_format(NumberFormatter $formatter, int|float $num, int $type = NumberFormatter::TYPE_DEFAULT): string|false Internally, class methods look a lot like regular functions that happen to take the "this" object as the first argument, and the procedural syntax for Given this procedural/OOP stuff is a common setup, I assume this "is it argument 2 or 3?" problem has a standard solution.
This is likely deliberate because there's a IMO this needs two fixes: one that PHP detects |
glad someone agrees that something is amiss. both of the proposed fixes sound like the correct direction. just for full vision the reason i did what i did the way i did, was it seemed like numberformatter could be told to init with a locale and desired formatting. and indeed i noticed the formatCurrency method, and more specifically, that the format method took a type. this suggested to me that i should initialise one numberformatter global to my app instance, using the user's preferences, and for consistency sake across all my various calls, i elected to only use |
It seems so far it has not. In theory it could be done by modifying the
So we likely need to handle the individual calls.
I would go with a doc fix only, but given that it is documented to support any |
Description
from the php manual
not quite sure about this mystical argument # 3.
Resulted in this output:
But I expected this output instead:
https://3v4l.org/mc4XU
PHP Version
PHP 8+
Operating System
Linux 5.4.0-88-generic # 99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[edit] idk it says i added those tags (bugs, triage) but they showed up on their own i just report the news
The text was updated successfully, but these errors were encountered: