@@ -187,14 +187,11 @@ class OptionsResolver implements Options
187
187
* // 'default' === $parent['connection']
188
188
* }
189
189
*
190
- * @param string $option The name of the option
191
- * @param mixed $value The default value of the option
192
- *
193
190
* @return $this
194
191
*
195
192
* @throws AccessException If called from a lazy option or normalizer
196
193
*/
197
- public function setDefault (string $ option , $ value )
194
+ public function setDefault (string $ option , mixed $ value )
198
195
{
199
196
// Setting is not possible once resolving starts, because then lazy
200
197
// options could manipulate the state of the object, leading to
@@ -263,8 +260,6 @@ public function setDefault(string $option, $value)
263
260
/**
264
261
* Sets a list of default values.
265
262
*
266
- * @param array $defaults The default values to set
267
- *
268
263
* @return $this
269
264
*
270
265
* @throws AccessException If called from a lazy option or normalizer
@@ -284,8 +279,6 @@ public function setDefaults(array $defaults)
284
279
* Returns true if {@link setDefault()} was called for this option.
285
280
* An option is also considered set if it was set to null.
286
281
*
287
- * @param string $option The option name
288
- *
289
282
* @return bool Whether a default value is set
290
283
*/
291
284
public function hasDefault (string $ option )
@@ -302,7 +295,7 @@ public function hasDefault(string $option)
302
295
*
303
296
* @throws AccessException If called from a lazy option or normalizer
304
297
*/
305
- public function setRequired ($ optionNames )
298
+ public function setRequired (string | array $ optionNames )
306
299
{
307
300
if ($ this ->locked ) {
308
301
throw new AccessException ('Options cannot be made required from a lazy option or normalizer. ' );
@@ -321,8 +314,6 @@ public function setRequired($optionNames)
321
314
*
322
315
* An option is required if it was passed to {@link setRequired()}.
323
316
*
324
- * @param string $option The name of the option
325
- *
326
317
* @return bool Whether the option is required
327
318
*/
328
319
public function isRequired (string $ option )
@@ -349,8 +340,6 @@ public function getRequiredOptions()
349
340
* to {@link setDefault()}. This option must be passed explicitly to
350
341
* {@link resolve()}, otherwise an exception will be thrown.
351
342
*
352
- * @param string $option The name of the option
353
- *
354
343
* @return bool Whether the option is missing
355
344
*/
356
345
public function isMissing (string $ option )
@@ -383,7 +372,7 @@ public function getMissingOptions()
383
372
*
384
373
* @throws AccessException If called from a lazy option or normalizer
385
374
*/
386
- public function setDefined ($ optionNames )
375
+ public function setDefined (string | array $ optionNames )
387
376
{
388
377
if ($ this ->locked ) {
389
378
throw new AccessException ('Options cannot be defined from a lazy option or normalizer. ' );
@@ -402,8 +391,6 @@ public function setDefined($optionNames)
402
391
* Returns true for any option passed to {@link setDefault()},
403
392
* {@link setRequired()} or {@link setDefined()}.
404
393
*
405
- * @param string $option The option name
406
- *
407
394
* @return bool Whether the option is defined
408
395
*/
409
396
public function isDefined (string $ option )
@@ -449,7 +436,7 @@ public function isNested(string $option): bool
449
436
* @param string $version The version of the package that introduced the deprecation
450
437
* @param string|\Closure $message The deprecation message to use
451
438
*/
452
- public function setDeprecated (string $ option , string $ package , string $ version , $ message = 'The option "%name%" is deprecated. ' ): self
439
+ public function setDeprecated (string $ option , string $ package , string $ version , string | \ Closure $ message = 'The option "%name%" is deprecated. ' ): self
453
440
{
454
441
if ($ this ->locked ) {
455
442
throw new AccessException ('Options cannot be deprecated from a lazy option or normalizer. ' );
@@ -503,9 +490,6 @@ public function isDeprecated(string $option): bool
503
490
*
504
491
* The resolved option value is set to the return value of the closure.
505
492
*
506
- * @param string $option The option name
507
- * @param \Closure $normalizer The normalizer
508
- *
509
493
* @return $this
510
494
*
511
495
* @throws UndefinedOptionsException If the option is undefined
@@ -547,10 +531,6 @@ public function setNormalizer(string $option, \Closure $normalizer)
547
531
*
548
532
* The resolved option value is set to the return value of the closure.
549
533
*
550
- * @param string $option The option name
551
- * @param \Closure $normalizer The normalizer
552
- * @param bool $forcePrepend If set to true, prepend instead of appending
553
- *
554
534
* @return $this
555
535
*
556
536
* @throws UndefinedOptionsException If the option is undefined
@@ -592,15 +572,14 @@ public function addNormalizer(string $option, \Closure $normalizer, bool $forceP
592
572
* The closure receives the value as argument and should return true to
593
573
* accept the value and false to reject the value.
594
574
*
595
- * @param string $option The option name
596
- * @param mixed $allowedValues One or more acceptable values/closures
575
+ * @param mixed $allowedValues One or more acceptable values/closures
597
576
*
598
577
* @return $this
599
578
*
600
579
* @throws UndefinedOptionsException If the option is undefined
601
580
* @throws AccessException If called from a lazy option or normalizer
602
581
*/
603
- public function setAllowedValues (string $ option , $ allowedValues )
582
+ public function setAllowedValues (string $ option , mixed $ allowedValues )
604
583
{
605
584
if ($ this ->locked ) {
606
585
throw new AccessException ('Allowed values cannot be set from a lazy option or normalizer. ' );
@@ -633,15 +612,14 @@ public function setAllowedValues(string $option, $allowedValues)
633
612
* The closure receives the value as argument and should return true to
634
613
* accept the value and false to reject the value.
635
614
*
636
- * @param string $option The option name
637
- * @param mixed $allowedValues One or more acceptable values/closures
615
+ * @param mixed $allowedValues One or more acceptable values/closures
638
616
*
639
617
* @return $this
640
618
*
641
619
* @throws UndefinedOptionsException If the option is undefined
642
620
* @throws AccessException If called from a lazy option or normalizer
643
621
*/
644
- public function addAllowedValues (string $ option , $ allowedValues )
622
+ public function addAllowedValues (string $ option , mixed $ allowedValues )
645
623
{
646
624
if ($ this ->locked ) {
647
625
throw new AccessException ('Allowed values cannot be added from a lazy option or normalizer. ' );
@@ -674,15 +652,14 @@ public function addAllowedValues(string $option, $allowedValues)
674
652
* acceptable. Additionally, fully-qualified class or interface names may
675
653
* be passed.
676
654
*
677
- * @param string $option The option name
678
655
* @param string|string[] $allowedTypes One or more accepted types
679
656
*
680
657
* @return $this
681
658
*
682
659
* @throws UndefinedOptionsException If the option is undefined
683
660
* @throws AccessException If called from a lazy option or normalizer
684
661
*/
685
- public function setAllowedTypes (string $ option , $ allowedTypes )
662
+ public function setAllowedTypes (string $ option , string | array $ allowedTypes )
686
663
{
687
664
if ($ this ->locked ) {
688
665
throw new AccessException ('Allowed types cannot be set from a lazy option or normalizer. ' );
@@ -709,15 +686,14 @@ public function setAllowedTypes(string $option, $allowedTypes)
709
686
* acceptable. Additionally, fully-qualified class or interface names may
710
687
* be passed.
711
688
*
712
- * @param string $option The option name
713
689
* @param string|string[] $allowedTypes One or more accepted types
714
690
*
715
691
* @return $this
716
692
*
717
693
* @throws UndefinedOptionsException If the option is undefined
718
694
* @throws AccessException If called from a lazy option or normalizer
719
695
*/
720
- public function addAllowedTypes (string $ option , $ allowedTypes )
696
+ public function addAllowedTypes (string $ option , string | array $ allowedTypes )
721
697
{
722
698
if ($ this ->locked ) {
723
699
throw new AccessException ('Allowed types cannot be added from a lazy option or normalizer. ' );
@@ -824,7 +800,7 @@ public function isPrototype(): bool
824
800
*
825
801
* @throws AccessException If called from a lazy option or normalizer
826
802
*/
827
- public function remove ($ optionNames )
803
+ public function remove (string | array $ optionNames )
828
804
{
829
805
if ($ this ->locked ) {
830
806
throw new AccessException ('Options cannot be removed from a lazy option or normalizer. ' );
@@ -877,8 +853,6 @@ public function clear()
877
853
* - Options have invalid types;
878
854
* - Options have invalid values.
879
855
*
880
- * @param array $options A map of option names to values
881
- *
882
856
* @return array The merged and validated options
883
857
*
884
858
* @throws UndefinedOptionsException If an option name is undefined
@@ -940,8 +914,7 @@ public function resolve(array $options = [])
940
914
/**
941
915
* Returns the resolved value of an option.
942
916
*
943
- * @param string $option The option name
944
- * @param bool $triggerDeprecation Whether to trigger the deprecation or not (true by default)
917
+ * @param bool $triggerDeprecation Whether to trigger the deprecation or not (true by default)
945
918
*
946
919
* @return mixed The option value
947
920
*
@@ -953,7 +926,7 @@ public function resolve(array $options = [])
953
926
* @throws OptionDefinitionException If there is a cyclic dependency between
954
927
* lazy options and/or normalizers
955
928
*/
956
- public function offsetGet ($ option , bool $ triggerDeprecation = true )
929
+ public function offsetGet (mixed $ option , bool $ triggerDeprecation = true )
957
930
{
958
931
if (!$ this ->locked ) {
959
932
throw new AccessException ('Array access is only supported within closures of lazy options and normalizers. ' );
@@ -1173,7 +1146,7 @@ public function offsetGet($option, bool $triggerDeprecation = true)
1173
1146
return $ value ;
1174
1147
}
1175
1148
1176
- private function verifyTypes (string $ type , $ value , array &$ invalidTypes , int $ level = 0 ): bool
1149
+ private function verifyTypes (string $ type , mixed $ value , array &$ invalidTypes , int $ level = 0 ): bool
1177
1150
{
1178
1151
if (\is_array ($ value ) && '[] ' === substr ($ type , -2 )) {
1179
1152
$ type = substr ($ type , 0 , -2 );
@@ -1202,15 +1175,13 @@ private function verifyTypes(string $type, $value, array &$invalidTypes, int $le
1202
1175
/**
1203
1176
* Returns whether a resolved option with the given name exists.
1204
1177
*
1205
- * @param string $option The option name
1206
- *
1207
1178
* @return bool Whether the option is set
1208
1179
*
1209
1180
* @throws AccessException If accessing this method outside of {@link resolve()}
1210
1181
*
1211
1182
* @see \ArrayAccess::offsetExists()
1212
1183
*/
1213
- public function offsetExists ($ option )
1184
+ public function offsetExists (mixed $ option )
1214
1185
{
1215
1186
if (!$ this ->locked ) {
1216
1187
throw new AccessException ('Array access is only supported within closures of lazy options and normalizers. ' );
@@ -1224,7 +1195,7 @@ public function offsetExists($option)
1224
1195
*
1225
1196
* @throws AccessException
1226
1197
*/
1227
- public function offsetSet ($ option , $ value )
1198
+ public function offsetSet (mixed $ option , mixed $ value )
1228
1199
{
1229
1200
throw new AccessException ('Setting options via array access is not supported. Use setDefault() instead. ' );
1230
1201
}
@@ -1234,7 +1205,7 @@ public function offsetSet($option, $value)
1234
1205
*
1235
1206
* @throws AccessException
1236
1207
*/
1237
- public function offsetUnset ($ option )
1208
+ public function offsetUnset (mixed $ option )
1238
1209
{
1239
1210
throw new AccessException ('Removing options via array access is not supported. Use remove() instead. ' );
1240
1211
}
@@ -1265,10 +1236,8 @@ public function count()
1265
1236
* This method returns the equivalent PHP tokens for most scalar types
1266
1237
* (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped
1267
1238
* in double quotes (").
1268
- *
1269
- * @param mixed $value The value to format as string
1270
1239
*/
1271
- private function formatValue ($ value ): string
1240
+ private function formatValue (mixed $ value ): string
1272
1241
{
1273
1242
if (\is_object ($ value )) {
1274
1243
return \get_class ($ value );
0 commit comments