Skip to content

Regression: number_format() — enum case operand coerces not TypeError (re-#5892, number_format.c) #8795

Description

@PurHur

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions