N°8834 - Add compatibility with PHP 8.4 (#819)

* N°8834 - Add compatibility with PHP 8.4

* Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -26,6 +26,7 @@ namespace Symfony\Polyfill\Intl\Grapheme;
* - grapheme_strrpos - Find position (in grapheme units) of last occurrence of a string
* - grapheme_strstr - Returns part of haystack string from the first occurrence of needle to the end of haystack
* - grapheme_substr - Return part of a string
* - grapheme_str_split - Splits a string into an array of individual or chunks of graphemes
*
* @author Nicolas Grekas <p@tchwork.com>
*
@@ -191,6 +192,37 @@ final class Grapheme
return mb_strstr($s, $needle, $beforeNeedle, 'UTF-8');
}
public static function grapheme_str_split($s, $len = 1)
{
if (0 > $len || 1073741823 < $len) {
if (80000 > \PHP_VERSION_ID) {
return false;
}
throw new \ValueError('grapheme_str_split(): Argument #2 ($length) must be greater than 0 and less than or equal to 1073741823.');
}
if ('' === $s) {
return [];
}
if (!preg_match_all('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', $s, $matches)) {
return false;
}
if (1 === $len) {
return $matches[0];
}
$chunks = array_chunk($matches[0], $len);
foreach ($chunks as &$chunk) {
$chunk = implode('', $chunk);
}
return $chunks;
}
private static function grapheme_position($s, $needle, $offset, $mode)
{
$needle = (string) $needle;