@@ -145,17 +145,17 @@ class OptionsResolver implements Options, OptionsResolverInterface
145
145
* @param string $option The name of the option
146
146
* @param mixed $value The default value of the option
147
147
*
148
- * @return Options This instance
148
+ * @return OptionsResolver This instance
149
149
*
150
- * @throws AccessException If the options are resolved already
150
+ * @throws AccessException If called from a lazy option or normalizer
151
151
*/
152
152
public function setDefault ($ option , $ value )
153
153
{
154
154
// Setting is not possible once resolving starts, because then lazy
155
155
// options could manipulate the state of the object, leading to
156
156
// inconsistent results.
157
157
if ($ this ->locked ) {
158
- throw new AccessException ('Default values cannot be set anymore once resolving has begun . ' );
158
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
159
159
}
160
160
161
161
// If an option is a closure that should be evaluated lazily, store it
@@ -208,9 +208,9 @@ public function setDefault($option, $value)
208
208
*
209
209
* @param array $defaults The default values to set
210
210
*
211
- * @return Options This instance
211
+ * @return OptionsResolver This instance
212
212
*
213
- * @throws AccessException If the options are resolved already
213
+ * @throws AccessException If called from a lazy option or normalizer
214
214
*/
215
215
public function setDefaults (array $ defaults )
216
216
{
@@ -241,14 +241,14 @@ public function hasDefault($option)
241
241
*
242
242
* @param string|string[] $optionNames One or more option names
243
243
*
244
- * @return Options This instance
244
+ * @return OptionsResolver This instance
245
245
*
246
- * @throws AccessException If the options are resolved already
246
+ * @throws AccessException If called from a lazy option or normalizer
247
247
*/
248
248
public function setRequired ($ optionNames )
249
249
{
250
250
if ($ this ->locked ) {
251
- throw new AccessException ('Options cannot be made required anymore once resolving has begun . ' );
251
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
252
252
}
253
253
254
254
foreach ((array ) $ optionNames as $ key => $ option ) {
@@ -322,14 +322,14 @@ public function getMissingOptions()
322
322
*
323
323
* @param string|string[] $optionNames One or more option names
324
324
*
325
- * @return Options This instance
325
+ * @return OptionsResolver This instance
326
326
*
327
- * @throws AccessException If the options are resolved already
327
+ * @throws AccessException If called from a lazy option or normalizer
328
328
*/
329
329
public function setDefined ($ optionNames )
330
330
{
331
331
if ($ this ->locked ) {
332
- throw new AccessException ('Options cannot be defined anymore once resolving has begun . ' );
332
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
333
333
}
334
334
335
335
foreach ((array ) $ optionNames as $ key => $ option ) {
@@ -389,15 +389,15 @@ public function getDefinedOptions()
389
389
* @param string $option The option name
390
390
* @param \Closure $normalizer The normalizer
391
391
*
392
- * @return Options This instance
392
+ * @return OptionsResolver This instance
393
393
*
394
- * @throws AccessException If the options are resolved already
395
394
* @throws UndefinedOptionsException If the option is undefined
395
+ * @throws AccessException If called from a lazy option or normalizer
396
396
*/
397
397
public function setNormalizer ($ option , \Closure $ normalizer )
398
398
{
399
399
if ($ this ->locked ) {
400
- throw new AccessException ('Normalizers cannot be added anymore once resolving has begun . ' );
400
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
401
401
}
402
402
403
403
if (!isset ($ this ->defined [$ option ])) {
@@ -444,16 +444,15 @@ public function setNormalizers(array $normalizers)
444
444
* @param string $option The option name
445
445
* @param mixed $allowedValues One or more acceptable values/closures
446
446
*
447
+ * @return OptionsResolver This instance
447
448
*
448
- * @return Options This instance
449
- *
450
- * @throws AccessException If the options are resolved already
451
- * @throws UndefinedOptionsException If an option is undefined
449
+ * @throws UndefinedOptionsException If the option is undefined
450
+ * @throws AccessException If called from a lazy option or normalizer
452
451
*/
453
452
public function setAllowedValues ($ option , $ allowedValues = null )
454
453
{
455
454
if ($ this ->locked ) {
456
- throw new AccessException ('Allowed values cannot be set anymore once resolving has begun . ' );
455
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
457
456
}
458
457
459
458
// BC
@@ -499,15 +498,15 @@ public function setAllowedValues($option, $allowedValues = null)
499
498
* @param string $option The option name
500
499
* @param mixed $allowedValues One or more acceptable values/closures
501
500
*
502
- * @return Options This instance
501
+ * @return OptionsResolver This instance
503
502
*
504
- * @throws AccessException If the options are resolved already
505
- * @throws UndefinedOptionsException If an option is undefined
503
+ * @throws UndefinedOptionsException If the option is undefined
504
+ * @throws AccessException If called from a lazy option or normalizer
506
505
*/
507
506
public function addAllowedValues ($ option , $ allowedValues = null )
508
507
{
509
508
if ($ this ->locked ) {
510
- throw new AccessException ('Allowed values cannot be added anymore once resolving has begun . ' );
509
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
511
510
}
512
511
513
512
// BC
@@ -551,15 +550,15 @@ public function addAllowedValues($option, $allowedValues = null)
551
550
* @param string $option The option name
552
551
* @param string|string[] $allowedTypes One or more accepted types
553
552
*
554
- * @return Options This instance
553
+ * @return OptionsResolver This instance
555
554
*
556
- * @throws AccessException If the options are resolved already
557
- * @throws UndefinedOptionsException If an option is undefined
555
+ * @throws UndefinedOptionsException If the option is undefined
556
+ * @throws AccessException If called from a lazy option or normalizer
558
557
*/
559
558
public function setAllowedTypes ($ option , $ allowedTypes = null )
560
559
{
561
560
if ($ this ->locked ) {
562
- throw new AccessException ('Allowed types cannot be set anymore once resolving has begun . ' );
561
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
563
562
}
564
563
565
564
// BC
@@ -599,15 +598,15 @@ public function setAllowedTypes($option, $allowedTypes = null)
599
598
* @param string $option The option name
600
599
* @param string|string[] $allowedTypes One or more accepted types
601
600
*
602
- * @return Options This instance
601
+ * @return OptionsResolver This instance
603
602
*
604
- * @throws AccessException If the options are resolved already
605
- * @throws UndefinedOptionsException If an option is undefined
603
+ * @throws UndefinedOptionsException If the option is undefined
604
+ * @throws AccessException If called from a lazy option or normalizer
606
605
*/
607
606
public function addAllowedTypes ($ option , $ allowedTypes = null )
608
607
{
609
608
if ($ this ->locked ) {
610
- throw new AccessException ('Allowed types cannot be added anymore once resolving has begun . ' );
609
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
611
610
}
612
611
613
612
// BC
@@ -646,14 +645,14 @@ public function addAllowedTypes($option, $allowedTypes = null)
646
645
*
647
646
* @param string|string[] $optionNames One or more option names
648
647
*
649
- * @return Options This instance
648
+ * @return OptionsResolver This instance
650
649
*
651
- * @throws AccessException If the options are resolved already
650
+ * @throws AccessException If called from a lazy option or normalizer
652
651
*/
653
652
public function remove ($ optionNames )
654
653
{
655
654
if ($ this ->locked ) {
656
- throw new AccessException ('Options cannot be removed anymore once resolving has begun . ' );
655
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
657
656
}
658
657
659
658
foreach ((array ) $ optionNames as $ option ) {
@@ -673,14 +672,14 @@ public function remove($optionNames)
673
672
/**
674
673
* Removes all options.
675
674
*
676
- * @return Options This instance
675
+ * @return OptionsResolver This instance
677
676
*
678
- * @throws AccessException If the options are resolved already
677
+ * @throws AccessException If called from a lazy option or normalizer
679
678
*/
680
679
public function clear ()
681
680
{
682
681
if ($ this ->locked ) {
683
- throw new AccessException ('Options cannot be cleared anymore once resolving has begun . ' );
682
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer . ' );
684
683
}
685
684
686
685
$ this ->defined = array ();
@@ -714,11 +713,16 @@ public function clear()
714
713
* @throws InvalidOptionsException If an option doesn't fulfill the
715
714
* specified validation rules
716
715
* @throws MissingOptionsException If a required option is missing
717
- * @throws OptionDefinitionException If a cyclic dependency is depended
718
- * between lazy options and/or normalizers
716
+ * @throws OptionDefinitionException If there is a cyclic dependency between
717
+ * lazy options and/or normalizers
718
+ * @throws AccessException If called from a lazy option or normalizer
719
719
*/
720
720
public function resolve (array $ options = array ())
721
721
{
722
+ if ($ this ->locked ) {
723
+ throw new AccessException ('This method cannot be called from a lazy option or normalizer. ' );
724
+ }
725
+
722
726
// Allow this method to be called multiple times
723
727
$ clone = clone $ this ;
724
728
@@ -778,8 +782,8 @@ public function resolve(array $options = array())
778
782
* @throws \OutOfBoundsException If the option is not set
779
783
* @throws InvalidOptionsException If an option doesn't fulfill the
780
784
* specified validation rules
781
- * @throws OptionDefinitionException If a cyclic dependency is detected
782
- * between two lazily evaluated options
785
+ * @throws OptionDefinitionException If there is a cyclic dependency between
786
+ * lazy options and/or normalizers
783
787
*/
784
788
public function offsetGet ($ option )
785
789
{
0 commit comments