mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +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:
@@ -13,6 +13,7 @@ namespace Symfony\Component\Config\Definition\Builder;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
|
||||
/**
|
||||
@@ -36,9 +37,6 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
protected $nodeBuilder;
|
||||
protected $normalizeKeys = true;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(?string $name, NodeParentInterface $parent = null)
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
@@ -48,83 +46,57 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
public function setBuilder(NodeBuilder $builder)
|
||||
{
|
||||
$this->nodeBuilder = $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function children()
|
||||
public function children(): NodeBuilder
|
||||
{
|
||||
return $this->getNodeBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a prototype for child nodes.
|
||||
*
|
||||
* @return NodeDefinition
|
||||
*/
|
||||
public function prototype(string $type)
|
||||
public function prototype(string $type): NodeDefinition
|
||||
{
|
||||
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VariableNodeDefinition
|
||||
*/
|
||||
public function variablePrototype()
|
||||
public function variablePrototype(): VariableNodeDefinition
|
||||
{
|
||||
return $this->prototype('variable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ScalarNodeDefinition
|
||||
*/
|
||||
public function scalarPrototype()
|
||||
public function scalarPrototype(): ScalarNodeDefinition
|
||||
{
|
||||
return $this->prototype('scalar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BooleanNodeDefinition
|
||||
*/
|
||||
public function booleanPrototype()
|
||||
public function booleanPrototype(): BooleanNodeDefinition
|
||||
{
|
||||
return $this->prototype('boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IntegerNodeDefinition
|
||||
*/
|
||||
public function integerPrototype()
|
||||
public function integerPrototype(): IntegerNodeDefinition
|
||||
{
|
||||
return $this->prototype('integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FloatNodeDefinition
|
||||
*/
|
||||
public function floatPrototype()
|
||||
public function floatPrototype(): FloatNodeDefinition
|
||||
{
|
||||
return $this->prototype('float');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function arrayPrototype()
|
||||
public function arrayPrototype(): self
|
||||
{
|
||||
return $this->prototype('array');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EnumNodeDefinition
|
||||
*/
|
||||
public function enumPrototype()
|
||||
public function enumPrototype(): EnumNodeDefinition
|
||||
{
|
||||
return $this->prototype('enum');
|
||||
}
|
||||
@@ -138,7 +110,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultsIfNotSet()
|
||||
public function addDefaultsIfNotSet(): static
|
||||
{
|
||||
$this->addDefaults = true;
|
||||
|
||||
@@ -154,7 +126,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultChildrenIfNoneSet($children = null)
|
||||
public function addDefaultChildrenIfNoneSet(int|string|array $children = null): static
|
||||
{
|
||||
$this->addDefaultChildren = $children;
|
||||
|
||||
@@ -168,7 +140,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function requiresAtLeastOneElement()
|
||||
public function requiresAtLeastOneElement(): static
|
||||
{
|
||||
$this->atLeastOne = true;
|
||||
|
||||
@@ -182,7 +154,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function disallowNewKeysInSubsequentConfigs()
|
||||
public function disallowNewKeysInSubsequentConfigs(): static
|
||||
{
|
||||
$this->allowNewKeys = false;
|
||||
|
||||
@@ -197,7 +169,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fixXmlConfig(string $singular, string $plural = null)
|
||||
public function fixXmlConfig(string $singular, string $plural = null): static
|
||||
{
|
||||
$this->normalization()->remap($singular, $plural);
|
||||
|
||||
@@ -232,7 +204,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function useAttributeAsKey(string $name, bool $removeKeyItem = true)
|
||||
public function useAttributeAsKey(string $name, bool $removeKeyItem = true): static
|
||||
{
|
||||
$this->key = $name;
|
||||
$this->removeKeyItem = $removeKeyItem;
|
||||
@@ -245,7 +217,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeUnset(bool $allow = true)
|
||||
public function canBeUnset(bool $allow = true): static
|
||||
{
|
||||
$this->merge()->allowUnset($allow);
|
||||
|
||||
@@ -267,7 +239,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeEnabled()
|
||||
public function canBeEnabled(): static
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
@@ -277,7 +249,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function (array $v) {
|
||||
$v['enabled'] = $v['enabled'] ?? true;
|
||||
$v['enabled'] ??= true;
|
||||
|
||||
return $v;
|
||||
})
|
||||
@@ -297,7 +269,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function canBeDisabled()
|
||||
public function canBeDisabled(): static
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
@@ -317,7 +289,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function performNoDeepMerging()
|
||||
public function performNoDeepMerging(): static
|
||||
{
|
||||
$this->performDeepMerging = false;
|
||||
|
||||
@@ -337,7 +309,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreExtraKeys(bool $remove = true)
|
||||
public function ignoreExtraKeys(bool $remove = true): static
|
||||
{
|
||||
$this->ignoreExtraKeys = true;
|
||||
$this->removeExtraKeys = $remove;
|
||||
@@ -350,17 +322,14 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function normalizeKeys(bool $bool)
|
||||
public function normalizeKeys(bool $bool): static
|
||||
{
|
||||
$this->normalizeKeys = $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append(NodeDefinition $node)
|
||||
public function append(NodeDefinition $node): static
|
||||
{
|
||||
$this->children[$node->name] = $node->setParent($this);
|
||||
|
||||
@@ -369,24 +338,17 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
|
||||
/**
|
||||
* Returns a node builder to be used to add children and prototype.
|
||||
*
|
||||
* @return NodeBuilder
|
||||
*/
|
||||
protected function getNodeBuilder()
|
||||
protected function getNodeBuilder(): NodeBuilder
|
||||
{
|
||||
if (null === $this->nodeBuilder) {
|
||||
$this->nodeBuilder = new NodeBuilder();
|
||||
}
|
||||
$this->nodeBuilder ??= new NodeBuilder();
|
||||
|
||||
return $this->nodeBuilder->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createNode()
|
||||
protected function createNode(): NodeInterface
|
||||
{
|
||||
if (null === $this->prototype) {
|
||||
if (!isset($this->prototype)) {
|
||||
$node = new ArrayNode($this->name, $this->parent, $this->pathSeparator);
|
||||
|
||||
$this->validateConcreteNode($node);
|
||||
@@ -420,7 +382,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
|
||||
if (false !== $this->addDefaultChildren) {
|
||||
$node->setAddChildrenIfNoneSet($this->addDefaultChildren);
|
||||
if ($this->prototype instanceof static && null === $this->prototype->prototype) {
|
||||
if ($this->prototype instanceof static && !isset($this->prototype->prototype)) {
|
||||
$this->prototype->addDefaultsIfNotSet();
|
||||
}
|
||||
}
|
||||
@@ -442,17 +404,18 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
$node->setDeprecated($this->deprecation['package'], $this->deprecation['version'], $this->deprecation['message']);
|
||||
}
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
if (isset($this->normalization)) {
|
||||
$node->setNormalizationClosures($this->normalization->before);
|
||||
$node->setNormalizedTypes($this->normalization->declaredTypes);
|
||||
$node->setXmlRemappings($this->normalization->remappings);
|
||||
}
|
||||
|
||||
if (null !== $this->merge) {
|
||||
if (isset($this->merge)) {
|
||||
$node->setAllowOverwrite($this->merge->allowOverwrite);
|
||||
$node->setAllowFalse($this->merge->allowFalse);
|
||||
}
|
||||
|
||||
if (null !== $this->validation) {
|
||||
if (isset($this->validation)) {
|
||||
$node->setFinalValidationClosures($this->validation->rules);
|
||||
}
|
||||
|
||||
@@ -462,6 +425,8 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
/**
|
||||
* Validate the configuration of a concrete node.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
protected function validateConcreteNode(ArrayNode $node)
|
||||
@@ -492,6 +457,8 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
/**
|
||||
* Validate the configuration of a prototype node.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidDefinitionException
|
||||
*/
|
||||
protected function validatePrototypeNode(PrototypedArrayNode $node)
|
||||
@@ -520,7 +487,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
/**
|
||||
* @return NodeDefinition[]
|
||||
*/
|
||||
public function getChildNodeDefinitions()
|
||||
public function getChildNodeDefinitions(): array
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user