N°9319 increase php min. version to 8.2 (#887)

* Update minimum PHP version to 8.2
* Fix previous wrong resolution of merge conflict
This commit is contained in:
jf-cbd
2026-04-20 14:47:44 +02:00
committed by GitHub
parent f439490bfc
commit 805087a01b
171 changed files with 5629 additions and 1446 deletions

View File

@@ -133,6 +133,10 @@ class OutputFormatter implements WrappableOutputFormatterInterface
return '';
}
// For ASCII-only strings, byte positions equal character positions,
// so we can use native strlen/substr which is much faster than Helper::length/substr.
$isAscii = !preg_match('/[\x80-\xFF]/', $message);
$offset = 0;
$output = '';
$openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';
@@ -147,11 +151,17 @@ class OutputFormatter implements WrappableOutputFormatterInterface
continue;
}
// convert byte position to character position.
$pos = Helper::length(substr($message, 0, $pos));
// add the text up to the next tag
$output .= $this->applyCurrentStyle(Helper::substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
$offset = $pos + Helper::length($text);
if ($isAscii) {
// For ASCII, byte position = character position, no conversion needed
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
$offset = $pos + \strlen($text);
} else {
// convert byte position to character position.
$pos = Helper::length(substr($message, 0, $pos));
// add the text up to the next tag
$output .= $this->applyCurrentStyle(Helper::substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
$offset = $pos + Helper::length($text);
}
// opening tag?
if ($open = '/' !== $text[1]) {
@@ -172,7 +182,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
}
}
$output .= $this->applyCurrentStyle(Helper::substr($message, $offset), $output, $width, $currentLineLength);
$output .= $this->applyCurrentStyle($isAscii ? substr($message, $offset) : Helper::substr($message, $offset), $output, $width, $currentLineLength);
return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
}