Skip to content

Stdlib: ext/intl — normalizer_normalize() / Normalizer (ext/intl/normalizer) #5153

Description

@PurHur

Category

stdlib

Problem

Unicode normalization (normalizer_normalize(), Normalizer class) from ext/intl is missing. function_exists('normalizer_normalize') → false on this VM (Zend with intl: true). Composer, Symfony String, and IDN/email validators depend on NFC/NFD/NFKC normalization.

php-src reference

Repro

test/repro/maintainer_normalizer_normalize.php:

<?php
declare(strict_types=1);

echo function_exists('normalizer_normalize') ? "yes\n" : "no\n";

// NFC: composed é (U+00E9) vs decomposed e + combining acute
$composed = "\xC3\xA9";
$decomposed = "e\xCC\x81";

echo bin2hex(normalizer_normalize($decomposed, Normalizer::FORM_C)), "\n";
echo normalizer_normalize($composed, Normalizer::FORM_C) === $composed ? "stable\n" : "changed\n";
echo normalizer_is_normalized($composed, Normalizer::FORM_C) ? "norm\n" : "not\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_normalizer_normalize.php
php bin/vm.php test/repro/maintainer_normalizer_normalize.php 2>&1 | head -5
'
Check Zend + ext/intl VM today
function_exists yes no
NFC decomposed → composed c3a9 hex fatal undefined
normalizer_is_normalized norm N/A

Negative arm

normalizer_normalize("x", 99); // ValueError / IntlException on bad form constant

Scope (this repo)

Path Work
ext/intl/normalizer_normalize.php, normalizer_is_normalized.php VM builtins
ext/intl/Normalizer.php or BuiltinClasses.php Normalizer::FORM_* constants
ext/intl/Module.php Register (may extend existing skeleton #5153 / #3336)
v1 transport Host ICU via thin wrapper or pure PHP Unicode tables for bootstrap subset (document gap)
Tests test/compliance/cases/stdlib/normalizer_normalize.phpt

Prefer PHP implementation in ext/intl/ for self-host (#1492); avoid permanent C-only ICU glue in runtime/.

Done when

  • function_exists('normalizer_normalize') && class_exists('Normalizer') true on VM
  • Repro NFC hex + stable + norm lines match Zend
  • Bad form constant throws like Zend (negative PHPT)
  • ./script/ci-fast.sh --filter normalizer_normalize green
  • Capability matrix updated (script/capability-matrix.php)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter normalizer_normalize'

Related

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