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

@@ -26,12 +26,13 @@ abstract class BaseNode implements NodeInterface
{
public const DEFAULT_PATH_SEPARATOR = '.';
private static $placeholderUniquePrefixes = [];
private static $placeholders = [];
private static array $placeholderUniquePrefixes = [];
private static array $placeholders = [];
protected $name;
protected $parent;
protected $normalizationClosures = [];
protected $normalizedTypes = [];
protected $finalValidationClosures = [];
protected $allowOverwrite = true;
protected $required = false;
@@ -40,7 +41,7 @@ abstract class BaseNode implements NodeInterface
protected $attributes = [];
protected $pathSeparator;
private $handlingPlaceholder;
private mixed $handlingPlaceholder = null;
/**
* @throws \InvalidArgumentException if the name contains a period
@@ -97,40 +98,40 @@ abstract class BaseNode implements NodeInterface
self::$placeholders = [];
}
public function setAttribute(string $key, $value)
/**
* @return void
*/
public function setAttribute(string $key, mixed $value)
{
$this->attributes[$key] = $value;
}
/**
* @return mixed
*/
public function getAttribute(string $key, $default = null)
public function getAttribute(string $key, mixed $default = null): mixed
{
return $this->attributes[$key] ?? $default;
}
/**
* @return bool
*/
public function hasAttribute(string $key)
public function hasAttribute(string $key): bool
{
return isset($this->attributes[$key]);
}
/**
* @return array
*/
public function getAttributes()
public function getAttributes(): array
{
return $this->attributes;
}
/**
* @return void
*/
public function setAttributes(array $attributes)
{
$this->attributes = $attributes;
}
/**
* @return void
*/
public function removeAttribute(string $key)
{
unset($this->attributes[$key]);
@@ -138,6 +139,8 @@ abstract class BaseNode implements NodeInterface
/**
* Sets an info message.
*
* @return void
*/
public function setInfo(string $info)
{
@@ -146,10 +149,8 @@ abstract class BaseNode implements NodeInterface
/**
* Returns info message.
*
* @return string|null
*/
public function getInfo()
public function getInfo(): ?string
{
return $this->getAttribute('info');
}
@@ -157,19 +158,17 @@ abstract class BaseNode implements NodeInterface
/**
* Sets the example configuration for this node.
*
* @param string|array $example
* @return void
*/
public function setExample($example)
public function setExample(string|array $example)
{
$this->setAttribute('example', $example);
}
/**
* Retrieves the example configuration for this node.
*
* @return string|array|null
*/
public function getExample()
public function getExample(): string|array|null
{
return $this->getAttribute('example');
}
@@ -177,16 +176,17 @@ abstract class BaseNode implements NodeInterface
/**
* Adds an equivalent value.
*
* @param mixed $originalValue
* @param mixed $equivalentValue
* @return void
*/
public function addEquivalentValue($originalValue, $equivalentValue)
public function addEquivalentValue(mixed $originalValue, mixed $equivalentValue)
{
$this->equivalentValues[] = [$originalValue, $equivalentValue];
}
/**
* Set this node as required.
*
* @return void
*/
public function setRequired(bool $boolean)
{
@@ -196,36 +196,17 @@ abstract class BaseNode implements NodeInterface
/**
* Sets this node as deprecated.
*
* You can use %node% and %path% placeholders in your message to display,
* respectively, the node name and its complete path.
*
* @param string $package The name of the composer package that is triggering the deprecation
* @param string $version The version of the package that introduced the deprecation
* @param string $message the deprecation message to use
*
* You can use %node% and %path% placeholders in your message to display,
* respectively, the node name and its complete path
* @return void
*/
public function setDeprecated(?string $package/* , string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.' */)
public function setDeprecated(string $package, string $version, string $message = 'The child node "%node%" at path "%path%" is deprecated.')
{
$args = \func_get_args();
if (\func_num_args() < 2) {
trigger_deprecation('symfony/config', '5.1', 'The signature of method "%s()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.', __METHOD__);
if (!isset($args[0])) {
trigger_deprecation('symfony/config', '5.1', 'Passing a null message to un-deprecate a node is deprecated.');
$this->deprecation = [];
return;
}
$message = (string) $args[0];
$package = $version = '';
} else {
$package = (string) $args[0];
$version = (string) $args[1];
$message = (string) ($args[2] ?? 'The child node "%node%" at path "%path%" is deprecated.');
}
$this->deprecation = [
'package' => $package,
'version' => $version,
@@ -235,6 +216,8 @@ abstract class BaseNode implements NodeInterface
/**
* Sets if this node can be overridden.
*
* @return void
*/
public function setAllowOverwrite(bool $allow)
{
@@ -245,57 +228,61 @@ abstract class BaseNode implements NodeInterface
* Sets the closures used for normalization.
*
* @param \Closure[] $closures An array of Closures used for normalization
*
* @return void
*/
public function setNormalizationClosures(array $closures)
{
$this->normalizationClosures = $closures;
}
/**
* Sets the list of types supported by normalization.
*
* see ExprBuilder::TYPE_* constants.
*
* @return void
*/
public function setNormalizedTypes(array $types)
{
$this->normalizedTypes = $types;
}
/**
* Gets the list of types supported by normalization.
*
* see ExprBuilder::TYPE_* constants.
*/
public function getNormalizedTypes(): array
{
return $this->normalizedTypes;
}
/**
* Sets the closures used for final validation.
*
* @param \Closure[] $closures An array of Closures used for final validation
*
* @return void
*/
public function setFinalValidationClosures(array $closures)
{
$this->finalValidationClosures = $closures;
}
/**
* {@inheritdoc}
*/
public function isRequired()
public function isRequired(): bool
{
return $this->required;
}
/**
* Checks if this node is deprecated.
*
* @return bool
*/
public function isDeprecated()
public function isDeprecated(): bool
{
return (bool) $this->deprecation;
}
/**
* Returns the deprecated message.
*
* @param string $node the configuration node name
* @param string $path the path of the node
*
* @return string
*
* @deprecated since Symfony 5.1, use "getDeprecation()" instead.
*/
public function getDeprecationMessage(string $node, string $path)
{
trigger_deprecation('symfony/config', '5.1', 'The "%s()" method is deprecated, use "getDeprecation()" instead.', __METHOD__);
return $this->getDeprecation($node, $path)['message'];
}
/**
* @param string $node The configuration node name
* @param string $path The path of the node
@@ -303,24 +290,18 @@ abstract class BaseNode implements NodeInterface
public function getDeprecation(string $node, string $path): array
{
return [
'package' => $this->deprecation['package'] ?? '',
'version' => $this->deprecation['version'] ?? '',
'message' => strtr($this->deprecation['message'] ?? '', ['%node%' => $node, '%path%' => $path]),
'package' => $this->deprecation['package'],
'version' => $this->deprecation['version'],
'message' => strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]),
];
}
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return $this->name;
}
/**
* {@inheritdoc}
*/
public function getPath()
public function getPath(): string
{
if (null !== $this->parent) {
return $this->parent->getPath().$this->pathSeparator.$this->name;
@@ -329,10 +310,7 @@ abstract class BaseNode implements NodeInterface
return $this->name;
}
/**
* {@inheritdoc}
*/
final public function merge($leftSide, $rightSide)
final public function merge(mixed $leftSide, mixed $rightSide): mixed
{
if (!$this->allowOverwrite) {
throw new ForbiddenOverwriteException(sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath()));
@@ -370,10 +348,7 @@ abstract class BaseNode implements NodeInterface
return $this->mergeValues($leftSide, $rightSide);
}
/**
* {@inheritdoc}
*/
final public function normalize($value)
final public function normalize(mixed $value): mixed
{
$value = $this->preNormalize($value);
@@ -412,30 +387,21 @@ abstract class BaseNode implements NodeInterface
/**
* Normalizes the value before any other normalization is applied.
*
* @param mixed $value
*
* @return mixed
*/
protected function preNormalize($value)
protected function preNormalize(mixed $value): mixed
{
return $value;
}
/**
* Returns parent node for this node.
*
* @return NodeInterface|null
*/
public function getParent()
public function getParent(): ?NodeInterface
{
return $this->parent;
}
/**
* {@inheritdoc}
*/
final public function finalize($value)
final public function finalize(mixed $value): mixed
{
if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
foreach ($placeholders as $placeholder) {
@@ -476,39 +442,26 @@ abstract class BaseNode implements NodeInterface
/**
* Validates the type of a Node.
*
* @param mixed $value The value to validate
* @return void
*
* @throws InvalidTypeException when the value is invalid
*/
abstract protected function validateType($value);
abstract protected function validateType(mixed $value);
/**
* Normalizes the value.
*
* @param mixed $value The value to normalize
*
* @return mixed
*/
abstract protected function normalizeValue($value);
abstract protected function normalizeValue(mixed $value): mixed;
/**
* Merges two values together.
*
* @param mixed $leftSide
* @param mixed $rightSide
*
* @return mixed
*/
abstract protected function mergeValues($leftSide, $rightSide);
abstract protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed;
/**
* Finalizes a value.
*
* @param mixed $value The value to finalize
*
* @return mixed
*/
abstract protected function finalizeValue($value);
abstract protected function finalizeValue(mixed $value): mixed;
/**
* Tests if placeholder values are allowed for this node.
@@ -534,7 +487,7 @@ abstract class BaseNode implements NodeInterface
return [];
}
private static function resolvePlaceholderValue($value)
private static function resolvePlaceholderValue(mixed $value): mixed
{
if (\is_string($value)) {
if (isset(self::$placeholders[$value])) {
@@ -551,7 +504,7 @@ abstract class BaseNode implements NodeInterface
return $value;
}
private function doValidateType($value): void
private function doValidateType(mixed $value): void
{
if (null !== $this->handlingPlaceholder && !$this->allowPlaceholders()) {
$e = new InvalidTypeException(sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".', static::class, $this->getPath()));