Skip to content

Commit 8cc472d

Browse files
Ayeshdevnexen
authored andcommitted
ext/intl: Add NumberFormatter::ROUND_HALFODD
The NumberFormatter::ROUND_HALFEVEN constant exists in PHP already, but its counterpart ROUND_HALFODD was missing. This adds it, using `UNUM_ROUND_HALF_ODD` Close GH-13191
1 parent 43b62b7 commit 8cc472d

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Intl:
4242
throws an exception. (David Carlier)
4343
. Added NumberFormatter::ROUND_TOWARD_ZERO and ::ROUND_AWAY_FROM_ZERO as
4444
aliases for ::ROUND_DOWN and ::ROUND_UP. (Jorg Sowa)
45+
. Added NumberFormatter::ROUND_HALFODD. (Ayesh Karunaratne)
4546

4647
MBString:
4748
. Added mb_trim, mb_ltrim and mb_rtrim. (Yuya Hamada)

UPGRADING

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,9 @@ PDO_SQLITE:
281281
. NumberFormatter::ROUND_TOWARD_ZERO and NumberFormatter::ROUND_AWAY_FROM_ZERO
282282
have been added as aliases for NumberFormatter::ROUND_DOWN and
283283
NumberFormatter::ROUND_UP to be consistent with the new PHP_ROUND_* modes.
284-
285284
RFC: https://wiki.php.net/rfc/new_rounding_modes_to_round_function
285+
. NumberFormatter::ROUND_HALFODD added to complement existing
286+
NumberFormatter::ROUND_HALFEVEN functionality.
286287

287288
- MBString:
288289
. The behavior of mb_strcut is more consistent now on invalid UTF-8 and UTF-16

ext/intl/formatter/formatter.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class NumberFormatter
5050
public const int ROUND_AWAY_FROM_ZERO = UNKNOWN;
5151
/** @cvalue UNUM_ROUND_HALFEVEN */
5252
public const int ROUND_HALFEVEN = UNKNOWN;
53+
/** @cvalue UNUM_ROUND_HALF_ODD */
54+
public const int ROUND_HALFODD = UNKNOWN;
5355
/** @cvalue UNUM_ROUND_HALFDOWN */
5456
public const int ROUND_HALFDOWN = UNKNOWN;
5557
/** @cvalue UNUM_ROUND_HALFUP */

ext/intl/formatter/formatter_arginfo.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/tests/formatter/rounding_modes.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var_dump(NumberFormatter::ROUND_TOWARD_ZERO);
1313
var_dump(NumberFormatter::ROUND_UP);
1414
var_dump(NumberFormatter::ROUND_AWAY_FROM_ZERO);
1515
var_dump(NumberFormatter::ROUND_HALFEVEN);
16+
var_dump(NumberFormatter::ROUND_HALFODD);
1617
var_dump(NumberFormatter::ROUND_HALFDOWN);
1718
var_dump(NumberFormatter::ROUND_HALFUP);
1819

@@ -27,6 +28,7 @@ int(2)
2728
int(3)
2829
int(3)
2930
int(4)
31+
int(8)
3032
int(5)
3133
int(6)
3234
bool(true)

0 commit comments

Comments
 (0)