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

@@ -21,45 +21,31 @@ use Symfony\Component\String\UnicodeString;
*/
abstract class Helper implements HelperInterface
{
protected $helperSet = null;
protected $helperSet;
/**
* {@inheritdoc}
* @return void
*/
public function setHelperSet(HelperSet $helperSet = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
$this->helperSet = $helperSet;
}
/**
* {@inheritdoc}
*/
public function getHelperSet()
public function getHelperSet(): ?HelperSet
{
return $this->helperSet;
}
/**
* Returns the length of a string, using mb_strwidth if it is available.
*
* @deprecated since Symfony 5.3
*
* @return int
*/
public static function strlen(?string $string)
{
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
return self::width($string);
}
/**
* Returns the width of a string, using mb_strwidth if it is available.
* The width is how many characters positions the string will use.
*/
public static function width(?string $string): int
{
$string ?? $string = '';
$string ??= '';
if (preg_match('//u', $string)) {
return (new UnicodeString($string))->width(false);
@@ -78,7 +64,7 @@ abstract class Helper implements HelperInterface
*/
public static function length(?string $string): int
{
$string ?? $string = '';
$string ??= '';
if (preg_match('//u', $string)) {
return (new UnicodeString($string))->length();
@@ -93,12 +79,10 @@ abstract class Helper implements HelperInterface
/**
* Returns the subset of a string, using mb_substr if it is available.
*
* @return string
*/
public static function substr(?string $string, int $from, int $length = null)
public static function substr(?string $string, int $from, int $length = null): string
{
$string ?? $string = '';
$string ??= '';
if (false === $encoding = mb_detect_encoding($string, null, true)) {
return substr($string, $from, $length);
@@ -107,35 +91,52 @@ abstract class Helper implements HelperInterface
return mb_substr($string, $from, $length, $encoding);
}
public static function formatTime($secs)
/**
* @return string
*/
public static function formatTime(int|float $secs, int $precision = 1)
{
$secs = (int) floor($secs);
if (0 === $secs) {
return '< 1 sec';
}
static $timeFormats = [
[0, '< 1 sec'],
[1, '1 sec'],
[2, 'secs', 1],
[60, '1 min'],
[120, 'mins', 60],
[3600, '1 hr'],
[7200, 'hrs', 3600],
[86400, '1 day'],
[172800, 'days', 86400],
[1, '1 sec', 'secs'],
[60, '1 min', 'mins'],
[3600, '1 hr', 'hrs'],
[86400, '1 day', 'days'],
];
$times = [];
foreach ($timeFormats as $index => $format) {
if ($secs >= $format[0]) {
if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
|| $index == \count($timeFormats) - 1
) {
if (2 == \count($format)) {
return $format[1];
}
$seconds = isset($timeFormats[$index + 1]) ? $secs % $timeFormats[$index + 1][0] : $secs;
return floor($secs / $format[2]).' '.$format[1];
}
if (isset($times[$index - $precision])) {
unset($times[$index - $precision]);
}
if (0 === $seconds) {
continue;
}
$unitCount = ($seconds / $format[0]);
$times[$index] = 1 === $unitCount ? $format[1] : $unitCount.' '.$format[2];
if ($secs === $seconds) {
break;
}
$secs -= $seconds;
}
return implode(', ', array_reverse($times));
}
/**
* @return string
*/
public static function formatMemory(int $memory)
{
if ($memory >= 1024 * 1024 * 1024) {
@@ -154,15 +155,8 @@ abstract class Helper implements HelperInterface
}
/**
* @deprecated since Symfony 5.3
* @return string
*/
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
{
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
return self::width(self::removeDecoration($formatter, $string));
}
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
{
$isDecorated = $formatter->isDecorated();