mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 14:38:47 +02:00
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:
@@ -42,12 +42,9 @@ final class Path
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private static $buffer = [];
|
||||
private static array $buffer = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private static $bufferSize = 0;
|
||||
private static int $bufferSize = 0;
|
||||
|
||||
/**
|
||||
* Canonicalizes the given path.
|
||||
@@ -81,7 +78,7 @@ final class Path
|
||||
|
||||
// Replace "~" with user's home directory.
|
||||
if ('~' === $path[0]) {
|
||||
$path = self::getHomeDirectory().mb_substr($path, 1);
|
||||
$path = self::getHomeDirectory().substr($path, 1);
|
||||
}
|
||||
|
||||
$path = self::normalize($path);
|
||||
@@ -151,14 +148,14 @@ final class Path
|
||||
$path = self::canonicalize($path);
|
||||
|
||||
// Maintain scheme
|
||||
if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
|
||||
$scheme = mb_substr($path, 0, $schemeSeparatorPosition + 3);
|
||||
$path = mb_substr($path, $schemeSeparatorPosition + 3);
|
||||
if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
|
||||
$scheme = substr($path, 0, $schemeSeparatorPosition + 3);
|
||||
$path = substr($path, $schemeSeparatorPosition + 3);
|
||||
} else {
|
||||
$scheme = '';
|
||||
}
|
||||
|
||||
if (false === ($dirSeparatorPosition = strrpos($path, '/'))) {
|
||||
if (false === $dirSeparatorPosition = strrpos($path, '/')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -169,10 +166,10 @@ final class Path
|
||||
|
||||
// Directory equals Windows root "C:/"
|
||||
if (2 === $dirSeparatorPosition && ctype_alpha($path[0]) && ':' === $path[1]) {
|
||||
return $scheme.mb_substr($path, 0, 3);
|
||||
return $scheme.substr($path, 0, 3);
|
||||
}
|
||||
|
||||
return $scheme.mb_substr($path, 0, $dirSeparatorPosition);
|
||||
return $scheme.substr($path, 0, $dirSeparatorPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +216,7 @@ final class Path
|
||||
}
|
||||
|
||||
// Maintain scheme
|
||||
if (false !== ($schemeSeparatorPosition = strpos($path, '://'))) {
|
||||
if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
|
||||
$scheme = substr($path, 0, $schemeSeparatorPosition + 3);
|
||||
$path = substr($path, $schemeSeparatorPosition + 3);
|
||||
} else {
|
||||
@@ -233,7 +230,7 @@ final class Path
|
||||
return $scheme.'/';
|
||||
}
|
||||
|
||||
$length = mb_strlen($path);
|
||||
$length = \strlen($path);
|
||||
|
||||
// Windows root
|
||||
if ($length > 1 && ':' === $path[1] && ctype_alpha($firstCharacter)) {
|
||||
@@ -349,16 +346,16 @@ final class Path
|
||||
$extension = ltrim($extension, '.');
|
||||
|
||||
// No extension for paths
|
||||
if ('/' === mb_substr($path, -1)) {
|
||||
if ('/' === substr($path, -1)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// No actual extension in path
|
||||
if (empty($actualExtension)) {
|
||||
return $path.('.' === mb_substr($path, -1) ? '' : '.').$extension;
|
||||
return $path.('.' === substr($path, -1) ? '' : '.').$extension;
|
||||
}
|
||||
|
||||
return mb_substr($path, 0, -mb_strlen($actualExtension)).$extension;
|
||||
return substr($path, 0, -\strlen($actualExtension)).$extension;
|
||||
}
|
||||
|
||||
public static function isAbsolute(string $path): bool
|
||||
@@ -368,8 +365,8 @@ final class Path
|
||||
}
|
||||
|
||||
// Strip scheme
|
||||
if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
|
||||
$path = mb_substr($path, $schemeSeparatorPosition + 3);
|
||||
if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
|
||||
$path = substr($path, $schemeSeparatorPosition + 3);
|
||||
}
|
||||
|
||||
$firstCharacter = $path[0];
|
||||
@@ -380,9 +377,9 @@ final class Path
|
||||
}
|
||||
|
||||
// Windows root
|
||||
if (mb_strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
|
||||
if (\strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
|
||||
// Special case: "C:"
|
||||
if (2 === mb_strlen($path)) {
|
||||
if (2 === \strlen($path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -451,9 +448,9 @@ final class Path
|
||||
return self::canonicalize($path);
|
||||
}
|
||||
|
||||
if (false !== ($schemeSeparatorPosition = mb_strpos($basePath, '://'))) {
|
||||
$scheme = mb_substr($basePath, 0, $schemeSeparatorPosition + 3);
|
||||
$basePath = mb_substr($basePath, $schemeSeparatorPosition + 3);
|
||||
if (false !== $schemeSeparatorPosition = strpos($basePath, '://')) {
|
||||
$scheme = substr($basePath, 0, $schemeSeparatorPosition + 3);
|
||||
$basePath = substr($basePath, $schemeSeparatorPosition + 3);
|
||||
} else {
|
||||
$scheme = '';
|
||||
}
|
||||
@@ -574,7 +571,7 @@ final class Path
|
||||
*/
|
||||
public static function isLocal(string $path): bool
|
||||
{
|
||||
return '' !== $path && false === mb_strpos($path, '://');
|
||||
return '' !== $path && !str_contains($path, '://');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,7 +635,7 @@ final class Path
|
||||
|
||||
// Prevent false positives for common prefixes
|
||||
// see isBasePath()
|
||||
if (0 === mb_strpos($path.'/', $basePath.'/')) {
|
||||
if (str_starts_with($path.'/', $basePath.'/')) {
|
||||
// next path
|
||||
continue 2;
|
||||
}
|
||||
@@ -666,12 +663,12 @@ final class Path
|
||||
if (null === $finalPath) {
|
||||
// For first part we keep slashes, like '/top', 'C:\' or 'phar://'
|
||||
$finalPath = $path;
|
||||
$wasScheme = (false !== mb_strpos($path, '://'));
|
||||
$wasScheme = str_contains($path, '://');
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only add slash if previous part didn't end with '/' or '\'
|
||||
if (!\in_array(mb_substr($finalPath, -1), ['/', '\\'])) {
|
||||
if (!\in_array(substr($finalPath, -1), ['/', '\\'])) {
|
||||
$finalPath .= '/';
|
||||
}
|
||||
|
||||
@@ -717,11 +714,11 @@ final class Path
|
||||
// Don't append a slash for the root "/", because then that root
|
||||
// won't be discovered as common prefix ("//" is not a prefix of
|
||||
// "/foobar/").
|
||||
return 0 === mb_strpos($ofPath.'/', rtrim($basePath, '/').'/');
|
||||
return str_starts_with($ofPath.'/', rtrim($basePath, '/').'/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return non-empty-string[]
|
||||
* @return string[]
|
||||
*/
|
||||
private static function findCanonicalParts(string $root, string $pathWithoutRoot): array
|
||||
{
|
||||
@@ -776,19 +773,19 @@ final class Path
|
||||
}
|
||||
|
||||
// Remember scheme as part of the root, if any
|
||||
if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
|
||||
$root = mb_substr($path, 0, $schemeSeparatorPosition + 3);
|
||||
$path = mb_substr($path, $schemeSeparatorPosition + 3);
|
||||
if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
|
||||
$root = substr($path, 0, $schemeSeparatorPosition + 3);
|
||||
$path = substr($path, $schemeSeparatorPosition + 3);
|
||||
} else {
|
||||
$root = '';
|
||||
}
|
||||
|
||||
$length = mb_strlen($path);
|
||||
$length = \strlen($path);
|
||||
|
||||
// Remove and remember root directory
|
||||
if (0 === mb_strpos($path, '/')) {
|
||||
if (str_starts_with($path, '/')) {
|
||||
$root .= '/';
|
||||
$path = $length > 1 ? mb_substr($path, 1) : '';
|
||||
$path = $length > 1 ? substr($path, 1) : '';
|
||||
} elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
|
||||
if (2 === $length) {
|
||||
// Windows special case: "C:"
|
||||
@@ -796,8 +793,8 @@ final class Path
|
||||
$path = '';
|
||||
} elseif ('/' === $path[2]) {
|
||||
// Windows normal case: "C:/"..
|
||||
$root .= mb_substr($path, 0, 3);
|
||||
$path = $length > 3 ? mb_substr($path, 3) : '';
|
||||
$root .= substr($path, 0, 3);
|
||||
$path = $length > 3 ? substr($path, 3) : '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,11 +803,11 @@ final class Path
|
||||
|
||||
private static function toLower(string $string): string
|
||||
{
|
||||
if (false !== $encoding = mb_detect_encoding($string)) {
|
||||
if (false !== $encoding = mb_detect_encoding($string, null, true)) {
|
||||
return mb_strtolower($string, $encoding);
|
||||
}
|
||||
|
||||
return strtolower($string, $encoding);
|
||||
return strtolower($string);
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
|
||||
Reference in New Issue
Block a user