Summary
number_format() rejects numeric strings for argument #1 ("1234.5"), while Zend coerces numeric strings to float/int before formatting. This breaks common web/form code paths.
Related but distinct from #3549 (internal strpos/strlen rules).
php-src reference
Repro
<?php
echo number_format("1234.567", 2), "\n"; // Zend: 1,234.57
This compiler (VM):
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "echo number_format(\"1234.5\", 2), \"\\n\";"'
# LogicException: number_format() number must be an integer or float in this compiler build
Current guard: ext/standard/number_format.php lines 37–38 (strict int/float only).
Expected
- Accept int, float, and numeric strings (including
"1234.5", "1e3").
- Reject non-numeric strings with
TypeError (PHP 8+) or Warning+0 per Zend for invalid input.
- JIT/AOT: same coercion in
JitNumberFormat::format().
Scope
- VM + JIT + AOT.
- Compliance:
test/compliance/cases/stdlib/number_format_numeric_string.phpt.
Summary
number_format()rejects numeric strings for argument #1 ("1234.5"), while Zend coerces numeric strings to float/int before formatting. This breaks common web/form code paths.Related but distinct from #3549 (internal
strpos/strlenrules).php-src reference
PHP_FUNCTION(number_format)usesZEND_PARSE_PARAMETERSwith numeric coercionRepro
This compiler (VM):
Current guard:
ext/standard/number_format.phplines 37–38 (strict int/float only).Expected
"1234.5","1e3").TypeError(PHP 8+) orWarning+0per Zend for invalid input.JitNumberFormat::format().Scope
test/compliance/cases/stdlib/number_format_numeric_string.phpt.