Bug #79212 [Opn]: NumberFormatter::format() may detect wrong type

From: Date: Sun, 02 Feb 2020 11:20:19 +0000
Subject: Bug #79212 [Opn]: NumberFormatter::format() may detect wrong type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225305@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79212&edit=1 ID: 79212 Updated by: cmb@php.net Reported by: cmb@php.net Summary: NumberFormatter::format() may detect wrong type Status: Open Type: Bug Package: I18N and L10N related Operating System: * PHP Version: 7.3Git-2020-02-02 (Git) Block user comment: N Private report: N New Comment: Well, the expected result above is obviously wrong, but apparently, we're additionally hitting an ICU4C bug here[1]. Anyhow, using ::PATTERN_DECIMAL instead of ::SPELLOUT, we get string(11) "-1129447424" while we should expect string(21) "823749273428379400000" [1] <https://unicode-org.atlassian.net/browse/ICU-8223> Previous Comments: ------------------------------------------------------------------------ [2020-02-02 10:44:16] cmb@php.net Description: ------------ If ::format() is called with ::TYPE_DEFAULT, but the value is an object which implements cast to number, the type is erroneously assumed to be ::TYPE_INT32. This issue has been reported by googleguy@php.net in r11. Test script: --------------- <?php $fmt = new NumberFormatter('en_US', NumberFormatter::SPELLOUT); var_dump($fmt->format(gmp_init('823749273428379492374'))); ?> Expected result: ---------------- string(157) "eighteen quadrillion fourteen trillion three hundred ninety-eight billion five hundred nine million four hundred eighty-one thousand nine hundred eighty-four" Actual result: -------------- string(108) "minus one billion one hundred twenty-nine million four hundred forty-seven thousand four hundred twenty-four" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79212&edit=1

« previous php.bugs (#225305) next »