Skip to content

Stdlib: Locale::canonicalize()/parseLocale()/composeLocale()/getKeywords() missing after #6696/#20036 (ext/intl/locale) #20738

Description

@PurHur

Category

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

Problem

Locale is advertised after #6696 / #9576 / #20036 (getDefault, getDisplayName, lookup, filterMatches, acceptFromHttp, …), but the BCP-47 canonicalize/parse/compose/keywords surface from php-src is still missing. Call sites that do Locale::canonicalize() hit undefined-method fatals despite class_exists('Locale').

Repro Zend (intl) VM PROFILE=8.4 (2026-07-18)
method_exists(Locale::class, 'getDefault') true true
method_exists(..., 'lookup') / filterMatches / acceptFromHttp true true
method_exists(..., 'canonicalize') true false
method_exists(..., 'parseLocale') true false
method_exists(..., 'composeLocale') true false
method_exists(..., 'getKeywords') true false
Locale::canonicalize('en-US') en_US (ICU form) Error: Call to undefined static method

Also still missing (same stub; may ship in follow-ups): getAllVariants, getDisplayLanguage/Region/Script/Variant, getDisplayKeyword*, isRightToLeft, addLikelySubtags, minimizeSubtags.

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 php bin/vm.php -r "
\$m=[\"canonicalize\",\"parseLocale\",\"composeLocale\",\"getKeywords\"];
foreach (\$m as \$n) echo \$n,\"=\",(method_exists(Locale::class,\$n)?\"1\":\"0\"),PHP_EOL;
try { var_export(Locale::canonicalize(\"en-US\")); echo PHP_EOL; }
catch (Throwable \$e) { echo get_class(\$e),\": \",\$e->getMessage(),PHP_EOL; }
"'

Done when

  • canonicalize / parseLocale / composeLocale / getKeywords exist and match Zend/intl on a small BCP-47 fixture set (including @currency= keywords)
  • Compliance .phpt under test/compliance/cases/intl/
  • php-src-strict; no php-compiler-strict shortcut

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