mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 14:58:43 +02:00
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:
@@ -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" => '\\', '\\<' => '<', '\\>' => '>']);
|
||||
}
|
||||
|
||||
@@ -142,12 +142,27 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
*/
|
||||
private function openOutputStream()
|
||||
{
|
||||
static $stdout;
|
||||
|
||||
if ($stdout) {
|
||||
return $stdout;
|
||||
}
|
||||
|
||||
if (!$this->hasStdoutSupport()) {
|
||||
return fopen('php://output', 'w');
|
||||
return $stdout = fopen('php://output', 'w');
|
||||
}
|
||||
|
||||
// Use STDOUT when possible to prevent from opening too many file descriptors
|
||||
return \defined('STDOUT') ? \STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w'));
|
||||
if (!\defined('STDOUT')) {
|
||||
return $stdout = @fopen('php://stdout', 'w') ?: fopen('php://output', 'w');
|
||||
}
|
||||
|
||||
// On Windows, STDOUT is opened in text mode; reopen in binary mode to prevent \n to \r\n conversion
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
return $stdout = @fopen('php://stdout', 'w') ?: \STDOUT;
|
||||
}
|
||||
|
||||
return $stdout = \STDOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,11 +170,26 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
*/
|
||||
private function openErrorStream()
|
||||
{
|
||||
static $stderr;
|
||||
|
||||
if ($stderr) {
|
||||
return $stderr;
|
||||
}
|
||||
|
||||
if (!$this->hasStderrSupport()) {
|
||||
return fopen('php://output', 'w');
|
||||
return $stderr = fopen('php://output', 'w');
|
||||
}
|
||||
|
||||
// Use STDERR when possible to prevent from opening too many file descriptors
|
||||
return \defined('STDERR') ? \STDERR : (@fopen('php://stderr', 'w') ?: fopen('php://output', 'w'));
|
||||
if (!\defined('STDERR')) {
|
||||
return $stderr = @fopen('php://stderr', 'w') ?: fopen('php://output', 'w');
|
||||
}
|
||||
|
||||
// On Windows, STDERR is opened in text mode; reopen in binary mode to prevent \n → \r\n conversion
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
return $stderr = @fopen('php://stderr', 'w') ?: \STDERR;
|
||||
}
|
||||
|
||||
return $stderr ??= \STDERR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class ApplicationTester
|
||||
*/
|
||||
public function run(array $input, array $options = []): int
|
||||
{
|
||||
$prevShellVerbosity = getenv('SHELL_VERBOSITY');
|
||||
$prevShellVerbosity = [getenv('SHELL_VERBOSITY'), $_ENV['SHELL_VERBOSITY'] ?? false, $_SERVER['SHELL_VERBOSITY'] ?? false];
|
||||
|
||||
try {
|
||||
$this->input = new ArrayInput($input);
|
||||
@@ -63,22 +63,35 @@ class ApplicationTester
|
||||
|
||||
$this->initOutput($options);
|
||||
|
||||
// Temporarily clear SHELL_VERBOSITY to prevent Application::configureIO
|
||||
// from overriding the interactive and verbosity settings set above
|
||||
if (\function_exists('putenv')) {
|
||||
@putenv('SHELL_VERBOSITY');
|
||||
}
|
||||
unset($_ENV['SHELL_VERBOSITY'], $_SERVER['SHELL_VERBOSITY']);
|
||||
|
||||
return $this->statusCode = $this->application->run($this->input, $this->output);
|
||||
} finally {
|
||||
// SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it
|
||||
// to its previous value to avoid one test's verbosity to spread to the following tests
|
||||
if (false === $prevShellVerbosity) {
|
||||
if (false === $prevShellVerbosity[0]) {
|
||||
if (\function_exists('putenv')) {
|
||||
@putenv('SHELL_VERBOSITY');
|
||||
}
|
||||
unset($_ENV['SHELL_VERBOSITY']);
|
||||
unset($_SERVER['SHELL_VERBOSITY']);
|
||||
} else {
|
||||
if (\function_exists('putenv')) {
|
||||
@putenv('SHELL_VERBOSITY='.$prevShellVerbosity);
|
||||
@putenv('SHELL_VERBOSITY='.$prevShellVerbosity[0]);
|
||||
}
|
||||
$_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity;
|
||||
$_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity;
|
||||
}
|
||||
if (false === $prevShellVerbosity[1]) {
|
||||
unset($_ENV['SHELL_VERBOSITY']);
|
||||
} else {
|
||||
$_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity[1];
|
||||
}
|
||||
if (false === $prevShellVerbosity[2]) {
|
||||
unset($_SERVER['SHELL_VERBOSITY']);
|
||||
} else {
|
||||
$_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user