mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +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:
@@ -32,21 +32,22 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
protected $removeExtraKeys = true;
|
||||
protected $normalizeKeys = true;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setNormalizeKeys(bool $normalizeKeys)
|
||||
{
|
||||
$this->normalizeKeys = $normalizeKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Namely, you mostly have foo_bar in YAML while you have foo-bar in XML.
|
||||
* After running this method, all keys are normalized to foo_bar.
|
||||
*
|
||||
* If you have a mixed key like foo-bar_moo, it will not be altered.
|
||||
* The key will also not be altered if the target key already exists.
|
||||
*/
|
||||
protected function preNormalize($value)
|
||||
protected function preNormalize(mixed $value): mixed
|
||||
{
|
||||
if (!$this->normalizeKeys || !\is_array($value)) {
|
||||
return $value;
|
||||
@@ -70,7 +71,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
*
|
||||
* @return array<string, NodeInterface>
|
||||
*/
|
||||
public function getChildren()
|
||||
public function getChildren(): array
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
@@ -79,6 +80,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
* Sets the xml remappings that should be performed.
|
||||
*
|
||||
* @param array $remappings An array of the form [[string, string]]
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setXmlRemappings(array $remappings)
|
||||
{
|
||||
@@ -90,7 +93,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
*
|
||||
* @return array an array of the form [[string, string]]
|
||||
*/
|
||||
public function getXmlRemappings()
|
||||
public function getXmlRemappings(): array
|
||||
{
|
||||
return $this->xmlRemappings;
|
||||
}
|
||||
@@ -98,6 +101,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
/**
|
||||
* Sets whether to add default values for this array if it has not been
|
||||
* defined in any of the configuration files.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAddIfNotSet(bool $boolean)
|
||||
{
|
||||
@@ -106,6 +111,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
|
||||
/**
|
||||
* Sets whether false is allowed as value indicating that the array should be unset.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAllowFalse(bool $allow)
|
||||
{
|
||||
@@ -114,6 +121,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
|
||||
/**
|
||||
* Sets whether new keys can be defined in subsequent configurations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAllowNewKeys(bool $allow)
|
||||
{
|
||||
@@ -122,6 +131,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
|
||||
/**
|
||||
* Sets if deep merging should occur.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPerformDeepMerging(bool $boolean)
|
||||
{
|
||||
@@ -133,6 +144,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
*
|
||||
* @param bool $boolean To allow extra keys
|
||||
* @param bool $remove To remove extra keys
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIgnoreExtraKeys(bool $boolean, bool $remove = true)
|
||||
{
|
||||
@@ -149,25 +162,19 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasDefaultValue()
|
||||
public function hasDefaultValue(): bool
|
||||
{
|
||||
return $this->addIfNotSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
public function getDefaultValue(): mixed
|
||||
{
|
||||
if (!$this->hasDefaultValue()) {
|
||||
throw new \RuntimeException(sprintf('The node at path "%s" has no default value.', $this->getPath()));
|
||||
@@ -186,6 +193,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
/**
|
||||
* Adds a child node.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \InvalidArgumentException when the child node has no name
|
||||
* @throws \InvalidArgumentException when the child node's name is not unique
|
||||
*/
|
||||
@@ -203,12 +212,10 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws UnsetKeyException
|
||||
* @throws InvalidConfigurationException if the node doesn't have enough children
|
||||
*/
|
||||
protected function finalizeValue($value)
|
||||
protected function finalizeValue(mixed $value): mixed
|
||||
{
|
||||
if (false === $value) {
|
||||
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value)));
|
||||
@@ -243,7 +250,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
|
||||
try {
|
||||
$value[$name] = $child->finalize($value[$name]);
|
||||
} catch (UnsetKeyException $e) {
|
||||
} catch (UnsetKeyException) {
|
||||
unset($value[$name]);
|
||||
}
|
||||
}
|
||||
@@ -252,9 +259,9 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
protected function validateType($value)
|
||||
protected function validateType(mixed $value)
|
||||
{
|
||||
if (!\is_array($value) && (!$this->allowFalse || false !== $value)) {
|
||||
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), get_debug_type($value)));
|
||||
@@ -268,11 +275,9 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws InvalidConfigurationException
|
||||
*/
|
||||
protected function normalizeValue($value)
|
||||
protected function normalizeValue(mixed $value): mixed
|
||||
{
|
||||
if (false === $value) {
|
||||
return $value;
|
||||
@@ -285,7 +290,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
if (isset($this->children[$name])) {
|
||||
try {
|
||||
$normalized[$name] = $this->children[$name]->normalize($val);
|
||||
} catch (UnsetKeyException $e) {
|
||||
} catch (UnsetKeyException) {
|
||||
}
|
||||
unset($value[$name]);
|
||||
} elseif (!$this->removeExtraKeys) {
|
||||
@@ -330,10 +335,8 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
|
||||
/**
|
||||
* Remaps multiple singular values to a single plural value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function remapXml(array $value)
|
||||
protected function remapXml(array $value): array
|
||||
{
|
||||
foreach ($this->xmlRemappings as [$singular, $plural]) {
|
||||
if (!isset($value[$singular])) {
|
||||
@@ -348,12 +351,10 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws InvalidConfigurationException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function mergeValues($leftSide, $rightSide)
|
||||
protected function mergeValues(mixed $leftSide, mixed $rightSide): mixed
|
||||
{
|
||||
if (false === $rightSide) {
|
||||
// if this is still false after the last config has been merged the
|
||||
@@ -394,9 +395,6 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
return $leftSide;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function allowPlaceholders(): bool
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user