Skip to content

Regression: NumberFormatter::parse() error code 1 not U_PARSE_ERROR (9); pollutes intl_get_error_code (ext/intl/formatter) #22855

Description

@PurHur

Category

stdlib · php-src-strict · ext/intl

Problem

On unparseable input, Zend NumberFormatter::parse() returns false, sets the formatter error to U_PARSE_ERROR (code 9) with message Number parsing failed: U_PARSE_ERROR, and leaves the global intl_get_error_code() at 0. This compiler returns false but uses code 1 (U_ILLEGAL_ARGUMENT_ERROR-shaped), prefixes the message with numfmt_parse:, and also writes the failure into the global intl error (code 1).

Probed 2026-07-24 — Zend 8.2.32 vs php bin/vm.php.

Repro Zend 8.2+ VM (2026-07-24)
parse('not-a-number') false false
$f->getErrorCode() 9 (U_PARSE_ERROR) 1
$f->getErrorMessage() Number parsing failed: U_PARSE_ERROR numfmt_parse: Number parsing failed: U_PARSE_ERROR
intl_get_error_code() after 0 1

php-src reference

PHP implementation target

  • ext/intl NumberFormatter parse path (PHP) — map ICU parse failure to code 9 / message without changing Zend’s global-intl non-pollution for this API
  • Expose/recognize U_PARSE_ERROR consistently with other intl status constants
  • No new C

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/nf_parse_err.php <<"PHP"
<?php
$f = new NumberFormatter("en_US", NumberFormatter::DECIMAL);
$r = $f->parse("not-a-number");
var_export($r); echo "\n";
echo $f->getErrorCode(), "\n";
echo $f->getErrorMessage(), "\n";
echo intl_get_error_code(), "\n";
PHP
php /tmp/nf_parse_err.php; php bin/vm.php /tmp/nf_parse_err.php'

Done when

  • Object error code 9 + Zend message text (no numfmt_parse: prefix drift)
  • Global intl_get_error_code() remains 0 after failed parse (Zend match)
  • Compliance .phpt under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

Maintainer note (2026-07-24)

Pillar 1 red (north-star5-fast 4f-m). Live probe vs Zend 8.2.32.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions