@@ -180,23 +180,30 @@ public function createProperty(string $name, $value = null, ?array $parameters =
180180
181181 $ class = null ;
182182
183+ // If a VALUE parameter is supplied, we have to use that
184+ // According to https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.20
185+ // If the property's value is the default value type, then this
186+ // parameter need not be specified. However, if the property's
187+ // default value type is overridden by some other allowable value
188+ // type, then this parameter MUST be specified.
189+ if (!$ valueType ) {
190+ $ valueType = $ parameters ['VALUE ' ] ?? null ;
191+ }
192+
183193 if ($ valueType ) {
184194 // The valueType argument comes first to figure out the correct
185195 // class.
186196 $ class = $ this ->getClassNameForPropertyValue ($ valueType );
187197 }
188198
199+ // If the value parameter is not set or set to something we do not recognize
200+ // we do not attempt to interpret or parse the datass value as specified in
201+ // https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.20
202+ // So when we so far did not get a class-name, we use the default for the property
189203 if (is_null ($ class )) {
190- // If a VALUE parameter is supplied, we should use that.
191- if (isset ($ parameters ['VALUE ' ])) {
192- $ class = $ this ->getClassNameForPropertyValue ($ parameters ['VALUE ' ]);
193- if (is_null ($ class )) {
194- throw new InvalidDataException ('Unsupported VALUE parameter for ' .$ name .' property. You supplied " ' .$ parameters ['VALUE ' ].'" ' );
195- }
196- } else {
197- $ class = $ this ->getClassNameForPropertyName ($ name );
198- }
204+ $ class = $ this ->getClassNameForPropertyName ($ name );
199205 }
206+
200207 if (is_null ($ parameters )) {
201208 $ parameters = [];
202209 }
0 commit comments