Skip to content

Commit

Permalink
ext/intl: Add NumberFormatter::ROUND_HALFODD
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ayesh authored and devnexen committed Jan 18, 2024
1 parent 43b62b7 commit 8cc472d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Intl:
throws an exception. (David Carlier)
. Added NumberFormatter::ROUND_TOWARD_ZERO and ::ROUND_AWAY_FROM_ZERO as
aliases for ::ROUND_DOWN and ::ROUND_UP. (Jorg Sowa)
. Added NumberFormatter::ROUND_HALFODD. (Ayesh Karunaratne)

MBString:
. Added mb_trim, mb_ltrim and mb_rtrim. (Yuya Hamada)
Expand Down
3 changes: 2 additions & 1 deletion UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ PDO_SQLITE:
. NumberFormatter::ROUND_TOWARD_ZERO and NumberFormatter::ROUND_AWAY_FROM_ZERO
have been added as aliases for NumberFormatter::ROUND_DOWN and
NumberFormatter::ROUND_UP to be consistent with the new PHP_ROUND_* modes.

RFC: https://wiki.php.net/rfc/new_rounding_modes_to_round_function
. NumberFormatter::ROUND_HALFODD added to complement existing
NumberFormatter::ROUND_HALFEVEN functionality.

- MBString:
. The behavior of mb_strcut is more consistent now on invalid UTF-8 and UTF-16
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/formatter/formatter.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class NumberFormatter
public const int ROUND_AWAY_FROM_ZERO = UNKNOWN;
/** @cvalue UNUM_ROUND_HALFEVEN */
public const int ROUND_HALFEVEN = UNKNOWN;
/** @cvalue UNUM_ROUND_HALF_ODD */
public const int ROUND_HALFODD = UNKNOWN;
/** @cvalue UNUM_ROUND_HALFDOWN */
public const int ROUND_HALFDOWN = UNKNOWN;
/** @cvalue UNUM_ROUND_HALFUP */
Expand Down
8 changes: 7 additions & 1 deletion ext/intl/formatter/formatter_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ext/intl/tests/formatter/rounding_modes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var_dump(NumberFormatter::ROUND_TOWARD_ZERO);
var_dump(NumberFormatter::ROUND_UP);
var_dump(NumberFormatter::ROUND_AWAY_FROM_ZERO);
var_dump(NumberFormatter::ROUND_HALFEVEN);
var_dump(NumberFormatter::ROUND_HALFODD);
var_dump(NumberFormatter::ROUND_HALFDOWN);
var_dump(NumberFormatter::ROUND_HALFUP);

Expand All @@ -27,6 +28,7 @@ int(2)
int(3)
int(3)
int(4)
int(8)
int(5)
int(6)
bool(true)
Expand Down

0 comments on commit 8cc472d

Please sign in to comment.