Skip to content

Stdlib: ResourceBundle::getLocales()/getErrorCode()/getErrorMessage() missing after #6187 (ext/intl/resourcebundle) #20739

Description

@PurHur

Category

stdlib · php-src-strict · ext/intl ResourceBundle · pillar 4

Problem

ResourceBundle::create() / get() / count() landed in #6187, but php-src’s locale enumeration and last-error accessors are still absent. Apps that list bundle locales or check getErrorCode() after a failed get() fatal instead.

Repro Zend (intl) VM PROFILE=8.4 (2026-07-18)
method_exists(ResourceBundle::class, 'create') true true
method_exists(..., 'getLocales') true false
$b->get / count works works
$b->getErrorCode() / getErrorMessage() works undefined method
$b->getIterator() works undefined method

php-src reference

PHP implementation target

  • Extend ext/intl/VmResourceBundle.php — PHP-in-PHP; reuse existing ICU ures_* FFI for locales/errors where needed, keep create/get/count paths shared
  • Register static getLocales + instance error/iterator methods next to ResourceBundleCreate / Get / Count

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 php bin/vm.php -r "
echo \"getLocales=\",(method_exists(ResourceBundle::class,\"getLocales\")?\"1\":\"0\"),PHP_EOL;
\$b=ResourceBundle::create(\"en\",\"ICUDATA\");
foreach ([\"getErrorCode\",\"getErrorMessage\",\"getIterator\"] as \$n) echo \$n,\"=\",(method_exists(\$b,\$n)?\"1\":\"0\"),PHP_EOL;
try { var_export(ResourceBundle::getLocales(\"ICUDATA\")); echo PHP_EOL; }
catch (Throwable \$e) { echo get_class(\$e),\": \",\$e->getMessage(),PHP_EOL; }
"'

Done when

  • getLocales returns a non-empty list (or Zend-equivalent false) for ICUDATA
  • After a failed lookup, getErrorCode/getErrorMessage match Zend/intl error semantics
  • Compliance .phpt under test/compliance/cases/intl/
  • php-src-strict; no php-compiler-strict shortcut

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 appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions