@@ -43,10 +43,17 @@ public function getModel(): ?StructModel
4343 return parent ::getModel ();
4444 }
4545
46+ protected function addClassElement (): AbstractModelFile
47+ {
48+ $ this ->getFile ()->addString ('#[\AllowDynamicProperties] ' );
49+
50+ return parent ::addClassElement ();
51+ }
52+
4653 protected function defineUseStatements (): self
4754 {
4855 if ($ this ->getGenerator ()->getOptionValidation ()) {
49- $ this ->getFile ()->addUse (\InvalidArgumentException::class, null , false );
56+ $ this ->getFile ()->addUse (\InvalidArgumentException::class);
5057 }
5158
5259 return parent ::defineUseStatements ();
@@ -175,7 +182,7 @@ protected function getStructMethodParameter(StructAttributeModel $attribute): Ph
175182 }
176183
177184 try {
178- $ defaultValue = $ attribute ->getDefaultValue ();
185+ $ defaultValue = $ attribute ->getDefaultValue ($ this -> getStructAttributeTypeAsPhpType ( $ attribute ) );
179186
180187 return new PhpFunctionParameter (
181188 lcfirst ($ attribute ->getUniqueString ($ attribute ->getCleanName (), 'method ' )),
@@ -340,17 +347,16 @@ protected function addStructMethodGetBodyReturn(PhpMethod $method, StructAttribu
340347
341348 protected function addStructMethodGet (StructAttributeModel $ attribute ): self
342349 {
343- switch (true ) {
344- // it can either be a string, a DOMDocument or null...
345- case $ attribute ->isXml ():
346- $ returnType = '' ;
347-
348- break ;
349-
350- default :
351- $ returnType = (!$ attribute ->getRemovableFromRequest () && !$ attribute ->isAChoice () && $ attribute ->isRequired () ? '' : '? ' ).$ this ->getStructAttributeTypeAsPhpType ($ attribute );
352-
353- break ;
350+ // it can either be a string, a DOMDocument or null...
351+ if ($ attribute ->isXml ()) {
352+ $ returnType = '' ;
353+ } else {
354+ $ returnType = (
355+ !$ attribute ->getRemovableFromRequest ()
356+ && !$ attribute ->isAChoice ()
357+ && $ attribute ->isRequired ()
358+ && !$ attribute ->isNullable () ? '' : '? '
359+ ).$ this ->getStructAttributeTypeAsPhpType ($ attribute );
354360 }
355361
356362 $ method = new PhpMethod (
0 commit comments