Category
stdlib | php-src-strict
Problem
number_format(E::A) on a backed enum case silently coerces to the backing scalar ('1') instead of throwing TypeError. Zend rejects enum objects for the $num parameter.
Regression of #5892 (closed 2026-06-10).
php-src reference
Repro
<?php
declare(strict_types=1);
enum E: int { case A = 1; }
try { var_export(number_format(E::A)); echo "\n"; } catch (Throwable $e) { echo get_class($e), "\n"; }
./script/docker-exec.sh -- bash -lc 'php test/repro-maintainer/parity_number_format_enum.php
php bin/vm.php test/repro-maintainer/parity_number_format_enum.php'
| Runtime |
Output |
| Zend |
TypeError |
| VM today |
'1' |
Existing repro: test/repro-maintainer/parity_number_format_enum.php
Scope (this repo)
| Path |
Work |
ext/standard/number_format.php |
Typed $num guard — reject enum objects before scalar coercion |
lib/JIT/ number_format lowering |
JIT/AOT parity |
| Tests |
compliance phpt under test/compliance/cases/stdlib/ |
PHP-in-PHP: fix guard in ext/standard; reuse shared numeric builtin arg helpers.
Done when
Related
#5892 · #8728 · #5934 · #8746 · #1492
Category
stdlib| php-src-strictProblem
number_format(E::A)on a backed enum case silently coerces to the backing scalar ('1') instead of throwing TypeError. Zend rejects enum objects for the$numparameter.Regression of #5892 (closed 2026-06-10).
php-src reference
ext/standard/number_format.c—php_number_format,_number_formatparameter typingZend/zend_enum.c— enum is object, not numeric for number_formatRepro
TypeError'1'Existing repro:
test/repro-maintainer/parity_number_format_enum.phpScope (this repo)
ext/standard/number_format.php$numguard — reject enum objects before scalar coercionlib/JIT/number_format loweringtest/compliance/cases/stdlib/PHP-in-PHP: fix guard in
ext/standard; reuse shared numeric builtin arg helpers.Done when
number_format()TypeError on enum case operand (VM)number_format(1.5)/ RoundingMode 5th arg (Stdlib: RoundingMode enum + number_format() 5th argument (PHP 8.4, ext/standard/number_format.c) #5934)Related
#5892 · #8728 · #5934 · #8746 · #1492