forked from phpseclib/bcmath_compat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoundingMode.php
More file actions
26 lines (25 loc) · 911 Bytes
/
RoundingMode.php
File metadata and controls
26 lines (25 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
* RoundingMode enum polyfill for PHP 8.1-8.3.
*
* This enum provides the same interface as PHP 8.4's native RoundingMode enum,
* but TowardsZero, AwayFromZero, and NegativeInfinity will throw exceptions
* when used in PHP < 8.4 to maintain compatibility expectations.
*
* The enum is only defined if:
* - PHP version is 8.1 or higher (enum support)
* - Native RoundingMode enum doesn't already exist (PHP < 8.4)
*/
// @phpstan-ignore-next-line
if (!enum_exists('RoundingMode') && version_compare(PHP_VERSION, '8.1', '>=')) {
enum RoundingMode: string
{
case HalfAwayFromZero = 'half_away_from_zero';
case HalfTowardsZero = 'half_towards_zero';
case HalfEven = 'half_even';
case HalfOdd = 'half_odd';
case TowardsZero = 'towards_zero';
case AwayFromZero = 'away_from_zero';
case NegativeInfinity = 'negative_infinity';
}
}