Skip to content

Commit 7a3eab6

Browse files
nanasessclaude
andcommitted
ci: 解消済み phpt を docker-phpt-tests の skip から除外し README を更新
方向系モードと bcdivmod の実装により、以下8件の公式 phpt テストが 拡張なし環境でも通るようになったため --skip から除外する: bcdivmod, bcdivmod_by_zero, bcround_all, bcround_away_from_zero, bcround_ceiling, bcround_floor, bcround_toward_zero, bcround_early_return README には bcdivmod・全RoundingMode対応と、symfony/polyfill-php84 との共存挙動 (PHP 8.2/8.3 + 拡張ありでのオートロード順) を追記。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 872e5bf commit 7a3eab6

2 files changed

Lines changed: 35 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ jobs:
9898
# scale_ini test skipped: bcmath.scale INI setting ignored without native extension
9999
# gh20006 test skipped: requires BcMath\Number OOP API (not supported by polyfill)
100100
# bcround_precision_bounds test skipped: requires BcMath\Number OOP API (not supported by polyfill)
101-
docker run --rm -v $PWD:/app bcmath-phpt-test:${{ matrix.php-version }} --skip bcdivmod,bug54598,bug72093,bug75178,gh15968,gh16262,scale_ini,bcmul_check_overflow,bug78878,bcpow_error1,bcpow_error2,bcpow_error3,bcpowmod_error,bcpowmod_with_mod_1,bcpowmod_zero_modulus,bcround_all,bcround_away_from_zero,bcround_ceiling,bcround_early_return,bcround_floor,bcround_toward_zero,bcscale_variation003,bcdivmod_by_zero,gh20006,bcround_precision_bounds
101+
# bcround directional modes + bcdivmod are now implemented, so those phpt tests no longer need skipping.
102+
docker run --rm -v $PWD:/app bcmath-phpt-test:${{ matrix.php-version }} --skip bug54598,bug72093,bug75178,gh15968,gh16262,scale_ini,bcmul_check_overflow,bug78878,bcpow_error1,bcpow_error2,bcpow_error3,bcpowmod_error,bcpowmod_with_mod_1,bcpowmod_zero_modulus,bcscale_variation003,gh20006,bcround_precision_bounds
102103
strategy:
103104
fail-fast: false
104105
matrix:

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
## 🚀 Features
1818

1919
- ✅ Complete bcmath extension polyfill for PHP 8.1+
20-
- ✅ Supports all PHP 8.4+ bcmath functions including `bcfloor()`, `bcceil()`, and `bcround()`
20+
- ✅ Supports all PHP 8.4+ bcmath functions including `bcfloor()`, `bcceil()`, `bcround()`, and `bcdivmod()`
2121
- ✅ PHP 8.5 compatibility tested and verified
2222
- ✅ Zero dependencies in production (uses phpseclib for arbitrary precision math)
2323
- ✅ Seamless fallback when bcmath extension is not available
@@ -54,6 +54,13 @@ echo bcround('2.5', 0, \RoundingMode::HalfAwayFromZero); // 3
5454
echo bcround('2.5', 0, \RoundingMode::HalfTowardsZero); // 2
5555
echo bcround('2.5', 0, \RoundingMode::HalfEven); // 2
5656
echo bcround('2.5', 0, \RoundingMode::HalfOdd); // 3
57+
echo bcround('2.5', 0, \RoundingMode::TowardsZero); // 2
58+
echo bcround('2.5', 0, \RoundingMode::AwayFromZero); // 3
59+
echo bcround('2.5', 0, \RoundingMode::PositiveInfinity); // 3
60+
echo bcround('2.5', 0, \RoundingMode::NegativeInfinity); // 2
61+
62+
// bcdivmod() returns [quotient, remainder]
63+
[$quot, $rem] = bcdivmod('17', '5'); // ['3', '2']
5764
```
5865

5966
## 📋 Supported Functions
@@ -74,20 +81,39 @@ echo bcround('2.5', 0, \RoundingMode::HalfOdd); // 3
7481
- `bcfloor()` - Round down to the nearest integer
7582
- `bcceil()` - Round up to the nearest integer
7683
- `bcround()` - Round to a specified precision with configurable rounding modes
84+
- `bcdivmod()` - Get the quotient and remainder of a division in a single call
7785

7886
#### RoundingMode Enum Support
79-
The `bcround()` function supports PHP 8.4's `RoundingMode` enum through a polyfill for PHP 8.1-8.3:
87+
The `bcround()` function supports PHP 8.4's `RoundingMode` enum through a polyfill for PHP 8.1-8.3.
88+
All eight native modes are implemented with exact, arbitrary-precision string arithmetic (no float
89+
fallback), so results match the native `bcround()` even for very large or high-precision numbers:
8090

81-
**Supported Modes:**
8291
- `RoundingMode::HalfAwayFromZero` (equivalent to `PHP_ROUND_HALF_UP`)
8392
- `RoundingMode::HalfTowardsZero` (equivalent to `PHP_ROUND_HALF_DOWN`)
8493
- `RoundingMode::HalfEven` (equivalent to `PHP_ROUND_HALF_EVEN`)
8594
- `RoundingMode::HalfOdd` (equivalent to `PHP_ROUND_HALF_ODD`)
95+
- `RoundingMode::TowardsZero`
96+
- `RoundingMode::AwayFromZero`
97+
- `RoundingMode::NegativeInfinity`
98+
- `RoundingMode::PositiveInfinity`
99+
100+
The legacy integer `PHP_ROUND_*` constants are also accepted for the four half-modes.
101+
102+
> **Note:** The polyfilled `RoundingMode` is a *pure* enum, matching native PHP 8.4 (it has no
103+
> backing value; `->value` / `from()` / `tryFrom()` are intentionally unavailable).
104+
105+
#### Interoperability with `symfony/polyfill-php84`
106+
107+
`symfony/polyfill-php84` also declares `bcceil()`, `bcfloor()`, `bcround()` and `bcdivmod()`, but only
108+
when the native bcmath extension is **already loaded** (its purpose is to backport the new PHP 8.4
109+
functions to older PHP that already has bcmath). This package instead provides the full bcmath API for
110+
environments **without** the extension.
86111

87-
**Not Yet Supported:**
88-
- `RoundingMode::TowardsZero` - Throws `ValueError` (planned for future release)
89-
- `RoundingMode::AwayFromZero` - Throws `ValueError` (planned for future release)
90-
- `RoundingMode::NegativeInfinity` - Throws `ValueError` (planned for future release)
112+
When both packages are installed on an environment that *does* have the bcmath extension and runs
113+
**PHP 8.2/8.3**, both declare `bcceil()`/`bcfloor()`/`bcround()`; whichever autoloads first wins (the
114+
`function_exists()` guards prevent a fatal redeclaration). This package's rounding is implemented with a
115+
native-compatible string algorithm, so the numeric results are identical regardless of which
116+
implementation is used. On environments without the extension only this package is active.
91117

92118
## ⚡ Performance
93119

0 commit comments

Comments
 (0)