diff --git a/composer.json b/composer.json index 4361a61d9..25b1673a7 100644 --- a/composer.json +++ b/composer.json @@ -61,10 +61,10 @@ "symfony/event-dispatcher": "^7.4.15", "symfony/http-foundation": "^7.4.15", "symfony/mailer": "^7.4.15", - "symfony/polyfill-intl-grapheme": "^1.43.0", + "symfony/polyfill-intl-grapheme": "^1.43.3", "symfony/polyfill-intl-normalizer": "^1.43.0", "symfony/polyfill-php84": "^1.43.0", - "symfony/polyfill-php85": "^1.43.0", + "symfony/polyfill-php85": "^1.44.0", "symfony/polyfill-php86": "^1.43.0", "symfony/process": "^6.4.33", "symfony/routing": "^6.4.41", diff --git a/composer.lock b/composer.lock index 559c55087..9e6e41eb0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "021317dcece4d1823016c6a643f61942", + "content-hash": "bf1b9d6b42c11050e248aa7244949ce4", "packages": [ { "name": "aws/aws-crt-php", @@ -5266,16 +5266,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.43.0", + "version": "v1.43.3", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "5cac8f4db97208823aa353f59a01faad2da52c75" + "reference": "5a8f33c87aeecffce24e721b5064fab05f4becf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5cac8f4db97208823aa353f59a01faad2da52c75", - "reference": "5cac8f4db97208823aa353f59a01faad2da52c75", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5a8f33c87aeecffce24e721b5064fab05f4becf8", + "reference": "5a8f33c87aeecffce24e721b5064fab05f4becf8", "shasum": "" }, "require": { @@ -5324,7 +5324,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.43.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.43.3" }, "funding": [ { @@ -5344,7 +5344,7 @@ "type": "tidelift" } ], - "time": "2026-09-25T15:46:47+00:00" + "time": "2026-10-15T09:18:53+00:00" }, { "name": "symfony/polyfill-intl-idn", @@ -5600,16 +5600,16 @@ }, { "name": "symfony/polyfill-php85", - "version": "v1.43.0", + "version": "v1.44.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php85.git", - "reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6" + "reference": "94c794cb5ba51784bc259f11e9f128593297d8dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/86a42cbcc07adc331481a5ab310a4024bfc227f6", - "reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/94c794cb5ba51784bc259f11e9f128593297d8dc", + "reference": "94c794cb5ba51784bc259f11e9f128593297d8dc", "shasum": "" }, "require": { @@ -5656,7 +5656,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php85/tree/v1.43.0" + "source": "https://github.com/symfony/polyfill-php85/tree/v1.44.0" }, "funding": [ { @@ -5676,7 +5676,7 @@ "type": "tidelift" } ], - "time": "2026-09-25T15:46:47+00:00" + "time": "2026-10-30T15:20:09+00:00" }, { "name": "symfony/polyfill-php86", diff --git a/composer/installed.json b/composer/installed.json index 201081897..3590088a3 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -5491,17 +5491,17 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.43.0", - "version_normalized": "1.43.0.0", + "version": "v1.43.3", + "version_normalized": "1.43.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "5cac8f4db97208823aa353f59a01faad2da52c75" + "reference": "5a8f33c87aeecffce24e721b5064fab05f4becf8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5cac8f4db97208823aa353f59a01faad2da52c75", - "reference": "5cac8f4db97208823aa353f59a01faad2da52c75", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5a8f33c87aeecffce24e721b5064fab05f4becf8", + "reference": "5a8f33c87aeecffce24e721b5064fab05f4becf8", "shasum": "" }, "require": { @@ -5510,7 +5510,7 @@ "suggest": { "ext-intl": "For best performance" }, - "time": "2026-09-25T15:46:47+00:00", + "time": "2026-10-15T09:18:53+00:00", "type": "library", "extra": { "thanks": { @@ -5552,7 +5552,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.43.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.43.3" }, "funding": [ { @@ -5837,23 +5837,23 @@ }, { "name": "symfony/polyfill-php85", - "version": "v1.43.0", - "version_normalized": "1.43.0.0", + "version": "v1.44.0", + "version_normalized": "1.44.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php85.git", - "reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6" + "reference": "94c794cb5ba51784bc259f11e9f128593297d8dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/86a42cbcc07adc331481a5ab310a4024bfc227f6", - "reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/94c794cb5ba51784bc259f11e9f128593297d8dc", + "reference": "94c794cb5ba51784bc259f11e9f128593297d8dc", "shasum": "" }, "require": { "php": ">=7.2" }, - "time": "2026-09-25T15:46:47+00:00", + "time": "2026-10-30T15:20:09+00:00", "type": "library", "extra": { "thanks": { @@ -5896,7 +5896,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php85/tree/v1.43.0" + "source": "https://github.com/symfony/polyfill-php85/tree/v1.44.0" }, "funding": [ { diff --git a/composer/installed.php b/composer/installed.php index 83427ef24..fd58aece8 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -797,9 +797,9 @@ ), ), 'symfony/polyfill-intl-grapheme' => array( - 'pretty_version' => 'v1.43.0', - 'version' => '1.43.0.0', - 'reference' => '5cac8f4db97208823aa353f59a01faad2da52c75', + 'pretty_version' => 'v1.43.3', + 'version' => '1.43.3.0', + 'reference' => '5a8f33c87aeecffce24e721b5064fab05f4becf8', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-intl-grapheme', 'aliases' => array(), @@ -863,9 +863,9 @@ 'dev_requirement' => false, ), 'symfony/polyfill-php85' => array( - 'pretty_version' => 'v1.43.0', - 'version' => '1.43.0.0', - 'reference' => '86a42cbcc07adc331481a5ab310a4024bfc227f6', + 'pretty_version' => 'v1.44.0', + 'version' => '1.44.0.0', + 'reference' => '94c794cb5ba51784bc259f11e9f128593297d8dc', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-php85', 'aliases' => array(), diff --git a/symfony/polyfill-intl-grapheme/Grapheme.php b/symfony/polyfill-intl-grapheme/Grapheme.php index 94d080ac9..a7e18d7de 100644 --- a/symfony/polyfill-intl-grapheme/Grapheme.php +++ b/symfony/polyfill-intl-grapheme/Grapheme.php @@ -49,6 +49,9 @@ final class Grapheme ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'], ]; + // The characters that extend a grapheme cluster and that ICU 74 ignores when it compares strings + private const IGNORABLE_RX = '/^[\x{034F}\x{0488}-\x{0489}\x{0591}-\x{05AF}\x{05BD}\x{05C4}-\x{05C5}\x{0610}-\x{061A}\x{06D6}-\x{06DC}\x{06DF}-\x{06E4}\x{06E7}-\x{06E8}\x{06EA}-\x{06ED}\x{0740}\x{0743}-\x{0744}\x{0747}-\x{074A}\x{0898}-\x{089D}\x{08CA}-\x{08E1}\x{08EA}-\x{08EF}\x{08F3}\x{0951}-\x{0952}\x{0F18}-\x{0F19}\x{0F35}\x{0F37}\x{0F3E}-\x{0F3F}\x{0F86}-\x{0F87}\x{0FC6}\x{17B4}-\x{17B5}\x{17D3}\x{180B}-\x{180D}\x{180F}\x{1A7F}\x{1B6B}-\x{1B73}\x{1CD0}-\x{1CD2}\x{1CD4}-\x{1CE8}\x{1CF4}\x{1CF7}-\x{1CF9}\x{200C}-\x{200D}\x{2D7F}\x{A670}-\x{A672}\x{A8E0}-\x{A8F1}\x{FE00}-\x{FE0F}\x{FE21}\x{FE23}-\x{FE26}\x{FE28}\x{FE2A}-\x{FE2D}\x{FE2F}\x{102E0}\x{10EFD}-\x{10EFF}\x{11366}-\x{1136C}\x{11370}-\x{11374}\x{13440}\x{13447}-\x{13455}\x{16FE4}\x{1CF00}-\x{1CF2D}\x{1CF30}-\x{1CF46}\x{1D165}-\x{1D169}\x{1D16D}-\x{1D172}\x{1D17B}-\x{1D182}\x{1D185}-\x{1D18B}\x{1D1AA}-\x{1D1AD}\x{1D242}-\x{1D244}\x{1DA00}-\x{1DA36}\x{1DA3B}-\x{1DA6C}\x{1DA75}\x{1DA84}\x{1DA9B}-\x{1DA9F}\x{1DAA1}-\x{1DAAF}\x{1E8D0}-\x{1E8D6}\x{E0020}-\x{E007F}\x{E0100}-\x{E01EF}]*+\z/u'; + // indexed by the $mode argument of grapheme_position() private const POSITION_FUNCTIONS = ['grapheme_strpos', 'grapheme_stripos', 'grapheme_strrpos', 'grapheme_strripos']; @@ -377,13 +380,72 @@ private static function grapheme_position($s, $needle, $offset, $mode) $needle = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $needle); } } - if ($reverse) { - $needlePos = strrpos($s, $needle); - } else { - $needlePos = strpos($s, $needle); + $needleLen = \strlen($needle); + $needlePos = $reverse ? strrpos($s, $needle) : strpos($s, $needle); + + while (false !== $needlePos) { + if (false !== $i = self::graphemeIndex($s, $needlePos, $needlePos + $needleLen)) { + return $i + $offset; + } + + if (!$reverse) { + $needlePos = strpos($s, $needle, $needlePos + 1); + } elseif ($needlePos) { + $needlePos = strrpos(substr($s, 0, $needlePos + $needleLen - 1), $needle); + } else { + $needlePos = false; + } + } + + return false; + } + + /** + * Returns the position in grapheme units of the bytes from $start to $end, + * or false when they split a grapheme cluster on characters that are not ignorable. + */ + private static function graphemeIndex($s, $start, $end) + { + if (self::isAsciiBoundary($s, $start) && self::isAsciiBoundary($s, $end)) { + return self::grapheme_strlen(substr($s, 0, $start)); } - return false !== $needlePos ? self::grapheme_strlen(substr($s, 0, $needlePos)) + $offset : false; + $i = $pos = 0; + + if ($start) { + // count the clusters that start before $start, then find where the last one starts + $prefix = substr($s, 0, $start); + preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $prefix, -1, $i); + + if (!$i) { + return false; + } + + $pos = 1 < $i ? $start - \strlen(preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $prefix, $i - 1)) : 0; + } + + do { + if (!preg_match('/\G'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $cluster, 0, $pos)) { + return false; + } + + $next = $pos + \strlen($cluster[0]); + + if ($pos < $start && $start < $next && !preg_match(self::IGNORABLE_RX, substr($s, $start, min($next, $end) - $start))) { + return false; + } + + if ($pos < $end && $end < $next && !preg_match(self::IGNORABLE_RX, substr($s, $end, $next - $end))) { + return false; + } + } while (($pos = $next) < $end); + + return $i; + } + + private static function isAsciiBoundary($s, $i) + { + return 0 === $i || !isset($s[$i]) || ($s[$i - 1] < "\x80" && $s[$i] < "\x80" && ("\r" !== $s[$i - 1] || "\n" !== $s[$i])); } public static function grapheme_strrev(string $string) diff --git a/symfony/polyfill-php85/Php85.php b/symfony/polyfill-php85/Php85.php index d1f038a10..24ce1b372 100644 --- a/symfony/polyfill-php85/Php85.php +++ b/symfony/polyfill-php85/Php85.php @@ -46,7 +46,11 @@ public static function array_first(array $array) public static function array_last(array $array) { - return $array ? current(\array_slice($array, -1)) : null; + if (!$array) { + return null; + } + + return \PHP_VERSION_ID >= 70300 ? $array[array_key_last($array)] : current(\array_slice($array, -1)); } // Taken from CLDR 44 (ICU 74); the exact set is ICU-version dependent and won't match every version of the native locale_is_right_to_left().