N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)

* Update Symfony lib to version ~6.4.0
* Update code missing return type
* Add an iTop general configuration entry to store application secret (Symfony mandatory parameter)
* Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
bdalsass
2023-12-05 13:56:56 +01:00
committed by GitHub
parent 863ab4560c
commit 27ce51ab07
1392 changed files with 44869 additions and 27799 deletions

View File

@@ -13,6 +13,8 @@ namespace Symfony\Component\Console\Formatter;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use function Symfony\Component\String\b;
/**
* Formatter class for console output.
*
@@ -21,9 +23,9 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
*/
class OutputFormatter implements WrappableOutputFormatterInterface
{
private $decorated;
private $styles = [];
private $styleStack;
private bool $decorated;
private array $styles = [];
private OutputFormatterStyleStack $styleStack;
public function __clone()
{
@@ -35,10 +37,8 @@ class OutputFormatter implements WrappableOutputFormatterInterface
/**
* Escapes "<" and ">" special chars in given text.
*
* @return string
*/
public static function escape(string $text)
public static function escape(string $text): string
{
$text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
@@ -84,41 +84,32 @@ class OutputFormatter implements WrappableOutputFormatterInterface
}
/**
* {@inheritdoc}
* @return void
*/
public function setDecorated(bool $decorated)
{
$this->decorated = $decorated;
}
/**
* {@inheritdoc}
*/
public function isDecorated()
public function isDecorated(): bool
{
return $this->decorated;
}
/**
* {@inheritdoc}
* @return void
*/
public function setStyle(string $name, OutputFormatterStyleInterface $style)
{
$this->styles[strtolower($name)] = $style;
}
/**
* {@inheritdoc}
*/
public function hasStyle(string $name)
public function hasStyle(string $name): bool
{
return isset($this->styles[strtolower($name)]);
}
/**
* {@inheritdoc}
*/
public function getStyle(string $name)
public function getStyle(string $name): OutputFormatterStyleInterface
{
if (!$this->hasStyle($name)) {
throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
@@ -127,16 +118,13 @@ class OutputFormatter implements WrappableOutputFormatterInterface
return $this->styles[strtolower($name)];
}
/**
* {@inheritdoc}
*/
public function format(?string $message)
public function format(?string $message): ?string
{
return $this->formatAndWrap($message, 0);
}
/**
* {@inheritdoc}
* @return string
*/
public function formatAndWrap(?string $message, int $width)
{
@@ -163,7 +151,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
$offset = $pos + \strlen($text);
// opening tag?
if ($open = '/' != $text[1]) {
if ($open = '/' !== $text[1]) {
$tag = $matches[1][$i][0];
} else {
$tag = $matches[3][$i][0] ?? '';
@@ -186,10 +174,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
}
/**
* @return OutputFormatterStyleStack
*/
public function getStyleStack()
public function getStyleStack(): OutputFormatterStyleStack
{
return $this->styleStack;
}
@@ -258,10 +243,10 @@ class OutputFormatter implements WrappableOutputFormatterInterface
}
preg_match('~(\\n)$~', $text, $matches);
$text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text);
$text = $prefix.$this->addLineBreaks($text, $width);
$text = rtrim($text, "\n").($matches[1] ?? '');
if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) {
if (!$currentLineLength && '' !== $current && !str_ends_with($current, "\n")) {
$text = "\n".$text;
}
@@ -282,4 +267,11 @@ class OutputFormatter implements WrappableOutputFormatterInterface
return implode("\n", $lines);
}
private function addLineBreaks(string $text, int $width): string
{
$encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8';
return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding);
}
}