From 359cff8bcc2320b6dd66d82cc30bf233ea3eac32 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Wed, 26 Aug 2026 15:17:49 +0200 Subject: [PATCH] ext/intl: document PHP 8.5 changes - Add Locale::addLikelySubtags() and Locale::minimizeSubtags() methods - Add grapheme_levenshtein() function - Locale methods now throw ValueError when locale arguments contain null bytes --- .../intl/grapheme/grapheme-levenshtein.xml | 117 ++++++++++++++++++ reference/intl/locale.xml | 8 ++ reference/intl/locale/add-likely-subtags.xml | 88 +++++++++++++ reference/intl/locale/minimize-subtags.xml | 89 +++++++++++++ 4 files changed, 302 insertions(+) create mode 100644 reference/intl/grapheme/grapheme-levenshtein.xml create mode 100644 reference/intl/locale/add-likely-subtags.xml create mode 100644 reference/intl/locale/minimize-subtags.xml diff --git a/reference/intl/grapheme/grapheme-levenshtein.xml b/reference/intl/grapheme/grapheme-levenshtein.xml new file mode 100644 index 000000000000..85adc133b010 --- /dev/null +++ b/reference/intl/grapheme/grapheme-levenshtein.xml @@ -0,0 +1,117 @@ + + + + + grapheme_levenshtein + Calculate the Levenshtein distance between two strings in grapheme units + + + &reftitle.description; + &style.procedural; + + intfalsegrapheme_levenshtein + stringstring1 + stringstring2 + intcost_ins1 + intcost_rep1 + intcost_del1 + stringlocale"" + + + Calculates the Levenshtein distance between two strings, where the distance + is measured in grapheme units rather than bytes or characters. + + + + + &reftitle.parameters; + + + string1 + + + One of the strings being evaluated for Levenshtein distance. + Must be valid UTF-8. + + + + + string2 + + + One of the strings being evaluated for Levenshtein distance. + Must be valid UTF-8. + + + + + cost_ins + + + Defines the cost of insertion. + + + + + cost_rep + + + Defines the cost of replacement. + + + + + cost_del + + + Defines the cost of deletion. + + + + + locale + + &intl.param.grapheme.locale; + + + + + + + &reftitle.returnvalues; + + This function returns the Levenshtein-Distance between the two argument + strings (in grapheme units), or &false; if one of the argument strings is + longer than the limit of 255 grapheme units. + + + + + &reftitle.seealso; + + levenshtein + grapheme_strlen + + + + + diff --git a/reference/intl/locale.xml b/reference/intl/locale.xml index 3ecb571c876a..570c4d72c1c4 100644 --- a/reference/intl/locale.xml +++ b/reference/intl/locale.xml @@ -177,6 +177,14 @@ + + 8.5.0 + + Locale methods now throw a + ValueError when a locale argument + contains null bytes. + + 8.4.0 diff --git a/reference/intl/locale/add-likely-subtags.xml b/reference/intl/locale/add-likely-subtags.xml new file mode 100644 index 000000000000..355a0ce770f3 --- /dev/null +++ b/reference/intl/locale/add-likely-subtags.xml @@ -0,0 +1,88 @@ + + + + + Locale::addLikelySubtags + locale_add_likely_subtags + Add likely subtags to a locale + + + + &reftitle.description; + + &style.oop; + + + public static stringfalseLocale::addLikelySubtags + stringlocale + + + &style.procedural; + + + stringfalselocale_add_likely_subtags + stringlocale + + + Expands a locale tag by adding likely subtags based on the ICU locale data. + For example, en becomes en_Latn_US. + + + + + &reftitle.parameters; + + + locale + + + The locale to expand. + + + + + + + + &reftitle.returnvalues; + + Returns the locale with likely subtags added, or &false; on failure. + + + + + &reftitle.errors; + + Throws a ValueError when the locale + argument contains null bytes. + + + + + &reftitle.seealso; + + Locale::minimizeSubtags + + + + + diff --git a/reference/intl/locale/minimize-subtags.xml b/reference/intl/locale/minimize-subtags.xml new file mode 100644 index 000000000000..acf57673ac9d --- /dev/null +++ b/reference/intl/locale/minimize-subtags.xml @@ -0,0 +1,89 @@ + + + + + Locale::minimizeSubtags + locale_minimize_subtags + Remove likely subtags from a locale + + + + &reftitle.description; + + &style.oop; + + + public static stringfalseLocale::minimizeSubtags + stringlocale + + + &style.procedural; + + + stringfalselocale_minimize_subtags + stringlocale + + + Minimizes a locale tag by removing subtags that can be inferred using the + ICU likely subtag data. For example, en_Latn_US becomes + en. + + + + + &reftitle.parameters; + + + locale + + + The locale to minimize. + + + + + + + + &reftitle.returnvalues; + + Returns the locale with likely subtags removed, or &false; on failure. + + + + + &reftitle.errors; + + Throws a ValueError when the locale + argument contains null bytes. + + + + + &reftitle.seealso; + + Locale::addLikelySubtags + + + + +