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

@@ -20,33 +20,72 @@ use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
*/
class EnumNode extends ScalarNode
{
private $values;
private array $values;
public function __construct(?string $name, NodeInterface $parent = null, array $values = [], string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
{
$values = array_unique($values);
if (empty($values)) {
if (!$values) {
throw new \InvalidArgumentException('$values must contain at least one element.');
}
foreach ($values as $value) {
if (null === $value || \is_scalar($value)) {
continue;
}
if (!$value instanceof \UnitEnum) {
throw new \InvalidArgumentException(sprintf('"%s" only supports scalar, enum, or null values, "%s" given.', __CLASS__, get_debug_type($value)));
}
if ($value::class !== ($enumClass ??= $value::class)) {
throw new \InvalidArgumentException(sprintf('"%s" only supports one type of enum, "%s" and "%s" passed.', __CLASS__, $enumClass, $value::class));
}
}
parent::__construct($name, $parent, $pathSeparator);
$this->values = $values;
}
/**
* @return array
*/
public function getValues()
{
return $this->values;
}
/**
* {@inheritdoc}
* @internal
*/
protected function finalizeValue($value)
public function getPermissibleValues(string $separator): string
{
return implode($separator, array_unique(array_map(static function (mixed $value): string {
if (!$value instanceof \UnitEnum) {
return json_encode($value);
}
return ltrim(var_export($value, true), '\\');
}, $this->values)));
}
/**
* @return void
*/
protected function validateType(mixed $value)
{
if ($value instanceof \UnitEnum) {
return;
}
parent::validateType($value);
}
protected function finalizeValue(mixed $value): mixed
{
$value = parent::finalizeValue($value);
if (!\in_array($value, $this->values, true)) {
$ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values))));
$ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), $this->getPermissibleValues(', ')));
$ex->setPath($this->getPath());
throw $ex;
@@ -54,12 +93,4 @@ class EnumNode extends ScalarNode
return $value;
}
/**
* {@inheritdoc}
*/
protected function allowPlaceholders(): bool
{
return false;
}
}