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:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -39,7 +39,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
/**
* {@inheritdoc}
*/
public function __construct($name, NodeParentInterface $parent = null)
public function __construct(?string $name, NodeParentInterface $parent = null)
{
parent::__construct($name, $parent);
@@ -66,11 +66,9 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
/**
* Sets a prototype for child nodes.
*
* @param string $type The type of node
*
* @return NodeDefinition
*/
public function prototype($type)
public function prototype(string $type)
{
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
}
@@ -194,12 +192,12 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
/**
* Sets a normalization rule for XML configurations.
*
* @param string $singular The key to remap
* @param string $plural The plural of the key for irregular plurals
* @param string $singular The key to remap
* @param string|null $plural The plural of the key for irregular plurals
*
* @return $this
*/
public function fixXmlConfig($singular, $plural = null)
public function fixXmlConfig(string $singular, string $plural = null)
{
$this->normalization()->remap($singular, $plural);
@@ -234,7 +232,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
*
* @return $this
*/
public function useAttributeAsKey($name, $removeKeyItem = true)
public function useAttributeAsKey(string $name, bool $removeKeyItem = true)
{
$this->key = $name;
$this->removeKeyItem = $removeKeyItem;
@@ -245,11 +243,9 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
/**
* Sets whether the node can be unset.
*
* @param bool $allow
*
* @return $this
*/
public function canBeUnset($allow = true)
public function canBeUnset(bool $allow = true)
{
$this->merge()->allowUnset($allow);
@@ -280,8 +276,8 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
->treatNullLike(['enabled' => true])
->beforeNormalization()
->ifArray()
->then(function ($v) {
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
->then(function (array $v) {
$v['enabled'] = $v['enabled'] ?? true;
return $v;
})
@@ -341,7 +337,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
*
* @return $this
*/
public function ignoreExtraKeys($remove = true)
public function ignoreExtraKeys(bool $remove = true)
{
$this->ignoreExtraKeys = true;
$this->removeExtraKeys = $remove;
@@ -350,15 +346,13 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
}
/**
* Sets key normalization.
*
* @param bool $bool Whether to enable key normalization
* Sets whether to enable key normalization.
*
* @return $this
*/
public function normalizeKeys($bool)
public function normalizeKeys(bool $bool)
{
$this->normalizeKeys = (bool) $bool;
$this->normalizeKeys = $bool;
return $this;
}
@@ -376,7 +370,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
/**
* Returns a node builder to be used to add children and prototype.
*
* @return NodeBuilder The node builder
* @return NodeBuilder
*/
protected function getNodeBuilder()
{
@@ -393,7 +387,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
protected function createNode()
{
if (null === $this->prototype) {
$node = new ArrayNode($this->name, $this->parent);
$node = new ArrayNode($this->name, $this->parent, $this->pathSeparator);
$this->validateConcreteNode($node);
@@ -404,7 +398,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
$node->addChild($child->getNode());
}
} else {
$node = new PrototypedArrayNode($this->name, $this->parent);
$node = new PrototypedArrayNode($this->name, $this->parent, $this->pathSeparator);
$this->validatePrototypeNode($node);
@@ -412,15 +406,15 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
$node->setKeyAttribute($this->key, $this->removeKeyItem);
}
if (false === $this->allowEmptyValue) {
@trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), \E_USER_DEPRECATED);
}
if (true === $this->atLeastOne) {
if (true === $this->atLeastOne || false === $this->allowEmptyValue) {
$node->setMinNumberOfElements(1);
}
if ($this->default) {
if (!\is_array($this->defaultValue)) {
throw new \InvalidArgumentException(sprintf('%s: the default value of an array node has to be an array.', $node->getPath()));
}
$node->setDefaultValue($this->defaultValue);
}
@@ -441,10 +435,13 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
$node->addEquivalentValue(false, $this->falseEquivalent);
$node->setPerformDeepMerging($this->performDeepMerging);
$node->setRequired($this->required);
$node->setDeprecated($this->deprecationMessage);
$node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys);
$node->setNormalizeKeys($this->normalizeKeys);
if ($this->deprecation) {
$node->setDeprecated($this->deprecation['package'], $this->deprecation['version'], $this->deprecation['message']);
}
if (null !== $this->normalization) {
$node->setNormalizationClosures($this->normalization->before);
$node->setXmlRemappings($this->normalization->remappings);
@@ -476,7 +473,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
}
if (false === $this->allowEmptyValue) {
@trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), \E_USER_DEPRECATED);
throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
}
if (true === $this->atLeastOne) {
@@ -519,4 +516,34 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
}
}
}
/**
* @return NodeDefinition[]
*/
public function getChildNodeDefinitions()
{
return $this->children;
}
/**
* Finds a node defined by the given $nodePath.
*
* @param string $nodePath The path of the node to find. e.g "doctrine.orm.mappings"
*/
public function find(string $nodePath): NodeDefinition
{
$firstPathSegment = (false === $pathSeparatorPos = strpos($nodePath, $this->pathSeparator))
? $nodePath
: substr($nodePath, 0, $pathSeparatorPos);
if (null === $node = ($this->children[$firstPathSegment] ?? null)) {
throw new \RuntimeException(sprintf('Node with name "%s" does not exist in the current node "%s".', $firstPathSegment, $this->name));
}
if (false === $pathSeparatorPos) {
return $node;
}
return $node->find(substr($nodePath, $pathSeparatorPos + \strlen($this->pathSeparator)));
}
}