Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76ee4a5

Browse filesBrowse files
minor #41575 [Config] Add parameter types (derrabus)
This PR was merged into the 6.0 branch. Discussion ---------- [Config] Add parameter types | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Part of #41424 | License | MIT | Doc PR | N/A This PR adds parameter types to all methods of the Config component. Commits ------- e7e5256 [Config] Add parameter types
2 parents ff940a0 + e7e5256 commit 76ee4a5
Copy full SHA for 76ee4a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

50 files changed

+98
-141
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(LoaderResolverInterface $resolver, array $defaultOpt
4242
/**
4343
* {@inheritdoc}
4444
*/
45-
public function load($resource, string $type = null)
45+
public function load(mixed $resource, string $type = null)
4646
{
4747
if ($this->loading) {
4848
// This can happen if a fatal error occurs in parent::load().

‎src/Symfony/Component/Config/Definition/ArrayNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/ArrayNode.php
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
3232
protected $removeExtraKeys = true;
3333
protected $normalizeKeys = true;
3434

35-
public function setNormalizeKeys($normalizeKeys)
35+
public function setNormalizeKeys(bool $normalizeKeys)
3636
{
37-
$this->normalizeKeys = (bool) $normalizeKeys;
37+
$this->normalizeKeys = $normalizeKeys;
3838
}
3939

4040
/**
@@ -46,7 +46,7 @@ public function setNormalizeKeys($normalizeKeys)
4646
* If you have a mixed key like foo-bar_moo, it will not be altered.
4747
* The key will also not be altered if the target key already exists.
4848
*/
49-
protected function preNormalize($value)
49+
protected function preNormalize(mixed $value)
5050
{
5151
if (!$this->normalizeKeys || !\is_array($value)) {
5252
return $value;
@@ -200,7 +200,7 @@ public function addChild(NodeInterface $node)
200200
* @throws UnsetKeyException
201201
* @throws InvalidConfigurationException if the node doesn't have enough children
202202
*/
203-
protected function finalizeValue($value)
203+
protected function finalizeValue(mixed $value)
204204
{
205205
if (false === $value) {
206206
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value)));
@@ -246,7 +246,7 @@ protected function finalizeValue($value)
246246
/**
247247
* {@inheritdoc}
248248
*/
249-
protected function validateType($value)
249+
protected function validateType(mixed $value)
250250
{
251251
if (!\is_array($value) && (!$this->allowFalse || false !== $value)) {
252252
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), get_debug_type($value)));
@@ -264,7 +264,7 @@ protected function validateType($value)
264264
*
265265
* @throws InvalidConfigurationException
266266
*/
267-
protected function normalizeValue($value)
267+
protected function normalizeValue(mixed $value)
268268
{
269269
if (false === $value) {
270270
return $value;
@@ -345,7 +345,7 @@ protected function remapXml(array $value)
345345
* @throws InvalidConfigurationException
346346
* @throws \RuntimeException
347347
*/
348-
protected function mergeValues($leftSide, $rightSide)
348+
protected function mergeValues(mixed $leftSide, mixed $rightSide)
349349
{
350350
if (false === $rightSide) {
351351
// if this is still false after the last config has been merged the

‎src/Symfony/Component/Config/Definition/BooleanNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/BooleanNode.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BooleanNode extends ScalarNode
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
protected function validateType($value)
26+
protected function validateType(mixed $value)
2727
{
2828
if (!\is_bool($value)) {
2929
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "bool", but got "%s".', $this->getPath(), get_debug_type($value)));
@@ -39,7 +39,7 @@ protected function validateType($value)
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
protected function isValueEmpty($value)
42+
protected function isValueEmpty(mixed $value)
4343
{
4444
// a boolean value cannot be empty
4545
return false;

‎src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function addDefaultsIfNotSet()
154154
*
155155
* @return $this
156156
*/
157-
public function addDefaultChildrenIfNoneSet($children = null)
157+
public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null)
158158
{
159159
$this->addDefaultChildren = $children;
160160

‎src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ abstract class NumericNodeDefinition extends ScalarNodeDefinition
2626
/**
2727
* Ensures that the value is smaller than the given reference.
2828
*
29-
* @param int|float $max
30-
*
3129
* @return $this
3230
*
3331
* @throws \InvalidArgumentException when the constraint is inconsistent
3432
*/
35-
public function max($max)
33+
public function max(int|float $max)
3634
{
3735
if (isset($this->min) && $this->min > $max) {
3836
throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min));
@@ -45,13 +43,11 @@ public function max($max)
4543
/**
4644
* Ensures that the value is bigger than the given reference.
4745
*
48-
* @param int|float $min
49-
*
5046
* @return $this
5147
*
5248
* @throws \InvalidArgumentException when the constraint is inconsistent
5349
*/
54-
public function min($min)
50+
public function min(int|float $min)
5551
{
5652
if (isset($this->max) && $this->max < $min) {
5753
throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max));

‎src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,8 @@ private function writeLine(string $text, int $indent = 0)
268268

269269
/**
270270
* Renders the string conversion of the value.
271-
*
272-
* @param mixed $value
273271
*/
274-
private function writeValue($value): string
272+
private function writeValue(mixed $value): string
275273
{
276274
if ('%%%%not_defined%%%%' === $value) {
277275
return '';

‎src/Symfony/Component/Config/Definition/EnumNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/EnumNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getValues()
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
protected function finalizeValue($value)
44+
protected function finalizeValue(mixed $value)
4545
{
4646
$value = parent::finalizeValue($value);
4747

‎src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class InvalidConfigurationException extends Exception
2222
private $path;
2323
private $containsHints = false;
2424

25-
public function setPath($path)
25+
public function setPath(string $path)
2626
{
2727
$this->path = $path;
2828
}

‎src/Symfony/Component/Config/Definition/FloatNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/FloatNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FloatNode extends NumericNode
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
protected function validateType($value)
26+
protected function validateType(mixed $value)
2727
{
2828
// Integers are also accepted, we just cast them
2929
if (\is_int($value)) {

‎src/Symfony/Component/Config/Definition/IntegerNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/IntegerNode.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class IntegerNode extends NumericNode
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
protected function validateType($value)
26+
protected function validateType(mixed $value)
2727
{
2828
if (!\is_int($value)) {
2929
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "int", but got "%s".', $this->getPath(), get_debug_type($value)));

‎src/Symfony/Component/Config/Definition/NodeInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/NodeInterface.php
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,36 +65,29 @@ public function getDefaultValue();
6565
/**
6666
* Normalizes a value.
6767
*
68-
* @param mixed $value The value to normalize
69-
*
7068
* @return mixed The normalized value
7169
*
7270
* @throws InvalidTypeException if the value type is invalid
7371
*/
74-
public function normalize($value);
72+
public function normalize(mixed $value);
7573

7674
/**
7775
* Merges two values together.
7876
*
79-
* @param mixed $leftSide
80-
* @param mixed $rightSide
81-
*
8277
* @return mixed The merged value
8378
*
8479
* @throws ForbiddenOverwriteException if the configuration path cannot be overwritten
8580
* @throws InvalidTypeException if the value type is invalid
8681
*/
87-
public function merge($leftSide, $rightSide);
82+
public function merge(mixed $leftSide, mixed $rightSide);
8883

8984
/**
9085
* Finalizes a value.
9186
*
92-
* @param mixed $value The value to finalize
93-
*
9487
* @return mixed The finalized value
9588
*
9689
* @throws InvalidTypeException if the value type is invalid
9790
* @throws InvalidConfigurationException if the value is invalid configuration
9891
*/
99-
public function finalize($value);
92+
public function finalize(mixed $value);
10093
}

‎src/Symfony/Component/Config/Definition/NumericNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/NumericNode.php
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ class NumericNode extends ScalarNode
2323
protected $min;
2424
protected $max;
2525

26-
/**
27-
* @param int|float|null $min
28-
* @param int|float|null $max
29-
*/
30-
public function __construct(?string $name, NodeInterface $parent = null, $min = null, $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
26+
public function __construct(?string $name, NodeInterface $parent = null, int|float|null $min = null, int|float|null $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR)
3127
{
3228
parent::__construct($name, $parent, $pathSeparator);
3329
$this->min = $min;
@@ -37,7 +33,7 @@ public function __construct(?string $name, NodeInterface $parent = null, $min =
3733
/**
3834
* {@inheritdoc}
3935
*/
40-
protected function finalizeValue($value)
36+
protected function finalizeValue(mixed $value)
4137
{
4238
$value = parent::finalizeValue($value);
4339

@@ -60,7 +56,7 @@ protected function finalizeValue($value)
6056
/**
6157
* {@inheritdoc}
6258
*/
63-
protected function isValueEmpty($value)
59+
protected function isValueEmpty(mixed $value)
6460
{
6561
// a numeric value cannot be empty
6662
return false;

‎src/Symfony/Component/Config/Definition/PrototypedArrayNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function hasDefaultValue()
104104
*
105105
* @param int|string|array|null $children The number of children|The child name|The children names to be added
106106
*/
107-
public function setAddChildrenIfNoneSet($children = ['defaults'])
107+
public function setAddChildrenIfNoneSet(int|string|array|null $children = ['defaults'])
108108
{
109109
if (null === $children) {
110110
$this->defaultChildren = ['defaults'];
@@ -165,7 +165,7 @@ public function addChild(NodeInterface $node)
165165
/**
166166
* {@inheritdoc}
167167
*/
168-
protected function finalizeValue($value)
168+
protected function finalizeValue(mixed $value)
169169
{
170170
if (false === $value) {
171171
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value)));
@@ -195,7 +195,7 @@ protected function finalizeValue($value)
195195
*
196196
* @throws DuplicateKeyException
197197
*/
198-
protected function normalizeValue($value)
198+
protected function normalizeValue(mixed $value)
199199
{
200200
if (false === $value) {
201201
return $value;
@@ -262,7 +262,7 @@ protected function normalizeValue($value)
262262
/**
263263
* {@inheritdoc}
264264
*/
265-
protected function mergeValues($leftSide, $rightSide)
265+
protected function mergeValues(mixed $leftSide, mixed $rightSide)
266266
{
267267
if (false === $rightSide) {
268268
// if this is still false after the last config has been merged the

‎src/Symfony/Component/Config/Definition/ScalarNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/ScalarNode.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ScalarNode extends VariableNode
3030
/**
3131
* {@inheritdoc}
3232
*/
33-
protected function validateType($value)
33+
protected function validateType(mixed $value)
3434
{
3535
if (!is_scalar($value) && null !== $value) {
3636
$ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "scalar", but got "%s".', $this->getPath(), get_debug_type($value)));
@@ -46,7 +46,7 @@ protected function validateType($value)
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
protected function isValueEmpty($value)
49+
protected function isValueEmpty(mixed $value)
5050
{
5151
// assume environment variables are never empty (which in practice is likely to be true during runtime)
5252
// not doing so breaks many configs that are valid today

‎src/Symfony/Component/Config/Definition/VariableNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/VariableNode.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface
2727
protected $defaultValue;
2828
protected $allowEmptyValue = true;
2929

30-
public function setDefaultValue($value)
30+
public function setDefaultValue(mixed $value)
3131
{
3232
$this->defaultValueSet = true;
3333
$this->defaultValue = $value;
@@ -72,14 +72,14 @@ public function setName(string $name)
7272
/**
7373
* {@inheritdoc}
7474
*/
75-
protected function validateType($value)
75+
protected function validateType(mixed $value)
7676
{
7777
}
7878

7979
/**
8080
* {@inheritdoc}
8181
*/
82-
protected function finalizeValue($value)
82+
protected function finalizeValue(mixed $value)
8383
{
8484
// deny environment variables only when using custom validators
8585
// this avoids ever passing an empty value to final validation closures
@@ -109,15 +109,15 @@ protected function finalizeValue($value)
109109
/**
110110
* {@inheritdoc}
111111
*/
112-
protected function normalizeValue($value)
112+
protected function normalizeValue(mixed $value)
113113
{
114114
return $value;
115115
}
116116

117117
/**
118118
* {@inheritdoc}
119119
*/
120-
protected function mergeValues($leftSide, $rightSide)
120+
protected function mergeValues(mixed $leftSide, mixed $rightSide)
121121
{
122122
return $rightSide;
123123
}
@@ -129,13 +129,11 @@ protected function mergeValues($leftSide, $rightSide)
129129
* method may be overridden by subtypes to better match their understanding
130130
* of empty data.
131131
*
132-
* @param mixed $value
133-
*
134132
* @return bool
135133
*
136134
* @see finalizeValue()
137135
*/
138-
protected function isValueEmpty($value)
136+
protected function isValueEmpty(mixed $value)
139137
{
140138
return empty($value);
141139
}

‎src/Symfony/Component/Config/Exception/LoaderLoadException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Exception/LoaderLoadException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(string $resource, string $sourceResource = null, int
7373
parent::__construct($message, $code, $previous);
7474
}
7575

76-
protected function varToString($var)
76+
protected function varToString(mixed $var)
7777
{
7878
if (\is_object($var)) {
7979
return sprintf('Object(%s)', \get_class($var));

‎src/Symfony/Component/Config/FileLocator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/FileLocator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FileLocator implements FileLocatorInterface
2525
/**
2626
* @param string|string[] $paths A path or an array of paths where to look for resources
2727
*/
28-
public function __construct($paths = [])
28+
public function __construct(string|array $paths = [])
2929
{
3030
$this->paths = (array) $paths;
3131
}

‎src/Symfony/Component/Config/Loader/DelegatingLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Loader/DelegatingLoader.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(LoaderResolverInterface $resolver)
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function load($resource, string $type = null)
34+
public function load(mixed $resource, string $type = null)
3535
{
3636
if (false === $loader = $this->resolver->resolve($resource, $type)) {
3737
throw new LoaderLoadException($resource, null, 0, null, $type);
@@ -43,7 +43,7 @@ public function load($resource, string $type = null)
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function supports($resource, string $type = null)
46+
public function supports(mixed $resource, string $type = null)
4747
{
4848
return false !== $this->resolver->resolve($resource, $type);
4949
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.