mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +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:
@@ -21,10 +21,7 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class IniFileLoader extends FileLoader
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($resource, string $type = null)
|
||||
public function load(mixed $resource, string $type = null): mixed
|
||||
{
|
||||
$path = $this->locator->locate($resource);
|
||||
|
||||
@@ -41,7 +38,11 @@ class IniFileLoader extends FileLoader
|
||||
|
||||
if (isset($result['parameters']) && \is_array($result['parameters'])) {
|
||||
foreach ($result['parameters'] as $key => $value) {
|
||||
$this->container->setParameter($key, $this->phpize($value));
|
||||
if (\is_array($value)) {
|
||||
$this->container->setParameter($key, array_map($this->phpize(...), $value));
|
||||
} else {
|
||||
$this->container->setParameter($key, $this->phpize($value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,10 +55,7 @@ class IniFileLoader extends FileLoader
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($resource, string $type = null)
|
||||
public function supports(mixed $resource, string $type = null): bool
|
||||
{
|
||||
if (!\is_string($resource)) {
|
||||
return false;
|
||||
@@ -74,10 +72,8 @@ class IniFileLoader extends FileLoader
|
||||
* Note that the following features are not supported:
|
||||
* * strings with escaped quotes are not supported "foo\"bar";
|
||||
* * string concatenation ("foo" "bar").
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function phpize(string $value)
|
||||
private function phpize(string $value): mixed
|
||||
{
|
||||
// trim on the right as comments removal keep whitespaces
|
||||
if ($value !== $v = rtrim($value)) {
|
||||
@@ -85,21 +81,18 @@ class IniFileLoader extends FileLoader
|
||||
}
|
||||
$lowercaseValue = strtolower($value);
|
||||
|
||||
switch (true) {
|
||||
case \defined($value):
|
||||
return \constant($value);
|
||||
case 'yes' === $lowercaseValue || 'on' === $lowercaseValue:
|
||||
return true;
|
||||
case 'no' === $lowercaseValue || 'off' === $lowercaseValue || 'none' === $lowercaseValue:
|
||||
return false;
|
||||
case isset($value[1]) && (
|
||||
("'" === $value[0] && "'" === $value[\strlen($value) - 1]) ||
|
||||
('"' === $value[0] && '"' === $value[\strlen($value) - 1])
|
||||
):
|
||||
// quoted string
|
||||
return substr($value, 1, -1);
|
||||
default:
|
||||
return XmlUtils::phpize($value);
|
||||
}
|
||||
return match (true) {
|
||||
\defined($value) => \constant($value),
|
||||
'yes' === $lowercaseValue,
|
||||
'on' === $lowercaseValue => true,
|
||||
'no' === $lowercaseValue,
|
||||
'off' === $lowercaseValue,
|
||||
'none' === $lowercaseValue => false,
|
||||
isset($value[1]) && (
|
||||
("'" === $value[0] && "'" === $value[\strlen($value) - 1])
|
||||
|| ('"' === $value[0] && '"' === $value[\strlen($value) - 1])
|
||||
) => substr($value, 1, -1), // quoted string
|
||||
default => XmlUtils::phpize($value),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user