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:
@@ -49,7 +49,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent(NodeParentInterface $parent)
|
||||
public function setParent(NodeParentInterface $parent): static
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function info(string $info)
|
||||
public function info(string $info): static
|
||||
{
|
||||
return $this->attribute('info', $info);
|
||||
}
|
||||
@@ -69,11 +69,9 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
/**
|
||||
* Sets example configuration.
|
||||
*
|
||||
* @param string|array $example
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function example($example)
|
||||
public function example(string|array $example): static
|
||||
{
|
||||
return $this->attribute('example', $example);
|
||||
}
|
||||
@@ -81,11 +79,9 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
/**
|
||||
* Sets an attribute on the node.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function attribute(string $key, $value)
|
||||
public function attribute(string $key, mixed $value): static
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
|
||||
@@ -94,30 +90,32 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return NodeParentInterface|NodeBuilder|NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition|null
|
||||
*/
|
||||
public function end()
|
||||
public function end(): NodeParentInterface|NodeBuilder|self|ArrayNodeDefinition|VariableNodeDefinition|null
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the node.
|
||||
*
|
||||
* @return NodeInterface
|
||||
*/
|
||||
public function getNode(bool $forceRootNode = false)
|
||||
public function getNode(bool $forceRootNode = false): NodeInterface
|
||||
{
|
||||
if ($forceRootNode) {
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
if (null !== $this->normalization) {
|
||||
if (isset($this->normalization)) {
|
||||
$allowedTypes = [];
|
||||
foreach ($this->normalization->before as $expr) {
|
||||
$allowedTypes[] = $expr->allowedTypes;
|
||||
}
|
||||
$allowedTypes = array_unique($allowedTypes);
|
||||
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
|
||||
$this->normalization->declaredTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
if (null !== $this->validation) {
|
||||
if (isset($this->validation)) {
|
||||
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
|
||||
}
|
||||
|
||||
@@ -132,11 +130,9 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
/**
|
||||
* Sets the default value.
|
||||
*
|
||||
* @param mixed $value The default value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultValue($value)
|
||||
public function defaultValue(mixed $value): static
|
||||
{
|
||||
$this->default = true;
|
||||
$this->defaultValue = $value;
|
||||
@@ -149,7 +145,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function isRequired()
|
||||
public function isRequired(): static
|
||||
{
|
||||
$this->required = true;
|
||||
|
||||
@@ -168,21 +164,8 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
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.'): static
|
||||
{
|
||||
$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__);
|
||||
|
||||
$message = $args[0] ?? 'The child node "%node%" at path "%path%" is deprecated.';
|
||||
$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,
|
||||
@@ -195,11 +178,9 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains null.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatNullLike($value)
|
||||
public function treatNullLike(mixed $value): static
|
||||
{
|
||||
$this->nullEquivalent = $value;
|
||||
|
||||
@@ -209,11 +190,9 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains true.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatTrueLike($value)
|
||||
public function treatTrueLike(mixed $value): static
|
||||
{
|
||||
$this->trueEquivalent = $value;
|
||||
|
||||
@@ -223,11 +202,9 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
/**
|
||||
* Sets the equivalent value used when the node contains false.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function treatFalseLike($value)
|
||||
public function treatFalseLike(mixed $value): static
|
||||
{
|
||||
$this->falseEquivalent = $value;
|
||||
|
||||
@@ -239,7 +216,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultNull()
|
||||
public function defaultNull(): static
|
||||
{
|
||||
return $this->defaultValue(null);
|
||||
}
|
||||
@@ -249,7 +226,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultTrue()
|
||||
public function defaultTrue(): static
|
||||
{
|
||||
return $this->defaultValue(true);
|
||||
}
|
||||
@@ -259,17 +236,15 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function defaultFalse()
|
||||
public function defaultFalse(): static
|
||||
{
|
||||
return $this->defaultValue(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an expression to run before the normalization.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function beforeNormalization()
|
||||
public function beforeNormalization(): ExprBuilder
|
||||
{
|
||||
return $this->normalization()->before();
|
||||
}
|
||||
@@ -279,7 +254,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cannotBeEmpty()
|
||||
public function cannotBeEmpty(): static
|
||||
{
|
||||
$this->allowEmptyValue = false;
|
||||
|
||||
@@ -292,10 +267,8 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
* The expression receives the value of the node and must return it. It can
|
||||
* modify it.
|
||||
* An exception should be thrown when the node is not valid.
|
||||
*
|
||||
* @return ExprBuilder
|
||||
*/
|
||||
public function validate()
|
||||
public function validate(): ExprBuilder
|
||||
{
|
||||
return $this->validation()->rule();
|
||||
}
|
||||
@@ -305,7 +278,7 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cannotBeOverwritten(bool $deny = true)
|
||||
public function cannotBeOverwritten(bool $deny = true): static
|
||||
{
|
||||
$this->merge()->denyOverwrite($deny);
|
||||
|
||||
@@ -314,61 +287,41 @@ abstract class NodeDefinition implements NodeParentInterface
|
||||
|
||||
/**
|
||||
* Gets the builder for validation rules.
|
||||
*
|
||||
* @return ValidationBuilder
|
||||
*/
|
||||
protected function validation()
|
||||
protected function validation(): ValidationBuilder
|
||||
{
|
||||
if (null === $this->validation) {
|
||||
$this->validation = new ValidationBuilder($this);
|
||||
}
|
||||
|
||||
return $this->validation;
|
||||
return $this->validation ??= new ValidationBuilder($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for merging rules.
|
||||
*
|
||||
* @return MergeBuilder
|
||||
*/
|
||||
protected function merge()
|
||||
protected function merge(): MergeBuilder
|
||||
{
|
||||
if (null === $this->merge) {
|
||||
$this->merge = new MergeBuilder($this);
|
||||
}
|
||||
|
||||
return $this->merge;
|
||||
return $this->merge ??= new MergeBuilder($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the builder for normalization rules.
|
||||
*
|
||||
* @return NormalizationBuilder
|
||||
*/
|
||||
protected function normalization()
|
||||
protected function normalization(): NormalizationBuilder
|
||||
{
|
||||
if (null === $this->normalization) {
|
||||
$this->normalization = new NormalizationBuilder($this);
|
||||
}
|
||||
|
||||
return $this->normalization;
|
||||
return $this->normalization ??= new NormalizationBuilder($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate and configure the node according to this definition.
|
||||
*
|
||||
* @return NodeInterface
|
||||
*
|
||||
* @throws InvalidDefinitionException When the definition is invalid
|
||||
*/
|
||||
abstract protected function createNode();
|
||||
abstract protected function createNode(): NodeInterface;
|
||||
|
||||
/**
|
||||
* Set PathSeparator to use.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPathSeparator(string $separator)
|
||||
public function setPathSeparator(string $separator): static
|
||||
{
|
||||
if ($this instanceof ParentNodeDefinitionInterface) {
|
||||
foreach ($this->getChildNodeDefinitions() as $child) {
|
||||
|
||||
Reference in New Issue
Block a user