Skip to content

Stdlib: number_format() optional RoundingMode fifth parameter (#9438) - #15819

Merged
PurHur merged 2 commits into
masterfrom
agent/stdlib-number-format-rounding-mode-9438
Jul 4, 2026
Merged

Stdlib: number_format() optional RoundingMode fifth parameter (#9438)#15819
PurHur merged 2 commits into
masterfrom
agent/stdlib-number-format-rounding-mode-9438

Conversation

@PurHur

@PurHur PurHur commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Accept PHP 8.4 optional 5th $rounding_mode (RoundingMode|int) on number_format() — previously rejected with ArgumentCountError.
  • VM path resolves mode via VmRoundMode::resolveRoundModeArg() and applies VmRound::mathRound() in VmNumberFormat::format() (php-src ext/standard/number_format.c / shared _php_math_number_format_ex rounding).
  • JIT/AOT lowering passes mode through JitRoundModeArg → extended __compiler_number_format ABI → SprintfJitHelper::numberFormat().

php-src reference

  • ext/standard/number_format.c — 5-arg signature with RoundingMode|int
  • ext/standard/math.c_php_math_number_format_ex() / _php_math_round()

Verification

# Repro (PHP 8.4 profile)
PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_number_format_rounding_mode.php
# ok

# Docker compliance (VM + JIT)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 vendor/bin/phpunit test/compliance/VMTest.php --filter number_format_rounding_mode'
# OK (2 tests)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 vendor/bin/phpunit test/compliance/JITTest.php --filter number_format_rounding_mode'
# OK (2 tests)

vendor/bin/phpunit test/unit/StringFormatRuntimeShrinkTest.php
# OK (3 tests)

Note: Standalone AOT number_format link (__compiler_number_format) remains on deferred inventory stubs (#14811) — same pre-merge master behavior; AOT fixture added for when full StringFormat standalone bodies land.

Closes #9438

Made with Cursor

Wire PHP 8.4 rounding_mode through VM, JIT, and SprintfJitHelper using
VmRoundMode/VmRound SSOT; extend __compiler_number_format ABI for mode int.

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.

Combine master VM rounding_mode scaffolding with JIT phpt, repro guards,
and SprintfJitHelper ABI fifth-arg mode forwarding.

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.

@PurHur
PurHur merged commit 5bc32ce into master Jul 4, 2026
@PurHur
PurHur deleted the agent/stdlib-number-format-rounding-mode-9438 branch July 4, 2026 03:13
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