@@ -29,6 +29,13 @@ class HttpOperation extends Operation
29
29
public const METHOD_HEAD = 'HEAD ' ;
30
30
public const METHOD_OPTIONS = 'OPTIONS ' ;
31
31
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
+
32
39
/**
33
40
* @param string[]|null $types the RDF types of this property
34
41
* @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(
90
97
protected string $ method = 'GET ' ,
91
98
protected ?string $ uriTemplate = null ,
92
99
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 ,
96
103
protected $ uriVariables = null ,
97
104
protected ?string $ routePrefix = null ,
98
105
protected ?string $ routeName = null ,
@@ -214,6 +221,10 @@ public function __construct(
214
221
?bool $ queryParameterValidationEnabled = null ,
215
222
array $ extraProperties = [],
216
223
) {
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
+
217
228
parent ::__construct (
218
229
shortName: $ shortName ,
219
230
class: $ class ,
@@ -287,7 +298,7 @@ public function getUriTemplate(): ?string
287
298
return $ this ->uriTemplate ;
288
299
}
289
300
290
- public function withUriTemplate (?string $ uriTemplate = null )
301
+ public function withUriTemplate (?string $ uriTemplate = null ): static
291
302
{
292
303
$ self = clone $ this ;
293
304
$ self ->uriTemplate = $ uriTemplate ;
@@ -311,45 +322,66 @@ public function withTypes($types): static
311
322
return $ self ;
312
323
}
313
324
325
+ /**
326
+ * @return array<int|string, string|string[]>|null
327
+ */
314
328
public function getFormats ()
315
329
{
316
330
return $ this ->formats ;
317
331
}
318
332
333
+ /**
334
+ * @param array<int|string, string|string[]>|string|null $formats
335
+ */
319
336
public function withFormats ($ formats = null ): static
320
337
{
321
338
$ self = clone $ this ;
322
- $ self ->formats = $ formats ;
339
+ $ self ->formats = ( null === $ formats || \is_array ( $ formats )) ? $ formats : [ $ formats ] ;
323
340
324
341
return $ self ;
325
342
}
326
343
344
+ /**
345
+ * @return array<int|string, string|string[]>|null
346
+ */
327
347
public function getInputFormats ()
328
348
{
329
349
return $ this ->inputFormats ;
330
350
}
331
351
352
+ /**
353
+ * @param array<int|string, string|string[]>|string|null $inputFormats
354
+ */
332
355
public function withInputFormats ($ inputFormats = null ): static
333
356
{
334
357
$ self = clone $ this ;
335
- $ self ->inputFormats = $ inputFormats ;
358
+ $ self ->inputFormats = ( null === $ inputFormats || \is_array ( $ inputFormats )) ? $ inputFormats : [ $ inputFormats ] ;
336
359
337
360
return $ self ;
338
361
}
339
362
363
+ /**
364
+ * @return array<int|string, string|string[]>|null
365
+ */
340
366
public function getOutputFormats ()
341
367
{
342
368
return $ this ->outputFormats ;
343
369
}
344
370
371
+ /**
372
+ * @param array<int|string, string|string[]>|string|null $outputFormats
373
+ */
345
374
public function withOutputFormats ($ outputFormats = null ): static
346
375
{
347
376
$ self = clone $ this ;
348
- $ self ->outputFormats = $ outputFormats ;
377
+ $ self ->outputFormats = ( null === $ outputFormats || \is_array ( $ outputFormats )) ? $ outputFormats : [ $ outputFormats ] ;
349
378
350
379
return $ self ;
351
380
}
352
381
382
+ /**
383
+ * @return array<string, mixed>|array<int, Link>|list<string>|null
384
+ */
353
385
public function getUriVariables ()
354
386
{
355
387
return $ this ->uriVariables ;
0 commit comments