@@ -691,20 +691,30 @@ public function addAllowedValuesForAll($optionNames, $allowedValues, $replace =
691
691
throw new AccessException ('Allowed types cannot be added from a lazy option or normalizer. ' );
692
692
}
693
693
694
- if (Options::ALL === $ optionNames ) {
695
- $ this ->allowedValuesForAll = $ replace
696
- ? array_merge ($ this ->allowedValuesForAll , $ allowedValues ) : $ allowedValues ;
694
+ switch ($ optionNames ) {
695
+ case Options::ALL :
696
+ $ this ->allowedValuesForAll = $ replace
697
+ ? array_merge ($ this ->allowedValuesForAll , $ allowedValues ) : $ allowedValues ;
697
698
698
- if (Options::NONE === $ nested ) {
699
- return $ this ;
700
- }
699
+ if (Options::NONE === $ nested ) {
700
+ return $ this ;
701
+ }
701
702
702
- $ optionNames = $ this ->getNestedOptions ();
703
+ $ optionNames = $ this ->getNestedOptions ();
704
+ break ;
705
+ case Options::NESTED :
706
+ $ optionNames = $ this ->getNestedOptions ();
707
+ break ;
708
+ case Options::DEFINED :
709
+ $ optionNames = $ this ->getDefinedOptions ();
710
+ break ;
711
+ default :
712
+ $ optionNames = (array ) $ optionNames ;
703
713
}
704
714
705
- foreach (( array ) $ optionNames as $ option ) {
706
- if ($ this ->isNested ($ option ) && Options::ALL = == $ nested ) {
707
- $ this ->nested [$ option ]->addAllowedValuesForAll (Options:: ALL , $ allowedValues , $ replace );
715
+ foreach ($ optionNames as $ option ) {
716
+ if ($ this ->isNested ($ option ) && Options::NONE ! == $ nested ) {
717
+ $ this ->nested [$ option ]->addAllowedValuesForAll ($ nested , $ allowedValues , $ replace );
708
718
} else {
709
719
if ($ replace ) {
710
720
$ this ->setAllowedValues ($ option , $ allowedValues );
@@ -840,20 +850,30 @@ public function addAllowedTypesForAll($optionNames, $allowedTypes, $replace = fa
840
850
throw new AccessException ('Allowed types cannot be added from a lazy option or normalizer. ' );
841
851
}
842
852
843
- if (Options::ALL === $ optionNames ) {
844
- $ this ->allowedTypesForAll = $ replace
845
- ? array_merge ($ this ->allowedTypesForAll , $ allowedTypes ) : $ allowedTypes ;
853
+ switch ($ optionNames ) {
854
+ case Options::ALL :
855
+ $ this ->allowedTypesForAll = $ replace
856
+ ? array_merge ($ this ->allowedTypesForAll , $ allowedTypes ) : $ allowedTypes ;
846
857
847
- if (Options::NONE === $ nested ) {
848
- return $ this ;
849
- }
858
+ if (Options::NONE === $ nested ) {
859
+ return $ this ;
860
+ }
850
861
851
- $ optionNames = $ this ->getNestedOptions ();
862
+ $ optionNames = $ this ->getNestedOptions ();
863
+ break ;
864
+ case Options::NESTED :
865
+ $ optionNames = $ this ->getNestedOptions ();
866
+ break ;
867
+ case Options::DEFINED :
868
+ $ optionNames = $ this ->getDefinedOptions ();
869
+ break ;
870
+ default :
871
+ $ optionNames = (array ) $ optionNames ;
852
872
}
853
873
854
- foreach (( array ) $ optionNames as $ option ) {
855
- if ($ this ->isNested ($ option ) && Options::ALL = == $ nested ) {
856
- $ this ->nested [$ option ]->addAllowedTypesForAll (Options:: ALL , $ allowedTypes , $ replace );
874
+ foreach ($ optionNames as $ option ) {
875
+ if ($ this ->isNested ($ option ) && Options::NONE ! == $ nested ) {
876
+ $ this ->nested [$ option ]->addAllowedTypesForAll ($ nested , $ allowedTypes , $ replace );
857
877
} else {
858
878
if ($ replace ) {
859
879
$ this ->setAllowedTypes ($ option , $ allowedTypes );
@@ -1090,10 +1110,18 @@ public function offsetGet($option)
1090
1110
}
1091
1111
1092
1112
// Validate the type of the resolved option
1093
- if (isset ($ this ->allowedTypes [$ option ]) || ($ this ->allowedTypesForAll && false === $ this ->isNested ($ option ))) {
1113
+ if (isset ($ this ->allowedTypes [$ option ])
1114
+ || ($ this ->allowedTypesForAll && false === $ this ->isNested ($ option ))
1115
+ || $ extra = (isset ($ this ->allowedTypes [Options::EXTRA ]) && false === $ this ->isDefined ($ option ))
1116
+ ) {
1094
1117
$ valid = false ;
1095
1118
1096
- $ allowedTypes = isset ($ this ->allowedTypes [$ option ]) ? $ this ->allowedTypes [$ option ] : array ();
1119
+ if (isset ($ extra ) && $ extra && $ this ->allowExtraOptions ) {
1120
+ $ allowedTypes = $ this ->allowedTypes [Options::EXTRA ];
1121
+ } else {
1122
+ $ allowedTypes = isset ($ this ->allowedTypes [$ option ]) ? $ this ->allowedTypes [$ option ] : [];
1123
+ }
1124
+
1097
1125
$ allowedTypes = array_unique (array_merge ($ allowedTypes , $ this ->allowedTypesForAll ));
1098
1126
1099
1127
foreach ($ allowedTypes as $ type ) {
@@ -1127,11 +1155,19 @@ public function offsetGet($option)
1127
1155
}
1128
1156
1129
1157
// Validate the value of the resolved option
1130
- if (isset ($ this ->allowedValues [$ option ]) || ($ this ->allowedValuesForAll && false === $ this ->isNested ($ option ))) {
1158
+ if (isset ($ this ->allowedValues [$ option ])
1159
+ || ($ this ->allowedValuesForAll && false === $ this ->isNested ($ option ))
1160
+ || $ extra = (isset ($ this ->allowedValues [Options::EXTRA ]) && false === $ this ->isDefined ($ option ))
1161
+ ) {
1131
1162
$ success = false ;
1132
1163
$ printableAllowedValues = array ();
1133
1164
1134
- $ allowedValues = isset ($ this ->allowedValues [$ option ]) ? $ this ->allowedValues [$ option ] : array ();
1165
+ if (isset ($ extra ) && $ extra && $ this ->allowExtraOptions ) {
1166
+ $ allowedValues = $ this ->allowedTypes [Options::EXTRA ];
1167
+ } else {
1168
+ $ allowedValues = isset ($ this ->allowedValues [$ option ]) ? $ this ->allowedValues [$ option ] : [];
1169
+ }
1170
+
1135
1171
$ allowedValues = array_merge ($ allowedValues , $ this ->allowedValuesForAll );
1136
1172
1137
1173
foreach ($ allowedValues as $ allowedValue ) {
0 commit comments