mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +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,10 +13,14 @@ namespace Symfony\Component\Config\Definition\Dumper;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\BooleanNode;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
use Symfony\Component\Config\Definition\FloatNode;
|
||||
use Symfony\Component\Config\Definition\IntegerNode;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
|
||||
/**
|
||||
* Dumps an XML reference configuration for the given configuration/node instance.
|
||||
@@ -25,13 +29,19 @@ use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
*/
|
||||
class XmlReferenceDumper
|
||||
{
|
||||
private $reference;
|
||||
private ?string $reference = null;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function dump(ConfigurationInterface $configuration, string $namespace = null)
|
||||
{
|
||||
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function dumpNode(NodeInterface $node, string $namespace = null)
|
||||
{
|
||||
$this->reference = '';
|
||||
@@ -42,16 +52,14 @@ class XmlReferenceDumper
|
||||
return $ref;
|
||||
}
|
||||
|
||||
private function writeNode(NodeInterface $node, int $depth = 0, bool $root = false, string $namespace = null)
|
||||
private function writeNode(NodeInterface $node, int $depth = 0, bool $root = false, string $namespace = null): void
|
||||
{
|
||||
$rootName = ($root ? 'config' : $node->getName());
|
||||
$rootNamespace = ($namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null));
|
||||
|
||||
// xml remapping
|
||||
if ($node->getParent()) {
|
||||
$remapping = array_filter($node->getParent()->getXmlRemappings(), function (array $mapping) use ($rootName) {
|
||||
return $rootName === $mapping[1];
|
||||
});
|
||||
$remapping = array_filter($node->getParent()->getXmlRemappings(), fn (array $mapping) => $rootName === $mapping[1]);
|
||||
|
||||
if (\count($remapping)) {
|
||||
[$singular] = current($remapping);
|
||||
@@ -100,27 +108,14 @@ class XmlReferenceDumper
|
||||
if ($prototype->hasDefaultValue()) {
|
||||
$prototypeValue = $prototype->getDefaultValue();
|
||||
} else {
|
||||
switch (\get_class($prototype)) {
|
||||
case 'Symfony\Component\Config\Definition\ScalarNode':
|
||||
$prototypeValue = 'scalar value';
|
||||
break;
|
||||
|
||||
case 'Symfony\Component\Config\Definition\FloatNode':
|
||||
case 'Symfony\Component\Config\Definition\IntegerNode':
|
||||
$prototypeValue = 'numeric value';
|
||||
break;
|
||||
|
||||
case 'Symfony\Component\Config\Definition\BooleanNode':
|
||||
$prototypeValue = 'true|false';
|
||||
break;
|
||||
|
||||
case 'Symfony\Component\Config\Definition\EnumNode':
|
||||
$prototypeValue = implode('|', array_map('json_encode', $prototype->getValues()));
|
||||
break;
|
||||
|
||||
default:
|
||||
$prototypeValue = 'value';
|
||||
}
|
||||
$prototypeValue = match ($prototype::class) {
|
||||
ScalarNode::class => 'scalar value',
|
||||
FloatNode::class,
|
||||
IntegerNode::class => 'numeric value',
|
||||
BooleanNode::class => 'true|false',
|
||||
EnumNode::class => $prototype->getPermissibleValues('|'),
|
||||
default => 'value',
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +142,7 @@ class XmlReferenceDumper
|
||||
}
|
||||
|
||||
if ($child instanceof BaseNode && $example = $child->getExample()) {
|
||||
$comments[] = 'Example: '.$example;
|
||||
$comments[] = 'Example: '.(\is_array($example) ? implode(', ', $example) : $example);
|
||||
}
|
||||
|
||||
if ($child->isRequired()) {
|
||||
@@ -160,7 +155,7 @@ class XmlReferenceDumper
|
||||
}
|
||||
|
||||
if ($child instanceof EnumNode) {
|
||||
$comments[] = 'One of '.implode('; ', array_map('json_encode', $child->getValues()));
|
||||
$comments[] = 'One of '.$child->getPermissibleValues('; ');
|
||||
}
|
||||
|
||||
if (\count($comments)) {
|
||||
@@ -258,7 +253,7 @@ class XmlReferenceDumper
|
||||
/**
|
||||
* Outputs a single config reference line.
|
||||
*/
|
||||
private function writeLine(string $text, int $indent = 0)
|
||||
private function writeLine(string $text, int $indent = 0): void
|
||||
{
|
||||
$indent = \strlen($text) + $indent;
|
||||
$format = '%'.$indent.'s';
|
||||
@@ -268,10 +263,8 @@ class XmlReferenceDumper
|
||||
|
||||
/**
|
||||
* Renders the string conversion of the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
private function writeValue($value): string
|
||||
private function writeValue(mixed $value): string
|
||||
{
|
||||
if ('%%%%not_defined%%%%' === $value) {
|
||||
return '';
|
||||
|
||||
Reference in New Issue
Block a user