• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 15023181448

14 May 2025 02:19PM UTC coverage: 0.0% (-8.4%) from 8.418%
15023181448

Pull #7139

github

web-flow
Merge 9f45709da into 1862d03b7
Pull Request #7139: refactor(symfony): remove obsolete option `validator.query-parameter-validation`

0 of 4 new or added lines in 1 file covered. (0.0%)

11266 existing lines in 366 files now uncovered.

0 of 50828 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Metadata/HttpOperation.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Metadata;
15

16
use ApiPlatform\Metadata\Exception\ProblemExceptionInterface;
17
use ApiPlatform\OpenApi\Attributes\Webhook;
18
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
19
use ApiPlatform\State\OptionsInterface;
20
use Symfony\Component\WebLink\Link as WebLink;
21

22
class HttpOperation extends Operation
23
{
24
    public const METHOD_GET = 'GET';
25
    public const METHOD_POST = 'POST';
26
    public const METHOD_PUT = 'PUT';
27
    public const METHOD_PATCH = 'PATCH';
28
    public const METHOD_DELETE = 'DELETE';
29
    public const METHOD_HEAD = 'HEAD';
30
    public const METHOD_OPTIONS = 'OPTIONS';
31

32
    /**
33
     * @param string[]|null                                  $types         the RDF types of this property
34
     * @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}
35
     * @param array<int|string, string|string[]>|string|null $inputFormats  {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
36
     * @param array<int|string, string|string[]>|string|null $outputFormats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
37
     * @param array<string,array{
38
     *     0: string,
39
     *     1: string
40
     * }|array{
41
     *     from_property?: string,
42
     *     to_property?: string,
43
     *     from_class?: string,
44
     *     to_class?: string,
45
     *     identifiers?: string[],
46
     *     composite_identifier?: bool,
47
     *     expanded_value?: string,
48
     * }|Link>|string[]|string|null $uriVariables {@see https://api-platform.com/docs/core/subresources/}
49
     * @param string|null     $routePrefix {@see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations}
50
     * @param string|null     $sunset      {@see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed}
51
     * @param string|int|null $status      {@see https://api-platform.com/docs/core/operations/#configuring-operations}
52
     * @param array{
53
     *     max_age?: int,
54
     *     vary?: string|string[],
55
     *     public?: bool,
56
     *     shared_max_age?: int,
57
     *     stale_while_revalidate?: int,
58
     *     stale_if_error?: int,
59
     *     must_revalidate?: bool,
60
     *     proxy_revalidate?: bool,
61
     *     no_cache?: bool,
62
     *     no_store?: bool,
63
     *     no_transform?: bool,
64
     *     immutable?: bool,
65
     * }|null $cacheHeaders {@see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers}
66
     * @param array<string, string>|null $headers
67
     * @param array{
68
     *     field: string,
69
     *     direction: string,
70
     * }|null $paginationViaCursor {@see https://api-platform.com/docs/core/pagination/#cursor-based-pagination}
71
     * @param array|null $normalizationContext   {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
72
     * @param array|null $denormalizationContext {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
73
     * @param array|null $hydraContext           {@see https://api-platform.com/docs/core/extending-jsonld-context/#hydra}
74
     * @param array{
75
     *     class?: string|null,
76
     *     name?: string,
77
     * }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
78
     * @param array{
79
     *     class?: string|null,
80
     *     name?: string,
81
     * }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
82
     * @param string|array|bool|null                              $mercure   {@see https://api-platform.com/docs/core/mercure}
83
     * @param string|bool|null                                    $messenger {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus}
84
     * @param string|callable|null                                $provider  {@see https://api-platform.com/docs/core/state-providers/#state-providers}
85
     * @param string|callable|null                                $processor {@see https://api-platform.com/docs/core/state-processors/#state-processors}
86
     * @param WebLink[]|null                                      $links
87
     * @param array<class-string<ProblemExceptionInterface>>|null $errors
88
     */
89
    public function __construct(
90
        protected string $method = 'GET',
91
        protected ?string $uriTemplate = null,
92
        protected ?array $types = null,
93
        protected $formats = null,
94
        protected $inputFormats = null,
95
        protected $outputFormats = null,
96
        protected $uriVariables = null,
97
        protected ?string $routePrefix = null,
98
        protected ?string $routeName = null,
99
        protected ?array $defaults = null,
100
        protected ?array $requirements = null,
101
        protected ?array $options = null,
102
        protected ?bool $stateless = null,
103
        /**
104
         * The `sunset` option indicates when a deprecated operation will be removed.
105
         *
106
         * <div data-code-selector>
107
         *
108
         * ```php
109
         * <?php
110
         * // api/src/Entity/Parchment.php
111
         * use ApiPlatform\Metadata\Get;
112
         *
113
         * #[Get(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
114
         * class Parchment
115
         * {
116
         *     // ...
117
         * }
118
         * ```
119
         *
120
         * ```yaml
121
         * # api/config/api_platform/resources.yaml
122
         * resources:
123
         *     App\Entity\Parchment:
124
         *         - operations:
125
         *               ApiPlatform\Metadata\Get:
126
         *                   deprecationReason: 'Create a Book instead'
127
         *                   sunset: '01/01/2020'
128
         * ```
129
         *
130
         * ```xml
131
         * <?xml version="1.0" encoding="UTF-8" ?>
132
         * <!-- api/config/api_platform/resources.xml -->
133
         *
134
         * <resources
135
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
136
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
137
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
138
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
139
         *     <resource class="App\Entity\Parchment">
140
         *         <operations>
141
         *             <operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" sunset="01/01/2020" />
142
         *         <operations>
143
         *     </resource>
144
         * </resources>
145
         * ```
146
         *
147
         * </div>
148
         */
149
        protected ?string $sunset = null,
150
        protected ?string $acceptPatch = null,
151
        protected $status = null,
152
        protected ?string $host = null,
153
        protected ?array $schemes = null,
154
        protected ?string $condition = null,
155
        protected ?string $controller = null,
156
        protected ?array $headers = null,
157
        protected ?array $cacheHeaders = null,
158
        protected ?array $paginationViaCursor = null,
159
        protected ?array $hydraContext = null,
160
        protected bool|OpenApiOperation|Webhook|null $openapi = null,
161
        protected ?array $exceptionToStatus = null,
162
        protected ?array $links = null,
163
        protected ?array $errors = null,
164
        protected ?bool $strictQueryParameterValidation = null,
165
        protected ?bool $hideHydraOperation = null,
166

167
        ?string $shortName = null,
168
        ?string $class = null,
169
        ?bool $paginationEnabled = null,
170
        ?string $paginationType = null,
171
        ?int $paginationItemsPerPage = null,
172
        ?int $paginationMaximumItemsPerPage = null,
173
        ?bool $paginationPartial = null,
174
        ?bool $paginationClientEnabled = null,
175
        ?bool $paginationClientItemsPerPage = null,
176
        ?bool $paginationClientPartial = null,
177
        ?bool $paginationFetchJoinCollection = null,
178
        ?bool $paginationUseOutputWalkers = null,
179
        ?array $order = null,
180
        ?string $description = null,
181
        ?array $normalizationContext = null,
182
        ?array $denormalizationContext = null,
183
        ?bool $collectDenormalizationErrors = null,
184
        string|\Stringable|null $security = null,
185
        ?string $securityMessage = null,
186
        string|\Stringable|null $securityPostDenormalize = null,
187
        ?string $securityPostDenormalizeMessage = null,
188
        string|\Stringable|null $securityPostValidation = null,
189
        ?string $securityPostValidationMessage = null,
190
        ?string $deprecationReason = null,
191
        ?array $filters = null,
192
        ?array $validationContext = null,
193
        $input = null,
194
        $output = null,
195
        $mercure = null,
196
        $messenger = null,
197
        ?bool $elasticsearch = null,
198
        ?int $urlGenerationStrategy = null,
199
        ?bool $read = null,
200
        ?bool $deserialize = null,
201
        ?bool $validate = null,
202
        ?bool $write = null,
203
        ?bool $serialize = null,
204
        ?bool $fetchPartial = null,
205
        ?bool $forceEager = null,
206
        ?int $priority = null,
207
        ?string $name = null,
208
        $provider = null,
209
        $processor = null,
210
        ?OptionsInterface $stateOptions = null,
211
        array|Parameters|null $parameters = null,
212
        array|string|null $rules = null,
213
        ?string $policy = null,
214
        array|string|null $middleware = null,
215
        ?bool $queryParameterValidationEnabled = null,
216
        array $extraProperties = [],
217
    ) {
UNCOV
218
        parent::__construct(
×
UNCOV
219
            shortName: $shortName,
×
UNCOV
220
            class: $class,
×
UNCOV
221
            paginationEnabled: $paginationEnabled,
×
UNCOV
222
            paginationType: $paginationType,
×
UNCOV
223
            paginationItemsPerPage: $paginationItemsPerPage,
×
UNCOV
224
            paginationMaximumItemsPerPage: $paginationMaximumItemsPerPage,
×
UNCOV
225
            paginationPartial: $paginationPartial,
×
UNCOV
226
            paginationClientEnabled: $paginationClientEnabled,
×
UNCOV
227
            paginationClientItemsPerPage: $paginationClientItemsPerPage,
×
UNCOV
228
            paginationClientPartial: $paginationClientPartial,
×
UNCOV
229
            paginationFetchJoinCollection: $paginationFetchJoinCollection,
×
UNCOV
230
            paginationUseOutputWalkers: $paginationUseOutputWalkers,
×
UNCOV
231
            order: $order,
×
UNCOV
232
            description: $description,
×
UNCOV
233
            normalizationContext: $normalizationContext,
×
UNCOV
234
            denormalizationContext: $denormalizationContext,
×
UNCOV
235
            collectDenormalizationErrors: $collectDenormalizationErrors,
×
UNCOV
236
            security: $security,
×
UNCOV
237
            securityMessage: $securityMessage,
×
UNCOV
238
            securityPostDenormalize: $securityPostDenormalize,
×
UNCOV
239
            securityPostDenormalizeMessage: $securityPostDenormalizeMessage,
×
UNCOV
240
            securityPostValidation: $securityPostValidation,
×
UNCOV
241
            securityPostValidationMessage: $securityPostValidationMessage,
×
UNCOV
242
            deprecationReason: $deprecationReason,
×
UNCOV
243
            filters: $filters,
×
UNCOV
244
            validationContext: $validationContext,
×
UNCOV
245
            input: $input,
×
UNCOV
246
            output: $output,
×
UNCOV
247
            mercure: $mercure,
×
UNCOV
248
            messenger: $messenger,
×
UNCOV
249
            elasticsearch: $elasticsearch,
×
UNCOV
250
            urlGenerationStrategy: $urlGenerationStrategy,
×
UNCOV
251
            read: $read,
×
UNCOV
252
            deserialize: $deserialize,
×
UNCOV
253
            validate: $validate,
×
UNCOV
254
            write: $write,
×
UNCOV
255
            serialize: $serialize,
×
UNCOV
256
            fetchPartial: $fetchPartial,
×
UNCOV
257
            forceEager: $forceEager,
×
UNCOV
258
            priority: $priority,
×
UNCOV
259
            name: $name,
×
UNCOV
260
            provider: $provider,
×
UNCOV
261
            processor: $processor,
×
UNCOV
262
            stateOptions: $stateOptions,
×
UNCOV
263
            parameters: $parameters,
×
UNCOV
264
            rules: $rules,
×
UNCOV
265
            policy: $policy,
×
UNCOV
266
            middleware: $middleware,
×
UNCOV
267
            queryParameterValidationEnabled: $queryParameterValidationEnabled,
×
UNCOV
268
            strictQueryParameterValidation: $strictQueryParameterValidation,
×
UNCOV
269
            hideHydraOperation: $hideHydraOperation,
×
UNCOV
270
            extraProperties: $extraProperties
×
UNCOV
271
        );
×
272
    }
273

274
    public function getMethod(): string
275
    {
UNCOV
276
        return $this->method;
×
277
    }
278

279
    public function withMethod(string $method): static
280
    {
UNCOV
281
        $self = clone $this;
×
UNCOV
282
        $self->method = $method;
×
283

UNCOV
284
        return $self;
×
285
    }
286

287
    public function getUriTemplate(): ?string
288
    {
UNCOV
289
        return $this->uriTemplate;
×
290
    }
291

292
    public function withUriTemplate(?string $uriTemplate = null)
293
    {
UNCOV
294
        $self = clone $this;
×
UNCOV
295
        $self->uriTemplate = $uriTemplate;
×
296

UNCOV
297
        return $self;
×
298
    }
299

300
    public function getTypes(): ?array
301
    {
UNCOV
302
        return $this->types;
×
303
    }
304

305
    /**
306
     * @param string[]|string $types
307
     */
308
    public function withTypes($types): static
309
    {
UNCOV
310
        $self = clone $this;
×
UNCOV
311
        $self->types = (array) $types;
×
312

UNCOV
313
        return $self;
×
314
    }
315

316
    public function getFormats()
317
    {
UNCOV
318
        return $this->formats;
×
319
    }
320

321
    public function withFormats($formats = null): static
322
    {
UNCOV
323
        $self = clone $this;
×
UNCOV
324
        $self->formats = $formats;
×
325

UNCOV
326
        return $self;
×
327
    }
328

329
    public function getInputFormats()
330
    {
UNCOV
331
        return $this->inputFormats;
×
332
    }
333

334
    public function withInputFormats($inputFormats = null): static
335
    {
UNCOV
336
        $self = clone $this;
×
UNCOV
337
        $self->inputFormats = $inputFormats;
×
338

UNCOV
339
        return $self;
×
340
    }
341

342
    public function getOutputFormats()
343
    {
UNCOV
344
        return $this->outputFormats;
×
345
    }
346

347
    public function withOutputFormats($outputFormats = null): static
348
    {
UNCOV
349
        $self = clone $this;
×
UNCOV
350
        $self->outputFormats = $outputFormats;
×
351

UNCOV
352
        return $self;
×
353
    }
354

355
    public function getUriVariables()
356
    {
UNCOV
357
        return $this->uriVariables;
×
358
    }
359

360
    public function withUriVariables($uriVariables): static
361
    {
UNCOV
362
        $self = clone $this;
×
UNCOV
363
        $self->uriVariables = $uriVariables;
×
364

UNCOV
365
        return $self;
×
366
    }
367

368
    public function getRoutePrefix(): ?string
369
    {
UNCOV
370
        return $this->routePrefix;
×
371
    }
372

373
    public function withRoutePrefix(string $routePrefix): static
374
    {
UNCOV
375
        $self = clone $this;
×
UNCOV
376
        $self->routePrefix = $routePrefix;
×
377

UNCOV
378
        return $self;
×
379
    }
380

381
    public function getRouteName(): ?string
382
    {
UNCOV
383
        return $this->routeName;
×
384
    }
385

386
    public function withRouteName(?string $routeName): static
387
    {
388
        $self = clone $this;
×
389
        $self->routeName = $routeName;
×
390

391
        return $self;
×
392
    }
393

394
    public function getDefaults(): ?array
395
    {
UNCOV
396
        return $this->defaults;
×
397
    }
398

399
    public function withDefaults(array $defaults): static
400
    {
UNCOV
401
        $self = clone $this;
×
UNCOV
402
        $self->defaults = $defaults;
×
403

UNCOV
404
        return $self;
×
405
    }
406

407
    public function getRequirements(): ?array
408
    {
UNCOV
409
        return $this->requirements;
×
410
    }
411

412
    public function withRequirements(array $requirements): static
413
    {
UNCOV
414
        $self = clone $this;
×
UNCOV
415
        $self->requirements = $requirements;
×
416

UNCOV
417
        return $self;
×
418
    }
419

420
    public function getOptions(): ?array
421
    {
UNCOV
422
        return $this->options;
×
423
    }
424

425
    public function withOptions(array $options): static
426
    {
UNCOV
427
        $self = clone $this;
×
UNCOV
428
        $self->options = $options;
×
429

UNCOV
430
        return $self;
×
431
    }
432

433
    public function getStateless(): ?bool
434
    {
UNCOV
435
        return $this->stateless;
×
436
    }
437

438
    public function withStateless($stateless): static
439
    {
UNCOV
440
        $self = clone $this;
×
UNCOV
441
        $self->stateless = $stateless;
×
442

UNCOV
443
        return $self;
×
444
    }
445

446
    public function getSunset(): ?string
447
    {
UNCOV
448
        return $this->sunset;
×
449
    }
450

451
    public function withSunset(string $sunset): static
452
    {
UNCOV
453
        $self = clone $this;
×
UNCOV
454
        $self->sunset = $sunset;
×
455

UNCOV
456
        return $self;
×
457
    }
458

459
    public function getAcceptPatch(): ?string
460
    {
UNCOV
461
        return $this->acceptPatch;
×
462
    }
463

464
    public function withAcceptPatch(string $acceptPatch): static
465
    {
UNCOV
466
        $self = clone $this;
×
UNCOV
467
        $self->acceptPatch = $acceptPatch;
×
468

UNCOV
469
        return $self;
×
470
    }
471

472
    public function getStatus(): ?int
473
    {
UNCOV
474
        return $this->status;
×
475
    }
476

477
    public function withStatus(int $status): static
478
    {
UNCOV
479
        $self = clone $this;
×
UNCOV
480
        $self->status = $status;
×
481

UNCOV
482
        return $self;
×
483
    }
484

485
    public function getHost(): ?string
486
    {
UNCOV
487
        return $this->host;
×
488
    }
489

490
    public function withHost(string $host): static
491
    {
UNCOV
492
        $self = clone $this;
×
UNCOV
493
        $self->host = $host;
×
494

UNCOV
495
        return $self;
×
496
    }
497

498
    public function getSchemes(): ?array
499
    {
UNCOV
500
        return $this->schemes;
×
501
    }
502

503
    public function withSchemes(array $schemes): static
504
    {
UNCOV
505
        $self = clone $this;
×
UNCOV
506
        $self->schemes = $schemes;
×
507

UNCOV
508
        return $self;
×
509
    }
510

511
    public function getCondition(): ?string
512
    {
UNCOV
513
        return $this->condition;
×
514
    }
515

516
    public function withCondition(string $condition): static
517
    {
UNCOV
518
        $self = clone $this;
×
UNCOV
519
        $self->condition = $condition;
×
520

UNCOV
521
        return $self;
×
522
    }
523

524
    public function getController(): ?string
525
    {
UNCOV
526
        return $this->controller;
×
527
    }
528

529
    public function withController(string $controller): static
530
    {
UNCOV
531
        $self = clone $this;
×
UNCOV
532
        $self->controller = $controller;
×
533

UNCOV
534
        return $self;
×
535
    }
536

537
    public function getHeaders(): ?array
538
    {
UNCOV
539
        return $this->headers;
×
540
    }
541

542
    public function withHeaders(array $headers): static
543
    {
544
        $self = clone $this;
×
545
        $self->headers = $headers;
×
546

547
        return $self;
×
548
    }
549

550
    public function getCacheHeaders(): ?array
551
    {
UNCOV
552
        return $this->cacheHeaders;
×
553
    }
554

555
    public function withCacheHeaders(array $cacheHeaders): static
556
    {
UNCOV
557
        $self = clone $this;
×
UNCOV
558
        $self->cacheHeaders = $cacheHeaders;
×
559

UNCOV
560
        return $self;
×
561
    }
562

563
    public function getPaginationViaCursor(): ?array
564
    {
UNCOV
565
        return $this->paginationViaCursor;
×
566
    }
567

568
    public function withPaginationViaCursor(array $paginationViaCursor): static
569
    {
570
        $self = clone $this;
×
571
        $self->paginationViaCursor = $paginationViaCursor;
×
572

573
        return $self;
×
574
    }
575

576
    public function getHydraContext(): ?array
577
    {
UNCOV
578
        return $this->hydraContext;
×
579
    }
580

581
    public function withHydraContext(array $hydraContext): static
582
    {
583
        $self = clone $this;
×
584
        $self->hydraContext = $hydraContext;
×
585

586
        return $self;
×
587
    }
588

589
    public function getOpenapi(): bool|OpenApiOperation|Webhook|null
590
    {
UNCOV
591
        return $this->openapi;
×
592
    }
593

594
    public function withOpenapi(bool|OpenApiOperation|Webhook $openapi): static
595
    {
UNCOV
596
        $self = clone $this;
×
UNCOV
597
        $self->openapi = $openapi;
×
598

UNCOV
599
        return $self;
×
600
    }
601

602
    public function getExceptionToStatus(): ?array
603
    {
UNCOV
604
        return $this->exceptionToStatus;
×
605
    }
606

607
    public function withExceptionToStatus(array $exceptionToStatus): static
608
    {
609
        $self = clone $this;
×
610
        $self->exceptionToStatus = $exceptionToStatus;
×
611

612
        return $self;
×
613
    }
614

615
    public function getLinks(): ?array
616
    {
UNCOV
617
        return $this->links;
×
618
    }
619

620
    /**
621
     * @param WebLink[] $links
622
     */
623
    public function withLinks(array $links): static
624
    {
625
        $self = clone $this;
×
626
        $self->links = $links;
×
627

628
        return $self;
×
629
    }
630

631
    public function getErrors(): ?array
632
    {
UNCOV
633
        return $this->errors;
×
634
    }
635

636
    /**
637
     * @param class-string<ProblemExceptionInterface>[] $errors
638
     */
639
    public function withErrors(array $errors): static
640
    {
641
        $self = clone $this;
×
642
        $self->errors = $errors;
×
643

644
        return $self;
×
645
    }
646
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc