@@ -30,68 +30,68 @@ class OptionsResolver implements Options
30
30
/**
31
31
* The names of all defined options.
32
32
*/
33
- private $ defined = array () ;
33
+ private $ defined = [] ;
34
34
35
35
/**
36
36
* The default option values.
37
37
*/
38
- private $ defaults = array () ;
38
+ private $ defaults = [] ;
39
39
40
40
/**
41
41
* A list of closure for nested options.
42
42
*
43
43
* @var \Closure[][]
44
44
*/
45
- private $ nested = array () ;
45
+ private $ nested = [] ;
46
46
47
47
/**
48
48
* The names of required options.
49
49
*/
50
- private $ required = array () ;
50
+ private $ required = [] ;
51
51
52
52
/**
53
53
* The resolved option values.
54
54
*/
55
- private $ resolved = array () ;
55
+ private $ resolved = [] ;
56
56
57
57
/**
58
58
* A list of normalizer closures.
59
59
*
60
60
* @var \Closure[]
61
61
*/
62
- private $ normalizers = array () ;
62
+ private $ normalizers = [] ;
63
63
64
64
/**
65
65
* A list of accepted values for each option.
66
66
*/
67
- private $ allowedValues = array () ;
67
+ private $ allowedValues = [] ;
68
68
69
69
/**
70
70
* A list of accepted types for each option.
71
71
*/
72
- private $ allowedTypes = array () ;
72
+ private $ allowedTypes = [] ;
73
73
74
74
/**
75
75
* A list of closures for evaluating lazy options.
76
76
*/
77
- private $ lazy = array () ;
77
+ private $ lazy = [] ;
78
78
79
79
/**
80
80
* A list of lazy options whose closure is currently being called.
81
81
*
82
82
* This list helps detecting circular dependencies between lazy options.
83
83
*/
84
- private $ calling = array () ;
84
+ private $ calling = [] ;
85
85
86
86
/**
87
87
* A list of deprecated options.
88
88
*/
89
- private $ deprecated = array () ;
89
+ private $ deprecated = [] ;
90
90
91
91
/**
92
92
* The list of options provided by the user.
93
93
*/
94
- private $ given = array () ;
94
+ private $ given = [] ;
95
95
96
96
/**
97
97
* Whether the instance is locked for reading.
@@ -103,11 +103,11 @@ class OptionsResolver implements Options
103
103
*/
104
104
private $ locked = false ;
105
105
106
- private static $ typeAliases = array (
106
+ private static $ typeAliases = [
107
107
'boolean ' => 'bool ' ,
108
108
'integer ' => 'int ' ,
109
109
'double ' => 'float ' ,
110
- ) ;
110
+ ] ;
111
111
112
112
/**
113
113
* Sets the default value of a given option.
@@ -146,7 +146,7 @@ class OptionsResolver implements Options
146
146
* following signature:
147
147
*
148
148
* $options->setDefault('database', function (OptionsResolver $resolver) {
149
- * $resolver->setDefined(array( 'dbname', 'host', 'port', 'user', 'pass') );
149
+ * $resolver->setDefined([ 'dbname', 'host', 'port', 'user', 'pass'] );
150
150
* }
151
151
*
152
152
* To get access to the parent options, add a second argument to the closure's
@@ -186,7 +186,7 @@ public function setDefault($option, $value)
186
186
187
187
// Ignore previous lazy options if the closure has no second parameter
188
188
if (!isset ($ this ->lazy [$ option ]) || !isset ($ params [1 ])) {
189
- $ this ->lazy [$ option ] = array () ;
189
+ $ this ->lazy [$ option ] = [] ;
190
190
}
191
191
192
192
// Store closure for later evaluation
@@ -202,7 +202,7 @@ public function setDefault($option, $value)
202
202
if (isset ($ params [0 ]) && null !== ($ class = $ params [0 ]->getClass ()) && self ::class === $ class ->name && (!isset ($ params [1 ]) || (null !== ($ class = $ params [1 ]->getClass ()) && Options::class === $ class ->name ))) {
203
203
// Store closure for later evaluation
204
204
$ this ->nested [$ option ][] = $ value ;
205
- $ this ->defaults [$ option ] = array () ;
205
+ $ this ->defaults [$ option ] = [] ;
206
206
$ this ->defined [$ option ] = true ;
207
207
208
208
// Make sure the option is processed and is not lazy anymore
@@ -523,7 +523,7 @@ public function setAllowedValues($option, $allowedValues)
523
523
throw new UndefinedOptionsException (sprintf ('The option "%s" does not exist. Defined options are: "%s". ' , $ option , implode ('", " ' , array_keys ($ this ->defined ))));
524
524
}
525
525
526
- $ this ->allowedValues [$ option ] = \is_array ($ allowedValues ) ? $ allowedValues : array ( $ allowedValues) ;
526
+ $ this ->allowedValues [$ option ] = \is_array ($ allowedValues ) ? $ allowedValues : [ $ allowedValues] ;
527
527
528
528
// Make sure the option is processed
529
529
unset($ this ->resolved [$ option ]);
@@ -565,7 +565,7 @@ public function addAllowedValues($option, $allowedValues)
565
565
}
566
566
567
567
if (!\is_array ($ allowedValues )) {
568
- $ allowedValues = array ( $ allowedValues) ;
568
+ $ allowedValues = [ $ allowedValues] ;
569
569
}
570
570
571
571
if (!isset ($ this ->allowedValues [$ option ])) {
@@ -690,16 +690,16 @@ public function clear()
690
690
throw new AccessException ('Options cannot be cleared from a lazy option or normalizer. ' );
691
691
}
692
692
693
- $ this ->defined = array () ;
694
- $ this ->defaults = array () ;
695
- $ this ->nested = array () ;
696
- $ this ->required = array () ;
697
- $ this ->resolved = array () ;
698
- $ this ->lazy = array () ;
699
- $ this ->normalizers = array () ;
700
- $ this ->allowedTypes = array () ;
701
- $ this ->allowedValues = array () ;
702
- $ this ->deprecated = array () ;
693
+ $ this ->defined = [] ;
694
+ $ this ->defaults = [] ;
695
+ $ this ->nested = [] ;
696
+ $ this ->required = [] ;
697
+ $ this ->resolved = [] ;
698
+ $ this ->lazy = [] ;
699
+ $ this ->normalizers = [] ;
700
+ $ this ->allowedTypes = [] ;
701
+ $ this ->allowedValues = [] ;
702
+ $ this ->deprecated = [] ;
703
703
704
704
return $ this ;
705
705
}
@@ -728,7 +728,7 @@ public function clear()
728
728
* @throws NoSuchOptionException If a lazy option reads an unavailable option
729
729
* @throws AccessException If called from a lazy option or normalizer
730
730
*/
731
- public function resolve (array $ options = array () )
731
+ public function resolve (array $ options = [] )
732
732
{
733
733
if ($ this ->locked ) {
734
734
throw new AccessException ('Options cannot be resolved from a lazy option or normalizer. ' );
@@ -802,7 +802,7 @@ public function offsetGet($option/*, bool $triggerDeprecation = true*/)
802
802
// Shortcut for resolved options
803
803
if (isset ($ this ->resolved [$ option ]) || array_key_exists ($ option , $ this ->resolved )) {
804
804
if ($ triggerDeprecation && isset ($ this ->deprecated [$ option ]) && (isset ($ this ->given [$ option ]) || $ this ->calling ) && \is_string ($ this ->deprecated [$ option ])) {
805
- @trigger_error (strtr ($ this ->deprecated [$ option ], array ( '%name% ' => $ option) ), E_USER_DEPRECATED );
805
+ @trigger_error (strtr ($ this ->deprecated [$ option ], [ '%name% ' => $ option] ), E_USER_DEPRECATED );
806
806
}
807
807
808
808
return $ this ->resolved [$ option ];
@@ -869,7 +869,7 @@ public function offsetGet($option/*, bool $triggerDeprecation = true*/)
869
869
// Validate the type of the resolved option
870
870
if (isset ($ this ->allowedTypes [$ option ])) {
871
871
$ valid = false ;
872
- $ invalidTypes = array () ;
872
+ $ invalidTypes = [] ;
873
873
874
874
foreach ($ this ->allowedTypes [$ option ] as $ type ) {
875
875
$ type = self ::$ typeAliases [$ type ] ?? $ type ;
@@ -893,7 +893,7 @@ public function offsetGet($option/*, bool $triggerDeprecation = true*/)
893
893
// Validate the value of the resolved option
894
894
if (isset ($ this ->allowedValues [$ option ])) {
895
895
$ success = false ;
896
- $ printableAllowedValues = array () ;
896
+ $ printableAllowedValues = [] ;
897
897
898
898
foreach ($ this ->allowedValues [$ option ] as $ allowedValue ) {
899
899
if ($ allowedValue instanceof \Closure) {
@@ -954,7 +954,7 @@ public function offsetGet($option/*, bool $triggerDeprecation = true*/)
954
954
}
955
955
956
956
if ('' !== $ deprecationMessage ) {
957
- @trigger_error (strtr ($ deprecationMessage , array ( '%name% ' => $ option) ), E_USER_DEPRECATED );
957
+ @trigger_error (strtr ($ deprecationMessage , [ '%name% ' => $ option] ), E_USER_DEPRECATED );
958
958
}
959
959
}
960
960
0 commit comments