Category
stdlib
Problem
number_format() argument #1 must be int|float in PHP 8+. Passing an array must throw TypeError. This compiler fails to validate and may proceed with undefined behavior instead of matching Zend.
php-src reference
Repro
<?php
try {
number_format(['x']);
} catch (Throwable $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
// Zend: TypeError: number_format(): Argument #1 ($num) must be of type float, array given
// vm.php today: no TypeError (silent/wrong path)
./script/docker-exec.sh -- bash -lc '
php -r "try { number_format([\"x\"]); } catch (Throwable \$e) { echo get_class(\$e),\": \",\$e->getMessage(),PHP_EOL; }"
php bin/vm.php -r "try { number_format([\"x\"]); } catch (Throwable \$e) { echo get_class(\$e),\": \",\$e->getMessage(),PHP_EOL; }"
'
Scope
| Area |
Files |
| VM |
ext/standard/number_format.php |
| JIT/AOT |
ext/standard/JitNumberFormat.php |
| Tests |
test/compliance/cases/stdlib/number_format_type_error.phpt |
Done when
Category
stdlibProblem
number_format()argument #1 must beint|floatin PHP 8+. Passing an array must throwTypeError. This compiler fails to validate and may proceed with undefined behavior instead of matching Zend.php-src reference
ext/standard/number_format.c—php_number_format()Z_PARAM_NUMBER / type checksRepro
Scope
ext/standard/number_format.phpext/standard/JitNumberFormat.phptest/compliance/cases/stdlib/number_format_type_error.phptDone when
TypeErroron VM/JIT/AOT$numbehavior remains covered by Stdlib: number_format() — decimals argument must accept numeric strings (ext/standard/number_format.c) #4148 separately