Skip to content

Commit 505cc77

Browse files
committed
Fix #78912: INTL Support for accounting format
We provide `NumberFormatter::CURRENCY_ACCOUNTING` to wrap `UNUM_CURRENCY_ACCOUNTING `[1]. [1] <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/unum_8h.html#a4eb4d3ff13bd506e7078b2be4052266dae97cdd7ed612d07d251021c076efb1c5>
1 parent 8d36d79 commit 505cc77

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ PHP NEWS
2727
. Fixed bug #78916 (php-fpm 7.4.0 don't send mail via mail()).
2828
(Jakub Zelenka)
2929

30+
- Intl:
31+
. Implemented FR #78912 (INTL Support for accounting format). (cmb)
32+
3033
- Mysqlnd:
3134
. Fixed bug #78823 (ZLIB_LIBS not added to EXTRA_LIBS). (Arjen de Korte)
3235

ext/intl/formatter/formatter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ void formatter_register_constants( INIT_FUNC_ARGS )
5151
FORMATTER_EXPOSE_CLASS_CONST( DURATION );
5252
FORMATTER_EXPOSE_CLASS_CONST( PATTERN_RULEBASED );
5353
FORMATTER_EXPOSE_CLASS_CONST( IGNORE );
54-
54+
#if U_ICU_VERSION_MAJOR_NUM >= 53
55+
FORMATTER_EXPOSE_CLASS_CONST( CURRENCY_ACCOUNTING );
56+
#endif
5557
FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_STYLE", UNUM_DEFAULT );
5658

5759
/* UNumberFormatRoundingMode */

ext/intl/tests/bug78912.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Request #78912 (INTL Support for accounting format)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('intl')) die('skip intl extension not available');
6+
if (version_compare(INTL_ICU_VERSION, '53.0') < 0) die('skip for ICU >= 53.0');
7+
?>
8+
--FILE--
9+
<?php
10+
$nf = new NumberFormatter('en_US', NumberFormatter::CURRENCY_ACCOUNTING);
11+
var_dump($nf->formatCurrency(-12345.67, 'USD'));
12+
?>
13+
--EXPECT--
14+
string(12) "($12,345.67)"

0 commit comments

Comments
 (0)