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

@@ -48,7 +48,7 @@ class ByteString extends AbstractString
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
}
$alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
$alphabet ??= self::ALPHABET_ALPHANUMERIC;
$alphabetSize = \strlen($alphabet);
$bits = (int) ceil(log($alphabetSize, 2.0));
if ($bits <= 0 || $bits > 56) {
@@ -92,7 +92,7 @@ class ByteString extends AbstractString
return '' === $str ? [] : [\ord($str)];
}
public function append(string ...$suffix): parent
public function append(string ...$suffix): static
{
$str = clone $this;
$str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
@@ -100,10 +100,13 @@ class ByteString extends AbstractString
return $str;
}
public function camel(): parent
public function camel(): static
{
$str = clone $this;
$str->string = lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
$parts = explode(' ', trim(ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
$parts[0] = 1 !== \strlen($parts[0]) && ctype_upper($parts[0]) ? $parts[0] : lcfirst($parts[0]);
$str->string = implode('', $parts);
return $str;
}
@@ -129,27 +132,23 @@ class ByteString extends AbstractString
return $chunks;
}
public function endsWith($suffix): bool
public function endsWith(string|iterable|AbstractString $suffix): bool
{
if ($suffix instanceof parent) {
if ($suffix instanceof AbstractString) {
$suffix = $suffix->string;
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
} elseif (!\is_string($suffix)) {
return parent::endsWith($suffix);
} else {
$suffix = (string) $suffix;
}
return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
}
public function equalsTo($string): bool
public function equalsTo(string|iterable|AbstractString $string): bool
{
if ($string instanceof parent) {
if ($string instanceof AbstractString) {
$string = $string->string;
} elseif (\is_array($string) || $string instanceof \Traversable) {
} elseif (!\is_string($string)) {
return parent::equalsTo($string);
} else {
$string = (string) $string;
}
if ('' !== $string && $this->ignoreCase) {
@@ -159,7 +158,7 @@ class ByteString extends AbstractString
return $string === $this->string;
}
public function folded(): parent
public function folded(): static
{
$str = clone $this;
$str->string = strtolower($str->string);
@@ -167,14 +166,12 @@ class ByteString extends AbstractString
return $str;
}
public function indexOf($needle, int $offset = 0): ?int
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
{
if ($needle instanceof parent) {
if ($needle instanceof AbstractString) {
$needle = $needle->string;
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
} elseif (!\is_string($needle)) {
return parent::indexOf($needle, $offset);
} else {
$needle = (string) $needle;
}
if ('' === $needle) {
@@ -186,14 +183,12 @@ class ByteString extends AbstractString
return false === $i ? null : $i;
}
public function indexOfLast($needle, int $offset = 0): ?int
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
{
if ($needle instanceof parent) {
if ($needle instanceof AbstractString) {
$needle = $needle->string;
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
} elseif (!\is_string($needle)) {
return parent::indexOfLast($needle, $offset);
} else {
$needle = (string) $needle;
}
if ('' === $needle) {
@@ -210,7 +205,7 @@ class ByteString extends AbstractString
return '' === $this->string || preg_match('//u', $this->string);
}
public function join(array $strings, string $lastGlue = null): parent
public function join(array $strings, string $lastGlue = null): static
{
$str = clone $this;
@@ -225,7 +220,7 @@ class ByteString extends AbstractString
return \strlen($this->string);
}
public function lower(): parent
public function lower(): static
{
$str = clone $this;
$str->string = strtolower($str->string);
@@ -241,19 +236,11 @@ class ByteString extends AbstractString
$regexp .= 'i';
}
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
try {
if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
$lastError = preg_last_error();
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
throw new RuntimeException('Matching failed with '.$k.'.');
}
}
throw new RuntimeException('Matching failed with unknown error code.');
throw new RuntimeException('Matching failed with error: '.preg_last_error_msg());
}
} finally {
restore_error_handler();
@@ -262,7 +249,7 @@ class ByteString extends AbstractString
return $matches;
}
public function padBoth(int $length, string $padStr = ' '): parent
public function padBoth(int $length, string $padStr = ' '): static
{
$str = clone $this;
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
@@ -270,7 +257,7 @@ class ByteString extends AbstractString
return $str;
}
public function padEnd(int $length, string $padStr = ' '): parent
public function padEnd(int $length, string $padStr = ' '): static
{
$str = clone $this;
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
@@ -278,7 +265,7 @@ class ByteString extends AbstractString
return $str;
}
public function padStart(int $length, string $padStr = ' '): parent
public function padStart(int $length, string $padStr = ' '): static
{
$str = clone $this;
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
@@ -286,7 +273,7 @@ class ByteString extends AbstractString
return $str;
}
public function prepend(string ...$prefix): parent
public function prepend(string ...$prefix): static
{
$str = clone $this;
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
@@ -294,7 +281,7 @@ class ByteString extends AbstractString
return $str;
}
public function replace(string $from, string $to): parent
public function replace(string $from, string $to): static
{
$str = clone $this;
@@ -305,30 +292,22 @@ class ByteString extends AbstractString
return $str;
}
public function replaceMatches(string $fromRegexp, $to): parent
public function replaceMatches(string $fromRegexp, string|callable $to): static
{
if ($this->ignoreCase) {
$fromRegexp .= 'i';
}
if (\is_array($to)) {
if (!\is_callable($to)) {
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
}
$replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
$replace = 'preg_replace_callback';
} else {
$replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
}
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
try {
if (null === $string = $replace($fromRegexp, $to, $this->string)) {
$lastError = preg_last_error();
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
throw new RuntimeException('Matching failed with '.$k.'.');
}
}
@@ -345,7 +324,7 @@ class ByteString extends AbstractString
return $str;
}
public function reverse(): parent
public function reverse(): static
{
$str = clone $this;
$str->string = strrev($str->string);
@@ -353,7 +332,7 @@ class ByteString extends AbstractString
return $str;
}
public function slice(int $start = 0, int $length = null): parent
public function slice(int $start = 0, int $length = null): static
{
$str = clone $this;
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
@@ -361,15 +340,15 @@ class ByteString extends AbstractString
return $str;
}
public function snake(): parent
public function snake(): static
{
$str = $this->camel()->title();
$str = $this->camel();
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
return $str;
}
public function splice(string $replacement, int $start = 0, int $length = null): parent
public function splice(string $replacement, int $start = 0, int $length = null): static
{
$str = clone $this;
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
@@ -379,7 +358,7 @@ class ByteString extends AbstractString
public function split(string $delimiter, int $limit = null, int $flags = null): array
{
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
if (1 > $limit ??= \PHP_INT_MAX) {
throw new InvalidArgumentException('Split limit must be a positive integer.');
}
@@ -404,9 +383,9 @@ class ByteString extends AbstractString
return $chunks;
}
public function startsWith($prefix): bool
public function startsWith(string|iterable|AbstractString $prefix): bool
{
if ($prefix instanceof parent) {
if ($prefix instanceof AbstractString) {
$prefix = $prefix->string;
} elseif (!\is_string($prefix)) {
return parent::startsWith($prefix);
@@ -415,7 +394,7 @@ class ByteString extends AbstractString
return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
}
public function title(bool $allWords = false): parent
public function title(bool $allWords = false): static
{
$str = clone $this;
$str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
@@ -438,7 +417,7 @@ class ByteString extends AbstractString
return $u;
}
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
try {
try {
@@ -465,7 +444,7 @@ class ByteString extends AbstractString
return $u;
}
public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent
public function trim(string $chars = " \t\n\r\0\x0B\x0C"): static
{
$str = clone $this;
$str->string = trim($str->string, $chars);
@@ -473,7 +452,7 @@ class ByteString extends AbstractString
return $str;
}
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): static
{
$str = clone $this;
$str->string = rtrim($str->string, $chars);
@@ -481,7 +460,7 @@ class ByteString extends AbstractString
return $str;
}
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): static
{
$str = clone $this;
$str->string = ltrim($str->string, $chars);
@@ -489,7 +468,7 @@ class ByteString extends AbstractString
return $str;
}
public function upper(): parent
public function upper(): static
{
$str = clone $this;
$str->string = strtoupper($str->string);