Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitf0f3e50

Browse files
committed
[Config] Add parameter types
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parentf1372e4 commitf0f3e50

File tree

75 files changed

+271
-388
lines changed

Some content is hidden

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

75 files changed

+271
-388
lines changed

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

Lines 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-
publicfunctionload($resource,string$type =null)
45+
publicfunctionload(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‎

Lines changed: 11 additions & 28 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-
publicfunctionsetNormalizeKeys($normalizeKeys)
35+
publicfunctionsetNormalizeKeys(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-
protectedfunctionpreNormalize($value)
49+
protectedfunctionpreNormalize(mixed$value)
5050
{
5151
if (!$this->normalizeKeys || !\is_array($value)) {
5252
return$value;
@@ -195,16 +195,12 @@ public function addChild(NodeInterface $node)
195195
}
196196

197197
/**
198-
* Finalizes the value of this node.
199-
*
200-
* @param mixed $value
201-
*
202-
* @return mixed The finalised value
198+
* {@inheritdoc}
203199
*
204200
* @throws UnsetKeyException
205201
* @throws InvalidConfigurationException if the node doesn't have enough children
206202
*/
207-
protectedfunctionfinalizeValue($value)
203+
protectedfunctionfinalizeValue(mixed$value)
208204
{
209205
if (false ===$value) {
210206
thrownewUnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.',$this->getPath(),json_encode($value)));
@@ -248,13 +244,9 @@ protected function finalizeValue($value)
248244
}
249245

250246
/**
251-
* Validates the type of the value.
252-
*
253-
* @param mixed $value
254-
*
255-
* @throws InvalidTypeException
247+
* {@inheritdoc}
256248
*/
257-
protectedfunctionvalidateType($value)
249+
protectedfunctionvalidateType(mixed$value)
258250
{
259251
if (!\is_array($value) && (!$this->allowFalse ||false !==$value)) {
260252
$ex =newInvalidTypeException(sprintf('Invalid type for path "%s". Expected "array", but got "%s"',$this->getPath(),get_debug_type($value)));
@@ -268,15 +260,11 @@ protected function validateType($value)
268260
}
269261

270262
/**
271-
* Normalizes the value.
272-
*
273-
* @param mixed $value The value to normalize
274-
*
275-
* @return mixed The normalized value
263+
* {@inheritdoc}
276264
*
277265
* @throws InvalidConfigurationException
278266
*/
279-
protectedfunctionnormalizeValue($value)
267+
protectedfunctionnormalizeValue(mixed$value)
280268
{
281269
if (false ===$value) {
282270
return$value;
@@ -352,17 +340,12 @@ protected function remapXml(array $value)
352340
}
353341

354342
/**
355-
* Merges values together.
356-
*
357-
* @param mixed $leftSide The left side to merge
358-
* @param mixed $rightSide The right side to merge
359-
*
360-
* @return mixed The merged values
343+
* {@inheritdoc}
361344
*
362345
* @throws InvalidConfigurationException
363346
* @throws \RuntimeException
364347
*/
365-
protectedfunctionmergeValues($leftSide,$rightSide)
348+
protectedfunctionmergeValues(mixed$leftSide,mixed$rightSide)
366349
{
367350
if (false ===$rightSide) {
368351
// if this is still false after the last config has been merged the

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

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ public static function resetPlaceholders(): void
9797
self::$placeholders = [];
9898
}
9999

100-
publicfunctionsetAttribute(string$key,$value)
100+
publicfunctionsetAttribute(string$key,mixed$value)
101101
{
102102
$this->attributes[$key] =$value;
103103
}
104104

105105
/**
106106
* @return mixed
107107
*/
108-
publicfunctiongetAttribute(string$key,$default =null)
108+
publicfunctiongetAttribute(string$key,mixed$default =null)
109109
{
110110
return$this->attributes[$key] ??$default;
111111
}
@@ -156,10 +156,8 @@ public function getInfo()
156156

157157
/**
158158
* Sets the example configuration for this node.
159-
*
160-
* @param string|array $example
161159
*/
162-
publicfunctionsetExample($example)
160+
publicfunctionsetExample(string |array$example)
163161
{
164162
$this->setAttribute('example',$example);
165163
}
@@ -176,19 +174,14 @@ public function getExample()
176174

177175
/**
178176
* Adds an equivalent value.
179-
*
180-
* @param mixed $originalValue
181-
* @param mixed $equivalentValue
182177
*/
183-
publicfunctionaddEquivalentValue($originalValue,$equivalentValue)
178+
publicfunctionaddEquivalentValue(mixed$originalValue,mixed$equivalentValue)
184179
{
185180
$this->equivalentValues[] = [$originalValue,$equivalentValue];
186181
}
187182

188183
/**
189184
* Set this node as required.
190-
*
191-
* @param bool $boolean Required node
192185
*/
193186
publicfunctionsetRequired(bool$boolean)
194187
{
@@ -296,7 +289,7 @@ public function getPath()
296289
/**
297290
* {@inheritdoc}
298291
*/
299-
finalpublicfunctionmerge($leftSide,$rightSide)
292+
finalpublicfunctionmerge(mixed$leftSide,mixed$rightSide)
300293
{
301294
if (!$this->allowOverwrite) {
302295
thrownewForbiddenOverwriteException(sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.',$this->getPath()));
@@ -337,7 +330,7 @@ final public function merge($leftSide, $rightSide)
337330
/**
338331
* {@inheritdoc}
339332
*/
340-
finalpublicfunctionnormalize($value)
333+
finalpublicfunctionnormalize(mixed$value)
341334
{
342335
$value =$this->preNormalize($value);
343336

@@ -377,11 +370,9 @@ final public function normalize($value)
377370
/**
378371
* Normalizes the value before any other normalization is applied.
379372
*
380-
* @param mixed $value
381-
*
382373
* @return mixed The normalized array value
383374
*/
384-
protectedfunctionpreNormalize($value)
375+
protectedfunctionpreNormalize(mixed$value)
385376
{
386377
return$value;
387378
}
@@ -399,7 +390,7 @@ public function getParent()
399390
/**
400391
* {@inheritdoc}
401392
*/
402-
finalpublicfunctionfinalize($value)
393+
finalpublicfunctionfinalize(mixed$value)
403394
{
404395
if ($value !==$placeholders =self::resolvePlaceholderValue($value)) {
405396
foreach ($placeholdersas$placeholder) {
@@ -440,39 +431,30 @@ final public function finalize($value)
440431
/**
441432
* Validates the type of a Node.
442433
*
443-
* @param mixed $value The value to validate
444-
*
445434
* @throws InvalidTypeException when the value is invalid
446435
*/
447-
abstractprotectedfunctionvalidateType($value);
436+
abstractprotectedfunctionvalidateType(mixed$value);
448437

449438
/**
450439
* Normalizes the value.
451440
*
452-
* @param mixed $value The value to normalize
453-
*
454441
* @return mixed The normalized value
455442
*/
456-
abstractprotectedfunctionnormalizeValue($value);
443+
abstractprotectedfunctionnormalizeValue(mixed$value);
457444

458445
/**
459446
* Merges two values together.
460447
*
461-
* @param mixed $leftSide
462-
* @param mixed $rightSide
463-
*
464448
* @return mixed The merged value
465449
*/
466-
abstractprotectedfunctionmergeValues($leftSide,$rightSide);
450+
abstractprotectedfunctionmergeValues(mixed$leftSide,mixed$rightSide);
467451

468452
/**
469453
* Finalizes a value.
470454
*
471-
* @param mixed $value The value to finalize
472-
*
473455
* @return mixed The finalized value
474456
*/
475-
abstractprotectedfunctionfinalizeValue($value);
457+
abstractprotectedfunctionfinalizeValue(mixed$value);
476458

477459
/**
478460
* Tests if placeholder values are allowed for this node.
@@ -498,7 +480,7 @@ protected function getValidPlaceholderTypes(): array
498480
return [];
499481
}
500482

501-
privatestaticfunctionresolvePlaceholderValue($value)
483+
privatestaticfunctionresolvePlaceholderValue(mixed$value)
502484
{
503485
if (\is_string($value)) {
504486
if (isset(self::$placeholders[$value])) {
@@ -515,7 +497,7 @@ private static function resolvePlaceholderValue($value)
515497
return$value;
516498
}
517499

518-
privatefunctiondoValidateType($value):void
500+
privatefunctiondoValidateType(mixed$value):void
519501
{
520502
if (null !==$this->handlingPlaceholder && !$this->allowPlaceholders()) {
521503
$e =newInvalidTypeException(sprintf('A dynamic value is not compatible with a "%s" node type at path "%s".',static::class,$this->getPath()));

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

Lines 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-
protectedfunctionvalidateType($value)
26+
protectedfunctionvalidateType(mixed$value)
2727
{
2828
if (!\is_bool($value)) {
2929
$ex =newInvalidTypeException(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-
protectedfunctionisValueEmpty($value)
42+
protectedfunctionisValueEmpty(mixed$value)
4343
{
4444
// a boolean value cannot be empty
4545
returnfalse;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ public function addDefaultsIfNotSet()
150150
*
151151
* This method is applicable to prototype nodes only.
152152
*
153-
* @param int|string|array|null $children The number of children|The child name|The children names to be added
153+
* @param int|array|string|null $children The number of children|The child name|The children names to be added
154154
*
155155
* @return $this
156156
*/
157-
publicfunctionaddDefaultChildrenIfNoneSet($children =null)
157+
publicfunctionaddDefaultChildrenIfNoneSet(int |array |string |null$children =null)
158158
{
159159
$this->addDefaultChildren =$children;
160160

@@ -276,7 +276,7 @@ public function canBeEnabled()
276276
->treatNullLike(['enabled' =>true])
277277
->beforeNormalization()
278278
->ifArray()
279-
->then(function ($v) {
279+
->then(function (array$v) {
280280
$v['enabled'] =$v['enabled'] ??true;
281281

282282
return$v;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp