mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -12,11 +12,13 @@
|
||||
namespace Symfony\Component\Config\Definition\Dumper;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\BaseNode;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\EnumNode;
|
||||
use Symfony\Component\Config\Definition\NodeInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
use Symfony\Component\Config\Definition\ScalarNode;
|
||||
use Symfony\Component\Config\Definition\VariableNode;
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
|
||||
/**
|
||||
@@ -33,7 +35,7 @@ class YamlReferenceDumper
|
||||
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
|
||||
}
|
||||
|
||||
public function dumpAtPath(ConfigurationInterface $configuration, $path)
|
||||
public function dumpAtPath(ConfigurationInterface $configuration, string $path)
|
||||
{
|
||||
$rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree();
|
||||
|
||||
@@ -69,17 +71,16 @@ class YamlReferenceDumper
|
||||
return $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $depth
|
||||
* @param bool $prototypedArray
|
||||
*/
|
||||
private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, $depth = 0, $prototypedArray = false)
|
||||
private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = false)
|
||||
{
|
||||
$comments = [];
|
||||
$default = '';
|
||||
$defaultArray = null;
|
||||
$children = null;
|
||||
$example = $node->getExample();
|
||||
$example = null;
|
||||
if ($node instanceof BaseNode) {
|
||||
$example = $node->getExample();
|
||||
}
|
||||
|
||||
// defaults
|
||||
if ($node instanceof ArrayNode) {
|
||||
@@ -99,6 +100,9 @@ class YamlReferenceDumper
|
||||
} elseif ($node instanceof EnumNode) {
|
||||
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
|
||||
$default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
|
||||
} elseif (VariableNode::class === \get_class($node) && \is_array($example)) {
|
||||
// If there is an array example, we are sure we dont need to print a default value
|
||||
$default = '';
|
||||
} else {
|
||||
$default = '~';
|
||||
|
||||
@@ -123,13 +127,14 @@ class YamlReferenceDumper
|
||||
}
|
||||
|
||||
// deprecated?
|
||||
if ($node->isDeprecated()) {
|
||||
$comments[] = sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath()));
|
||||
if ($node instanceof BaseNode && $node->isDeprecated()) {
|
||||
$deprecation = $node->getDeprecation($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath());
|
||||
$comments[] = sprintf('Deprecated (%s)', ($deprecation['package'] || $deprecation['version'] ? "Since {$deprecation['package']} {$deprecation['version']}: " : '').$deprecation['message']);
|
||||
}
|
||||
|
||||
// example
|
||||
if ($example && !\is_array($example)) {
|
||||
$comments[] = 'Example: '.$example;
|
||||
$comments[] = 'Example: '.Inline::dump($example);
|
||||
}
|
||||
|
||||
$default = '' != (string) $default ? ' '.$default : '';
|
||||
@@ -138,7 +143,7 @@ class YamlReferenceDumper
|
||||
$key = $prototypedArray ? '-' : $node->getName().':';
|
||||
$text = rtrim(sprintf('%-21s%s %s', $key, $default, $comments), ' ');
|
||||
|
||||
if ($info = $node->getInfo()) {
|
||||
if ($node instanceof BaseNode && $info = $node->getInfo()) {
|
||||
$this->writeLine('');
|
||||
// indenting multi-line info
|
||||
$info = str_replace("\n", sprintf("\n%".($depth * 4).'s# ', ' '), $info);
|
||||
@@ -165,7 +170,7 @@ class YamlReferenceDumper
|
||||
|
||||
$this->writeLine('# '.$message.':', $depth * 4 + 4);
|
||||
|
||||
$this->writeArray($example, $depth + 1);
|
||||
$this->writeArray(array_map([Inline::class, 'dump'], $example), $depth + 1);
|
||||
}
|
||||
|
||||
if ($children) {
|
||||
@@ -177,11 +182,8 @@ class YamlReferenceDumper
|
||||
|
||||
/**
|
||||
* Outputs a single config reference line.
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $indent
|
||||
*/
|
||||
private function writeLine($text, $indent = 0)
|
||||
private function writeLine(string $text, int $indent = 0)
|
||||
{
|
||||
$indent = \strlen($text) + $indent;
|
||||
$format = '%'.$indent.'s';
|
||||
@@ -189,7 +191,7 @@ class YamlReferenceDumper
|
||||
$this->reference .= sprintf($format, $text)."\n";
|
||||
}
|
||||
|
||||
private function writeArray(array $array, $depth)
|
||||
private function writeArray(array $array, int $depth)
|
||||
{
|
||||
$isIndexed = array_values($array) === $array;
|
||||
|
||||
@@ -212,10 +214,7 @@ class YamlReferenceDumper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getPrototypeChildren(PrototypedArrayNode $node)
|
||||
private function getPrototypeChildren(PrototypedArrayNode $node): array
|
||||
{
|
||||
$prototype = $node->getPrototype();
|
||||
$key = $node->getKeyAttribute();
|
||||
|
||||
Reference in New Issue
Block a user