[Config] Add parameter types

by @derrabus

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/41575/a9e75c25bcf3ce9bbb6552d00ef2a0345c21d1a7/cs.diff | patch -p0
diff -ru src/Symfony/Component/Config/Definition/BaseNode.php src/Symfony/Component/Config/Definition/BaseNode.php
--- src/Symfony/Component/Config/Definition/BaseNode.php	2021-06-09 11:16:12.920973000 +0000
+++ src/Symfony/Component/Config/Definition/BaseNode.php	2021-06-09 11:16:19.774770682 +0000
@@ -157,7 +157,7 @@
     /**
      * Sets the example configuration for this node.
      */
-    public function setExample(string|array $example)
+    public function setExample(string | array $example)
     {
         $this->setAttribute('example', $example);
     }
diff -ru src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
--- src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php	2021-06-09 11:16:13.369959746 +0000
+++ src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php	2021-06-09 11:16:20.218757575 +0000
@@ -154,7 +154,7 @@
      *
      * @return $this
      */
-    public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null)
+    public function addDefaultChildrenIfNoneSet(int | string | array | null $children = null)
     {
         $this->addDefaultChildren = $children;
 
diff -ru src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
--- src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php	2021-06-09 11:16:13.770947910 +0000
+++ src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php	2021-06-09 11:16:20.521748631 +0000
@@ -71,7 +71,7 @@
      *
      * @return $this
      */
-    public function example(string|array $example)
+    public function example(string | array $example)
     {
         return $this->attribute('example', $example);
     }
diff -ru src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php
--- src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php	2021-06-09 11:16:14.011940796 +0000
+++ src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php	2021-06-09 11:16:20.560747480 +0000
@@ -30,7 +30,7 @@
      *
      * @throws \InvalidArgumentException when the constraint is inconsistent
      */
-    public function max(int|float $max)
+    public function max(int | float $max)
     {
         if (isset($this->min) && $this->min > $max) {
             throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
@@ -47,7 +47,7 @@
      *
      * @throws \InvalidArgumentException when the constraint is inconsistent
      */
-    public function min(int|float $min)
+    public function min(int | float $min)
     {
         if (isset($this->max) && $this->max < $min) {
             throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));
diff -ru src/Symfony/Component/Config/Definition/NumericNode.php src/Symfony/Component/Config/Definition/NumericNode.php
--- src/Symfony/Component/Config/Definition/NumericNode.php	2021-06-09 11:16:15.410899499 +0000
+++ src/Symfony/Component/Config/Definition/NumericNode.php	2021-06-09 11:16:21.077732218 +0000
@@ -23,7 +23,7 @@
     protected $min;
     protected $max;
 
-    public function __construct(?string $name, NodeInterface $parent = null, int|float| null $min = null, int|float|null $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
+    public function __construct(?string $name, NodeInterface $parent = null, int | float | null $min = null, int | float | null $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
     {
         parent::__construct($name, $parent, $pathSeparator);
         $this->min = $min;
diff -ru src/Symfony/Component/Config/Definition/PrototypedArrayNode.php src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
--- src/Symfony/Component/Config/Definition/PrototypedArrayNode.php	2021-06-09 11:16:15.657892209 +0000
+++ src/Symfony/Component/Config/Definition/PrototypedArrayNode.php	2021-06-09 11:16:21.353724071 +0000
@@ -104,7 +104,7 @@
      *
      * @param int|string|array|null $children The number of children|The child name|The children names to be added
      */
-    public function setAddChildrenIfNoneSet(int|string|array|null $children = ['defaults'])
+    public function setAddChildrenIfNoneSet(int | string | array | null $children = ['defaults'])
     {
         if (null === $children) {
             $this->defaultChildren = ['defaults'];
diff -ru src/Symfony/Component/Config/FileLocator.php src/Symfony/Component/Config/FileLocator.php
--- src/Symfony/Component/Config/FileLocator.php	2021-06-09 11:16:16.471868181 +0000
+++ src/Symfony/Component/Config/FileLocator.php	2021-06-09 11:16:21.638715658 +0000
@@ -25,7 +25,7 @@
     /**
      * @param string|string[] $paths A path or an array of paths where to look for resources
      */
-    public function __construct(string|array $paths = [])
+    public function __construct(string | array $paths = [])
     {
         $this->paths = (array) $paths;
     }
diff -ru src/Symfony/Component/Config/Loader/FileLoader.php src/Symfony/Component/Config/Loader/FileLoader.php
--- src/Symfony/Component/Config/Loader/FileLoader.php	2021-06-09 11:16:16.890855812 +0000
+++ src/Symfony/Component/Config/Loader/FileLoader.php	2021-06-09 11:16:21.917707423 +0000
@@ -70,7 +70,7 @@
      * @throws FileLoaderImportCircularReferenceException
      * @throws FileLocatorFileNotFoundException
      */
-    public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array|null $exclude = null)
+    public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string | array | null $exclude = null)
     {
         if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && false === strpos($resource, "\n")) {
             $excluded = [];
diff -ru src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php
--- src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php	2021-06-09 11:16:18.584805808 +0000
+++ src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php	2021-06-09 11:16:22.801681328 +0000
@@ -70,7 +70,7 @@
     /**
      * @dataProvider ignoreAndRemoveMatrixProvider
      */
-    public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array|\Exception $expected, string $message = '')
+    public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array | \Exception $expected, string $message = '')
     {
         if ($expected instanceof \Exception) {
             $this->expectException(\get_class($expected));

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
File Permissions

0
Merge Commits

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/41575/a9e75c25bcf3ce9bbb6552d00ef2a0345c21d1a7/exception_messages.diff | patch -p0
diff -ru src/Symfony/Component/Config/Definition/ArrayNode.php src/Symfony/Component/Config/Definition/ArrayNode.php
--- src/Symfony/Component/Config/Definition/ArrayNode.php	2021-06-09 11:16:12.592982682 +0000
+++ src/Symfony/Component/Config/Definition/ArrayNode.php	2021-06-09 11:16:26.102583888 +0000
@@ -203,7 +203,7 @@
     protected function finalizeValue(mixed $value)
     {
         if (false === $value) {
-            throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value)));
+            throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value)));
         }
 
         foreach ($this->children as $name => $child) {
diff -ru src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
--- src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php	2021-06-09 11:16:13.369959746 +0000
+++ src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php	2021-06-09 11:16:26.103583859 +0000
@@ -412,7 +412,7 @@
 
             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()));
+                    throw new \InvalidArgumentException(sprintf('"%s": the default value of an array node has to be an array.', $node->getPath()));
                 }
 
                 $node->setDefaultValue($this->defaultValue);
diff -ru src/Symfony/Component/Config/Definition/PrototypedArrayNode.php src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
--- src/Symfony/Component/Config/Definition/PrototypedArrayNode.php	2021-06-09 11:16:15.657892209 +0000
+++ src/Symfony/Component/Config/Definition/PrototypedArrayNode.php	2021-06-09 11:16:26.103583859 +0000
@@ -168,7 +168,7 @@
     protected function finalizeValue(mixed $value)
     {
         if (false === $value) {
-            throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value)));
+            throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value)));
         }
 
         foreach ($value as $k => $v) {

0
Usage of void in test files

0
Use ::class whenever possible