Skip to content

Stdlib: number_format() optional RoundingMode 5th arg (#9438) - #15818

Merged
PurHur merged 1 commit into
masterfrom
fix/9438-number-format-rounding-mode
Jul 4, 2026
Merged

Stdlib: number_format() optional RoundingMode 5th arg (#9438)#15818
PurHur merged 1 commit into
masterfrom
fix/9438-number-format-rounding-mode

Conversation

@PurHur

@PurHur PurHur commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • PHP 8.4 number_format($num, $decimals, $dec, $thou, RoundingMode::…) now accepted when PHP_COMPILER_PROFILE=8.4 / stable 8.4 profile (CompilerVersion::supportsRoundingModeEnum()).
  • VM path resolves mode via VmRoundMode::resolveRoundModeArg() and formats with VmRound::mathRound() in VmNumberFormat::format().
  • JIT/AOT: extended __compiler_number_format ABI + SprintfJitHelper::numberFormat() with mode int64; JitRoundModeArg lowering for arg Stdlib: floatval, boolval, gettype(null) and expanded PHPT specs #5.

php-src reference

ext/standard/number_format.c_php_math_number_format_ex() 5-arg signature

Verification

PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_number_format_rounding_mode.php
# ok

PHP_COMPILER_PROFILE=8.4 php bin/vm.php -r "echo number_format(1.55, 1, '.', '', RoundingMode::HalfAwayFromZero);"
# 1.6

Closes #9438

Made with Cursor

Accept rounding_mode when PHP 8.4 profile is active; delegate to VmRound::mathRound
via VmRoundMode SSOT. Extend __compiler_number_format JIT ABI with mode int64.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: number_format() — optional 5th RoundingMode parameter missing (PHP 8.4, ext/standard/number_format.c)

1 participant