Merge remote-tracking branch 'origin/support/3.2' into develop

This commit is contained in:
lenaick.moreira
2026-03-02 10:56:31 +01:00
123 changed files with 2898 additions and 2149 deletions

View File

@@ -530,6 +530,8 @@ abstract class AbstractUnicodeString extends AbstractString
private function wcswidth(string $string): int
{
$width = 0;
$lastChar = null;
$lastWidth = null;
foreach (preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
$codePoint = mb_ord($c, 'UTF-8');
@@ -552,6 +554,20 @@ abstract class AbstractUnicodeString extends AbstractString
return -1;
}
if (0xFE0F === $codePoint) {
if (\PCRE_VERSION_MAJOR < 10 || \PCRE_VERSION_MAJOR === 10 && \PCRE_VERSION_MINOR < 40) {
$regex = '/\p{So}/u';
} else {
$regex = '/\p{Emoji}/u';
}
if (null !== $lastChar && 1 === $lastWidth && preg_match($regex, $lastChar)) {
++$width;
$lastWidth = 2;
}
continue;
}
self::$tableZero ??= require __DIR__.'/Resources/data/wcswidth_table_zero.php';
if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) {
@@ -582,6 +598,8 @@ abstract class AbstractUnicodeString extends AbstractString
$ubound = $mid - 1;
} else {
$width += 2;
$lastChar = $c;
$lastWidth = 2;
continue 2;
}
@@ -589,6 +607,8 @@ abstract class AbstractUnicodeString extends AbstractString
}
++$width;
$lastChar = $c;
$lastWidth = 1;
}
return $width;