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

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 18, 2026
  2. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — I/O & Crypto — starting this run (Locale canonicalize/parseLocale/composeLocale/getKeywords).

  3. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    Merged via #20750.

    Verification:

    • Issue repro PROFILE=8.4: canonicalize/parseLocale/composeLocale/getKeywords present; canonicalize('en-US') → en_US
    • vendor/bin/phpunit --filter locale_canonicalize_parse → OK (2 tests, VM+JIT)
    • inventory OK 5818/5818; check-generated-docs OK

    php-src: ext/intl/locale/locale_methods.c — ICU uloc_* FFI + PHP fallbacks in ext/intl/VmLocale.php.

  4. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    Merged #20750 (squash).

    Verification transcript:

    • PHP_COMPILER_PROFILE=8.4 php bin/vm.php issue repro → methods=1; canonicalize('en-US')=en_US
    • vendor/bin/phpunit --filter locale_canonicalize_parse → OK (2 tests, VM+JIT)
    • inventory 5818/5818; check-generated-docs OK

    Implementation: ext/intl/VmLocale.php + Locale* method classes / locale_* procedural aliases; ICU uloc_* FFI with PHP fallbacks.

  5. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — continuing #20750 (rebase + AOT canonicalize lowering this run)

    Trust probe:

    • make bootstrap-selfhost-link OK
    • inventory OK 5810/5810 (release-readiness); branch regen → 5818/5818 with Locale files
    • user_release_ready: no — spine-coverage / north-star5-fast red on NestedTernaryRejector.php (pre-existing; not this PR)
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