@@ -29,66 +29,66 @@ class OptionsResolver implements Options
29
29
/**
30
30
* The names of all defined options.
31
31
*/
32
- private $ defined = [] ;
32
+ private $ defined = array () ;
33
33
34
34
/**
35
35
* The default option values.
36
36
*/
37
- private $ defaults = [] ;
37
+ private $ defaults = array () ;
38
38
39
39
/**
40
40
* The names of required options.
41
41
*/
42
- private $ required = [] ;
42
+ private $ required = array () ;
43
43
44
44
/**
45
45
* The resolved option values.
46
46
*/
47
- private $ resolved = [] ;
47
+ private $ resolved = array () ;
48
48
49
49
/**
50
50
* A list of normalizer closures.
51
51
*
52
52
* @var \Closure[]
53
53
*/
54
- private $ normalizers = [] ;
54
+ private $ normalizers = array () ;
55
55
56
56
/**
57
57
* A list of accepted values for each option.
58
58
*/
59
- private $ allowedValues = [] ;
59
+ private $ allowedValues = array () ;
60
60
61
61
/**
62
62
* A list of accepted types for each option.
63
63
*/
64
- private $ allowedTypes = [] ;
64
+ private $ allowedTypes = array () ;
65
65
66
66
/**
67
67
* A list of closures for evaluating lazy options.
68
68
*/
69
- private $ lazy = [] ;
69
+ private $ lazy = array () ;
70
70
71
71
/**
72
72
* A list of lazy options whose closure is currently being called.
73
73
*
74
74
* This list helps detecting circular dependencies between lazy options.
75
75
*/
76
- private $ calling = [] ;
76
+ private $ calling = array () ;
77
77
78
78
/**
79
79
* A list of nested OptionResolvers.
80
80
*/
81
- private $ nested = [] ;
81
+ private $ nested = array () ;
82
82
83
83
/**
84
84
* A list of parent name. Use in exceptions.
85
85
*/
86
- private $ nestedLevelsName = [] ;
86
+ private $ nestedLevelsName = array () ;
87
87
88
88
/**
89
- * A list of resoilve data. Needs for root access from children
89
+ * A list of resoilve data. Needs for root access from children.
90
90
*/
91
- private $ resolvedData = [] ;
91
+ private $ resolvedData = array () ;
92
92
93
93
/**
94
94
* Parent OptionResolver.
@@ -107,11 +107,11 @@ class OptionsResolver implements Options
107
107
*/
108
108
private $ locked = false ;
109
109
110
- private static $ typeAliases = [
110
+ private static $ typeAliases = array (
111
111
'boolean ' => 'bool ' ,
112
112
'integer ' => 'int ' ,
113
113
'double ' => 'float ' ,
114
- ] ;
114
+ ) ;
115
115
116
116
/**
117
117
* Sets the default value of a given option.
@@ -147,7 +147,7 @@ class OptionsResolver implements Options
147
147
* sub-classes.
148
148
*
149
149
* @param string $option The name of the option
150
- * @param mixed $value The default value of the option
150
+ * @param mixed $value The default value of the option
151
151
*
152
152
* @return $this
153
153
*
@@ -171,7 +171,7 @@ public function setDefault($option, $value)
171
171
$ optionsResolver ->setNestedLevelsName (
172
172
array_merge (
173
173
$ this ->getNestedLevelsName (),
174
- [ $ option]
174
+ array ( $ option)
175
175
)
176
176
);
177
177
// Set parent for child OptionResolvers
@@ -198,7 +198,7 @@ public function setDefault($option, $value)
198
198
199
199
// Ignore previous lazy options if the closure has no second parameter
200
200
if (!isset ($ this ->lazy [$ option ]) || !isset ($ params [1 ])) {
201
- $ this ->lazy [$ option ] = [] ;
201
+ $ this ->lazy [$ option ] = array () ;
202
202
}
203
203
204
204
// Store closure for later evaluation
@@ -360,21 +360,21 @@ public function isRequired($option)
360
360
*
361
361
* @see isRequired()
362
362
*/
363
- public function getRequiredOptions (array $ nestedLevel = [] )
363
+ public function getRequiredOptions (array $ nestedLevel = array () )
364
364
{
365
- <
10000
span class="pl-c1">$ requiredOptions = [] ;
365
+ $ requiredOptions = array () ;
366
366
367
367
// Call recursive for all nested OptionResolvers
368
368
foreach ($ this ->nested as $ key => $ nested ) {
369
- if ($ required = $ nested ->getRequiredOptions (array_merge ($ nestedLevel , [ $ key] ))) {
369
+ if ($ required = $ nested ->getRequiredOptions (array_merge ($ nestedLevel , array ( $ key) ))) {
370
370
$ requiredOptions = $ required ;
371
371
}
372
372
}
373
373
374
374
foreach ($ this ->required as $ key => $ item ) {
375
375
// If we in child OptionResolver, return array
376
376
if (count ($ nestedLevel )) {
377
- $ key = array_merge ($ nestedLevel , [ $ key] );
377
+ $ key = array_merge ($ nestedLevel , array ( $ key) );
378
378
}
379
379
$ requiredOptions [] = $ key ;
380
380
}
@@ -421,13 +421,13 @@ public function isMissing($option)
421
421
*
422
422
* @see isMissing()
423
423
*/
424
- public function getMissingOptions (array $ nestedLevel = [] )
424
+ public function getMissingOptions (array $ nestedLevel = array () )
425
425
{
426
- $ missingOptions = [] ;
426
+ $ missingOptions = array () ;
427
427
428
428
// Call recursive for all nested OptionResolvers
429
429
foreach ($ this ->nested as $ key => $ nested ) {
430
- if ($ required = $ nested ->getMissingOptions (array_merge ($ nestedLevel , [ $ key] ))) {
430
+ if ($ required = $ nested ->getMissingOptions (array_merge ($ nestedLevel , array ( $ key) ))) {
431
431
$ missingOptions = $ required ;
432
432
}
433
433
}
@@ -439,7 +439,7 @@ public function getMissingOptions(array $nestedLevel = [])
439
439
440
440
// If we in child OptionResolver, return array
441
441
if (count ($ nestedLevel )) {
442
- $ key = array_merge ($ nestedLevel , [ $ key] );
442
+ $ key = array_merge ($ nestedLevel , array ( $ key) );
443
443
}
444
444
445
445
$ missingOptions [] = $ key ;
@@ -534,21 +534,21 @@ public function isDefined($option)
534
534
*
535
535
* @see isDefined()
536
536
*/
537
- public function getDefinedOptions (array $ nestedLevel = [] )
537
+ public function getDefinedOptions (array $ nestedLevel = array () )
538
538
{
539
- $ definedOptions = [] ;
539
+ $ definedOptions = array () ;
540
540
541
541
// Call recursive for all nested OptionResolvers
542
542
foreach ($ this ->nested as $ key => $ nested ) {
543
- if ($ required = $ nested ->getDefinedOptions (array_merge ($ nestedLevel , [ $ key] ))) {
543
+ if ($ required = $ nested ->getDefinedOptions (array_merge ($ nestedLevel , array ( $ key) ))) {
544
544
$ definedOptions = $ required ;
545
545
}
546
546
}
547
547
548
548
// If we in child OptionResolver, return array
549
549
foreach ($ this ->defined as $ key => $ item ) {
550
550
if (count ($ nestedLevel )) {
551
- $ key = array_merge ($ nestedLevel , [ $ key] );
551
+ $ key = array_merge ($ nestedLevel , array ( $ key) );
552
552
}
553
553
$ definedOptions [] = $ key ;
554
554
}
@@ -576,7 +576,7 @@ public function getDefinedOptions(array $nestedLevel = [])
576
576
*
577
577
* The resolved option value is set to the return value of the closure.
578
578
*
579
- * @param string|string[] $option The option name
579
+ * @param string|string[] $option The option name
580
580
* @param \Closure $normalizer The normalizer
581
581
*
582
582
* @return $this
@@ -645,7 +645,7 @@ public function setNormalizer($option, \Closure $normalizer)
645
645
* The closure receives the value as argument and should return true to
646
646
* accept the value and false to reject the value.
647
647
*
648
- * @param string|string[] $option The option name
648
+ * @param string|string[] $option The option name
649
649
* @param mixed $allowedValues One or more acceptable values/closures
650
650
*
651
651
* @return $this
@@ -693,7 +693,7 @@ public function setAllowedValues($option, $allowedValues)
693
693
));
694
694
}
695
695
696
- $ this ->allowedValues [$ option ] = is_array ($ allowedValues ) ? $ allowedValues : [ $ allowedValues] ;
696
+ $ this ->allowedValues [$ option ] = is_array ($ allowedValues ) ? $ allowedValues : array ( $ allowedValues) ;
697
697
698
698
// Make sure the option is processed
699
699
unset($ this ->resolved [$ option ]);
@@ -716,7 +716,7 @@ public function setAllowedValues($option, $allowedValues)
716
716
* The closure receives the value as argument and should return true to
717
717
* accept the value and false to reject the value.
718
718
*
719
- * @param string|string[] $option The option name
719
+ * @param string|string[] $option The option name
720
720
* @param mixed $allowedValues One or more acceptable values/closures
721
721
*
722
722
* @return $this
@@ -765,7 +765,7 @@ public function addAllowedValues($option, $allowedValues)
765
765
}
766
766
767
767
if (!is_array ($ allowedValues )) {
768
- $ allowedValues = [ $ allowedValues] ;
768
+ $ allowedValues = array ( $ allowedValues) ;
769
769
}
770
770
771
771
if (!isset ($ this ->allowedValues [$ option ])) {
@@ -787,7 +787,7 @@ public function addAllowedValues($option, $allowedValues)
787
787
* acceptable. Additionally, fully-qualified class or interface names may
788
788
* be passed.
789
789
*
790
- * @param string|string[] $option The option name
790
+ * @param string|string[] $option The option name
791
791
* @param string|string[] $allowedTypes One or more accepted types
792
792
*
793
793
* @return $this
@@ -852,7 +852,7 @@ public function setAllowedTypes($option, $allowedTypes)
852
852
* acceptable. Additionally, fully-qualified class or interface names may
853
853
* be passed.
854
854
*
855
- * @param string|string[] $option The option name
855
+ * @param string|string[] $option The option name
856
856
* @param string|string[] $allowedTypes One or more accepted types
857
857
*
858
858
* @return $this
@@ -1012,16 +1012,16 @@ public function clear($options = null)
1012
1012
return $ this ;
1013
1013
}
1014
1014
1015
- $ this ->defined = [] ;
1016
- $ this ->defaults = [] ;
1017
- $ this ->required = [] ;
1018
- $ this ->resolved = [] ;
1019
- $ this ->lazy = [] ;
1020
- $ this ->normalizers = [] ;
1021
- $ this ->allowedTypes = [] ;
1022
- $ this ->allowedValues = [] ;
1023
- $ this ->nested = [] ;
1024
- $ this ->nestedLevelsName = [] ;
1015
+ $ this ->defined = array () ;
1016
+ $ this ->defaults = array () ;
1017
+ $ this ->required = array () ;
1018
+ $ this ->resolved = array () ;
1019
+ $ this ->lazy = array () ;
1020
+ $ this ->normalizers = array () ;
1021
+ $ this ->allowedTypes = array () ;
1022
+ $ this ->allowedValues = array () ;
1023
+ $ this ->nested = array () ;
1024
+ $ this ->nestedLevelsName = array () ;
1025
1025
1026
1026
return $ this ;
1027
1027
}
@@ -1050,7 +1050,7 @@ public function clear($options = null)
1050
1050
* @throws NoSuchOptionException If a lazy option reads an unavailable option
1051
1051
* @throws AccessException If called from a lazy option or normalizer
1052
1052
*/
1053
- public function resolve (array $ options = [] )
1053
+ public function resolve (array $ options = array () )
1054
1054
{
1055
1055
if ($ this ->locked ) {
1056
1056
throw new AccessException ('Options cannot be resolved from a lazy option or normalizer. ' );
@@ -1120,7 +1120,7 @@ public function resolve(array $options = [])
1120
1120
// If there are nested entities, then we pass them
1121
1121
if (count ($ this ->nested )) {
1122
1122
foreach ($ this ->nested as $ option => $ item ) {
1123
- $ clone ->resolved [$ option ] = $ item ->resolve ($ options [$ option ] ?? [] );
1123
+ $ clone ->resolved [$ option ] = $ item ->resolve ($ options [$ option ] ?? array () );
1124
1124
}
1125
1125
}
1126
1126
@@ -1143,11 +1143,12 @@ public function resolve(array $options = [])
1143
1143
/**
1144
1144
* Last step for resolve data
1145
1145
* If there are closures without resolve, we tried to resolve it with finish data
1146
- * It needs when we want need access to parents resolver from nested resolvers
1146
+ * It needs when we want need access to parents resolver from nested resolvers.
1147
1147
*
1148
1148
* @param array $data
1149
1149
*
1150
1150
* @return array
1151
+ *
1151
1152
* @throws \ReflectionException
1152
1153
*/
1153
1154
private function rezolveParentAccess (array $ data )
@@ -1255,7 +1256,7 @@ public function offsetGet($option)
1255
1256
// Validate the type of the resolved option
1256
1257
if (isset ($ this ->allowedTypes [$ option ])) {
1257
1258
$ valid = false ;
1258
- $ invalidTypes = [] ;
1259
+ $ invalidTypes = array () ;
1259
1260
1260
1261
foreach ($ this ->allowedTypes [$ option ] as $ type ) {
1261
1262
$ type = isset (self ::$ typeAliases [$ type ]) ? self ::$ typeAliases [$ type ] : $ type ;
@@ -1283,7 +1284,7 @@ public function offsetGet($option)
1283
1284
// Validate the value of the resolved option
1284
1285
if (isset ($ this ->allowedValues [$ option ])) {
1285
1286
$ success = false ;
1286
- $ printableAllowedValues = [] ;
1287
+ $ printableAllowedValues = array () ;
1287
1288
1288
1289
foreach ($ this ->allowedValues [$ option ] as $ allowedValue ) {
1289
1290
if ($ allowedValue instanceof \Closure) {
@@ -1522,7 +1523,7 @@ private function formatTypeOf($value, ?string $type): string
1522
1523
}
1523
1524
1524
1525
if (is_array ($ value )) {
1525
- $ subTypes = [] ;
1526
+ $ subTypes = array () ;
1526
1527
foreach ($ value as $ val ) {
1527
1528
$ subTypes [$ this ->formatTypeOf ($ val , null )] = true ;
1528
1529
}
0 commit comments