@@ -231,16 +231,26 @@ public function getTypeName(array $parameter, array $spec = []): string
231
231
if (!empty ($ parameter ['enumValues ' ])) {
232
232
return \ucfirst ($ parameter ['name ' ]);
233
233
}
234
- return match ($ parameter ['type ' ] ?? '' ) {
235
- self ::TYPE_FILE => 'InputFile ' ,
236
- self ::TYPE_NUMBER ,
237
- self ::TYPE_INTEGER => 'float ' ,
238
- self ::TYPE_BOOLEAN => 'bool ' ,
239
- self ::TYPE_STRING => 'str ' ,
240
- self ::TYPE_ARRAY => 'list ' ,
241
- self ::TYPE_OBJECT => 'dict ' ,
242
- default => $ parameter ['type ' ],
243
- };
234
+ switch ($ parameter ['type ' ] ?? '' ) {
235
+ case self ::TYPE_FILE :
236
+ return 'InputFile ' ;
237
+ case self ::TYPE_NUMBER :
238
+ case self ::TYPE_INTEGER :
239
+ return 'float ' ;
240
+ case self ::TYPE_BOOLEAN :
241
+ return 'bool ' ;
242
+ case self ::TYPE_STRING :
243
+ return 'str ' ;
244
+ case self ::TYPE_ARRAY :
245
+ if (!empty (($ parameter ['array ' ] ?? [])['type ' ]) && !\is_array ($ parameter ['array ' ]['type ' ])) {
246
+ return 'list[ ' . $ this ->getTypeName ($ parameter ['array ' ]) . '] ' ;
247
+ }
248
+ return 'list[str] ' ;
249
+ case self ::TYPE_OBJECT :
250
+ return 'dict ' ;
251
+ default :
252
+ return $ parameter ['type ' ];
253
+ }
244
254
}
245
255
246
256
/**
@@ -360,6 +370,9 @@ public function getFilters(): array
360
370
new TwigFilter ('caseEnumKey ' , function (string $ value ) {
361
371
return $ this ->toUpperSnakeCase ($ value );
362
372
}),
373
+ new TwigFilter ('getPropertyType ' , function ($ value , $ method = []) {
374
+ return $ this ->getTypeName ($ value , $ method );
375
+ }),
363
376
];
364
377
}
365
378
}
0 commit comments