@@ -29,6 +29,13 @@ class HttpOperation extends Operation
2929 public const METHOD_HEAD = 'HEAD ' ;
3030 public const METHOD_OPTIONS = 'OPTIONS ' ;
3131
32+ /** @var array<int|string, string|string[]>|null */
33+ protected ?array $ formats ;
34+ /** @var array<int|string, string|string[]>|null */
35+ protected ?array $ inputFormats ;
36+ /** @var array<int|string, string|string[]>|null */
37+ protected ?array $ outputFormats ;
38+
3239 /**
3340 * @param string[]|null $types the RDF types of this property
3441 * @param array<int|string, string|string[]>|string|null $formats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
@@ -90,9 +97,9 @@ public function __construct(
9097 protected string $ method = 'GET ' ,
9198 protected ?string $ uriTemplate = null ,
9299 protected ?array $ types = null ,
93- protected $ formats = null ,
94- protected $ inputFormats = null ,
95- protected $ outputFormats = null ,
100+ $ formats = null ,
101+ $ inputFormats = null ,
102+ $ outputFormats = null ,
96103 protected $ uriVariables = null ,
97104 protected ?string $ routePrefix = null ,
98105 protected ?string $ routeName = null ,
@@ -214,6 +221,10 @@ public function __construct(
214221 ?bool $ queryParameterValidationEnabled = null ,
215222 array $ extraProperties = [],
216223 ) {
224+ $ this ->formats = (null === $ formats || \is_array ($ formats )) ? $ formats : [$ formats ];
225+ $ this ->inputFormats = (null === $ inputFormats || \is_array ($ inputFormats )) ? $ inputFormats : [$ inputFormats ];
226+ $ this ->outputFormats = (null === $ outputFormats || \is_array ($ outputFormats )) ? $ outputFormats : [$ outputFormats ];
227+
217228 parent ::__construct (
218229 shortName: $ shortName ,
219230 class: $ class ,
@@ -312,7 +323,7 @@ public function withTypes($types): static
312323 }
313324
314325 /**
315- * @return array<int|string, string|string[]>|string| null
326+ * @return array<int|string, string|string[]>|null
316327 */
317328 public function getFormats ()
318329 {
@@ -325,13 +336,13 @@ public function getFormats()
325336 public function withFormats ($ formats = null ): static
326337 {
327338 $ self = clone $ this ;
328- $ self ->formats = $ formats ;
339+ $ self ->formats = ( null === $ formats || \is_array ( $ formats )) ? $ formats : [ $ formats ] ;
329340
330341 return $ self ;
331342 }
332343
333344 /**
334- * @return array<int|string, string|string[]>|string| null
345+ * @return array<int|string, string|string[]>|null
335346 */
336347 public function getInputFormats ()
337348 {
@@ -344,13 +355,13 @@ public function getInputFormats()
344355 public function withInputFormats ($ inputFormats = null ): static
345356 {
346357 $ self = clone $ this ;
347- $ self ->inputFormats = $ inputFormats ;
358+ $ self ->inputFormats = ( null === $ inputFormats || \is_array ( $ inputFormats )) ? $ inputFormats : [ $ inputFormats ] ;
348359
349360 return $ self ;
350361 }
351362
352363 /**
353- * @return array<int|string, string|string[]>|string| null
364+ * @return array<int|string, string|string[]>|null
354365 */
355366 public function getOutputFormats ()
356367 {
@@ -363,7 +374,7 @@ public function getOutputFormats()
363374 public function withOutputFormats ($ outputFormats = null ): static
364375 {
365376 $ self = clone $ this ;
366- $ self ->outputFormats = $ outputFormats ;
377+ $ self ->outputFormats = ( null === $ outputFormats || \is_array ( $ outputFormats )) ? $ outputFormats : [ $ outputFormats ] ;
367378
368379 return $ self ;
369380 }
0 commit comments