Category
stdlib — php-src-strict PHP 8.4 rounding mode on number_format()
Problem
PHP 8.4 adds an optional 5th $rounding_mode argument (RoundingMode|int) to number_format(). This compiler registers the RoundingMode enum for round() (#5934) but number_format() still rejects any 5th argument with LogicException: number_format() requires one to four arguments.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r '"'"'var_dump(number_format(1.55, 1, ".", "", RoundingMode::HalfAwayFromZero));'"'"''
Zend (PHP 8.4+):
string(3) "2.0" # example — exact string per mode
This compiler (bin/vm.php):
LogicException: number_format() requires one to four arguments
Contrast: round(2.5, 0, RoundingMode::HalfAwayFromZero) already works on VM.
Scope (PHP-in-PHP)
ext/standard/number_format.php — accept argc 5; delegate mode resolution to VmRoundMode / RoundingMode enum
ext/standard/VmNumberFormat.php — apply rounding mode in formatting path
ext/standard/JitNumberFormat.php — JIT/AOT 5-arg lowering (reuse JitRoundModeResolve / RoundingModeJit)
- Reuse
ext/standard/VmRoundMode.php SSOT; do not duplicate mode tables in LLVM
Done when (php-src-strict)
- Repro matches Zend output for
HalfAwayFromZero, HalfEven, and legacy int mode passthrough.
- Invalid mode operands TypeError/ValueError like Zend.
- Compliance guards
test/compliance/cases/stdlib/number_format_rounding_mode.phpt (+ JIT variant) green.
script/capability-matrix.php notes 5-arg number_format when matrix regen runs.
Related
#5934 (round() + RoundingMode), #8795 (enum operand coercion on number_format args).
Category
stdlib— php-src-strict PHP 8.4 rounding mode onnumber_format()Problem
PHP 8.4 adds an optional 5th
$rounding_modeargument (RoundingMode|int) tonumber_format(). This compiler registers theRoundingModeenum forround()(#5934) butnumber_format()still rejects any 5th argument withLogicException: number_format() requires one to four arguments.php-src reference
PHP_FUNCTION(number_format)5-arg signature_php_math_number_format_ex()rounding mode dispatch (shared withround())enum RoundingModeRepro
Zend (PHP 8.4+):
This compiler (
bin/vm.php):Contrast:
round(2.5, 0, RoundingMode::HalfAwayFromZero)already works on VM.Scope (PHP-in-PHP)
ext/standard/number_format.php— accept argc 5; delegate mode resolution toVmRoundMode/RoundingModeenumext/standard/VmNumberFormat.php— apply rounding mode in formatting pathext/standard/JitNumberFormat.php— JIT/AOT 5-arg lowering (reuseJitRoundModeResolve/RoundingModeJit)ext/standard/VmRoundMode.phpSSOT; do not duplicate mode tables in LLVMDone when (php-src-strict)
HalfAwayFromZero,HalfEven, and legacy int mode passthrough.test/compliance/cases/stdlib/number_format_rounding_mode.phpt(+ JIT variant) green.script/capability-matrix.phpnotes 5-argnumber_formatwhen matrix regen runs.Related
#5934 (
round()+RoundingMode), #8795 (enum operand coercion onnumber_formatargs).