Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ jobs:
- name: Build Docker test image
run: docker build -f Dockerfile.test-without-bcmath --build-arg PHP_VERSION=${{ matrix.php-version }} -t bcmath-phpt-test:${{ matrix.php-version }} .
- name: Run Docker-based PHPT tests
run: docker run --rm -v $PWD:/app bcmath-phpt-test:${{ matrix.php-version }} --skip bcceil,bccomp,bcdivmod,bcfloor,bcmod,bcpow,bcpowmod,bcround,bcscale,bug54598,bug72093,bug75178,gh15968,gh16262,scale_ini,str2num_formatting,bcmul_check_overflow,bug78878,bccomp_variation001,bccomp_variation002,bcdivmod_by_zero,bcmod_error2,bcpow_div_by_zero,bcpow_error1,bcpow_error2,bcpow_error3,bcpow_large_numbers,bcpow_zero,bcpowmod_error,bcpowmod_with_mod_1,bcpowmod_zero_modulus,bcround_all,bcround_away_from_zero,bcround_ceiling,bcround_early_return,bcround_floor,bcround_half_down,bcround_toward_zero,bcscale_variation003
run: |
# scale_ini test skipped: bcmath.scale INI setting ignored without native extension
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
strategy:
fail-fast: false
matrix:
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ This polyfill uses [phpseclib](https://github.com/phpseclib/phpseclib)'s BigInte
- Recommended approach: Don't check for the extension, just use the functions

### Configuration Options
- `ini_set('bcmath.scale', ...)` won't work without the native extension
- Use `bcscale()` instead to set the scale globally
- **bcmath.scale INI setting is ignored**: When the native bcmath extension is not loaded, PHP does not recognize the `bcmath.scale` INI setting. This means:
- `ini_get('bcmath.scale')` returns `false`
- `ini_set('bcmath.scale', ...)` won't work
- INI settings in php.ini or PHPT tests are ignored
- The polyfill defaults to scale 0 when no explicit scale is provided
- **Workaround**: Use `bcscale()` instead to set the scale globally
- To get the current scale:
- PHP >= 7.3.0: Use `bcscale()` without arguments
- PHP < 7.3.0: Use `max(0, strlen(bcadd('0', '0')) - 2)`
Expand Down
3 changes: 2 additions & 1 deletion lib/RoundingMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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
* but TowardsZero, AwayFromZero, NegativeInfinity, and PositiveInfinity will throw exceptions
* when used in PHP < 8.4 to maintain compatibility expectations.
*
* The enum is only defined if:
Expand All @@ -22,5 +22,6 @@ enum RoundingMode: string
case TowardsZero = 'towards_zero';
case AwayFromZero = 'away_from_zero';
case NegativeInfinity = 'negative_infinity';
case PositiveInfinity = 'positive_infinity';
}
}
Loading
Loading