@@ -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 $ formats ;
34+ /** @var array<int|string, string|string[]>|null */
35+ protected $ inputFormats ;
36+ /** @var array<int|string, string|string[]>|null */
37+ protected $ 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 ,
@@ -287,7 +298,7 @@ public function getUriTemplate(): ?string
287298 return $ this ->uriTemplate ;
288299 }
289300
290- public function withUriTemplate (?string $ uriTemplate = null )
301+ public function withUriTemplate (?string $ uriTemplate = null ): static
291302 {
292303 $ self = clone $ this ;
293304 $ self ->uriTemplate = $ uriTemplate ;
@@ -311,45 +322,66 @@ public function withTypes($types): static
311322 return $ self ;
312323 }
313324
325+ /**
326+ * @return array<int|string, string|string[]>|null
327+ */
314328 public function getFormats ()
315329 {
316330 return $ this ->formats ;
317331 }
318332
333+ /**
334+ * @param array<int|string, string|string[]>|string|null $formats
335+ */
319336 public function withFormats ($ formats = null ): static
320337 {
321338 $ self = clone $ this ;
322- $ self ->formats = $ formats ;
339+ $ self ->formats = ( null === $ formats || \is_array ( $ formats )) ? $ formats : [ $ formats ] ;
323340
324341 return $ self ;
325342 }
326343
344+ /**
345+ * @return array<int|string, string|string[]>|null
346+ */
327347 public function getInputFormats ()
328348 {
329349 return $ this ->inputFormats ;
330350 }
331351
352+ /**
353+ * @param array<int|string, string|string[]>|string|null $inputFormats
354+ */
332355 public function withInputFormats ($ inputFormats = null ): static
333356 {
334357 $ self = clone $ this ;
335- $ self ->inputFormats = $ inputFormats ;
358+ $ self ->inputFormats = ( null === $ inputFormats || \is_array ( $ inputFormats )) ? $ inputFormats : [ $ inputFormats ] ;
336359
337360 return $ self ;
338361 }
339362
363+ /**
364+ * @return array<int|string, string|string[]>|null
365+ */
340366 public function getOutputFormats ()
341367 {
342368 return $ this ->outputFormats ;
343369 }
344370
371+ /**
372+ * @param array<int|string, string|string[]>|string|null $outputFormats
373+ */
345374 public function withOutputFormats ($ outputFormats = null ): static
346375 {
347376 $ self = clone $ this ;
348- $ self ->outputFormats = $ outputFormats ;
377+ $ self ->outputFormats = ( null === $ outputFormats || \is_array ( $ outputFormats )) ? $ outputFormats : [ $ outputFormats ] ;
349378
350379 return $ self ;
351380 }
352381
382+ /**
383+ * @return array<string, mixed>|array<int, Link>|list<string>|null
384+ */
353385 public function getUriVariables ()
354386 {
355387 return $ this ->uriVariables ;
0 commit comments