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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

94.34
/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\OpenApi\Model\Operation as OpenApiOperation;
17
use ApiPlatform\State\OptionsInterface;
18
use Symfony\Component\WebLink\Link as WebLink;
19

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

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

154
        string $shortName = null,
155
        string $class = null,
156
        bool $paginationEnabled = null,
157
        string $paginationType = null,
158
        int $paginationItemsPerPage = null,
159
        int $paginationMaximumItemsPerPage = null,
160
        bool $paginationPartial = null,
161
        bool $paginationClientEnabled = null,
162
        bool $paginationClientItemsPerPage = null,
163
        bool $paginationClientPartial = null,
164
        bool $paginationFetchJoinCollection = null,
165
        bool $paginationUseOutputWalkers = null,
166
        array $order = null,
167
        string $description = null,
168
        array $normalizationContext = null,
169
        array $denormalizationContext = null,
170
        bool $collectDenormalizationErrors = null,
171
        string $security = null,
172
        string $securityMessage = null,
173
        string $securityPostDenormalize = null,
174
        string $securityPostDenormalizeMessage = null,
175
        string $securityPostValidation = null,
176
        string $securityPostValidationMessage = null,
177
        string $deprecationReason = null,
178
        array $filters = null,
179
        array $validationContext = null,
180
        $input = null,
181
        $output = null,
182
        $mercure = null,
183
        $messenger = null,
184
        bool $elasticsearch = null,
185
        int $urlGenerationStrategy = null,
186
        bool $read = null,
187
        bool $deserialize = null,
188
        bool $validate = null,
189
        bool $write = null,
190
        bool $serialize = null,
191
        bool $fetchPartial = null,
192
        bool $forceEager = null,
193
        int $priority = null,
194
        string $name = null,
195
        $provider = null,
196
        $processor = null,
197
        OptionsInterface $stateOptions = null,
198
        array $extraProperties = [],
199
    ) {
200
        parent::__construct(
896✔
201
            shortName: $shortName,
896✔
202
            class: $class,
896✔
203
            paginationEnabled: $paginationEnabled,
896✔
204
            paginationType: $paginationType,
896✔
205
            paginationItemsPerPage: $paginationItemsPerPage,
896✔
206
            paginationMaximumItemsPerPage: $paginationMaximumItemsPerPage,
896✔
207
            paginationPartial: $paginationPartial,
896✔
208
            paginationClientEnabled: $paginationClientEnabled,
896✔
209
            paginationClientItemsPerPage: $paginationClientItemsPerPage,
896✔
210
            paginationClientPartial: $paginationClientPartial,
896✔
211
            paginationFetchJoinCollection: $paginationFetchJoinCollection,
896✔
212
            paginationUseOutputWalkers: $paginationUseOutputWalkers,
896✔
213
            order: $order,
896✔
214
            description: $description,
896✔
215
            normalizationContext: $normalizationContext,
896✔
216
            denormalizationContext: $denormalizationContext,
896✔
217
            collectDenormalizationErrors: $collectDenormalizationErrors,
896✔
218
            security: $security,
896✔
219
            securityMessage: $securityMessage,
896✔
220
            securityPostDenormalize: $securityPostDenormalize,
896✔
221
            securityPostDenormalizeMessage: $securityPostDenormalizeMessage,
896✔
222
            securityPostValidation: $securityPostValidation,
896✔
223
            securityPostValidationMessage: $securityPostValidationMessage,
896✔
224
            deprecationReason: $deprecationReason,
896✔
225
            filters: $filters,
896✔
226
            validationContext: $validationContext,
896✔
227
            input: $input,
896✔
228
            output: $output,
896✔
229
            mercure: $mercure,
896✔
230
            messenger: $messenger,
896✔
231
            elasticsearch: $elasticsearch,
896✔
232
            urlGenerationStrategy: $urlGenerationStrategy,
896✔
233
            read: $read,
896✔
234
            deserialize: $deserialize,
896✔
235
            validate: $validate,
896✔
236
            write: $write,
896✔
237
            serialize: $serialize,
896✔
238
            fetchPartial: $fetchPartial,
896✔
239
            forceEager: $forceEager,
896✔
240
            priority: $priority,
896✔
241
            name: $name,
896✔
242
            provider: $provider,
896✔
243
            processor: $processor,
896✔
244
            stateOptions: $stateOptions,
896✔
245
            extraProperties: $extraProperties
896✔
246
        );
896✔
247
    }
248

249
    public function getMethod(): string
250
    {
251
        return $this->method;
540✔
252
    }
253

254
    public function withMethod(string $method): self
255
    {
256
        $self = clone $this;
3✔
257
        $self->method = $method;
3✔
258

259
        return $self;
3✔
260
    }
261

262
    public function getUriTemplate(): ?string
263
    {
264
        return $this->uriTemplate;
189✔
265
    }
266

267
    public function withUriTemplate(string $uriTemplate = null)
268
    {
269
        $self = clone $this;
33✔
270
        $self->uriTemplate = $uriTemplate;
33✔
271

272
        return $self;
33✔
273
    }
274

275
    public function getTypes(): ?array
276
    {
277
        return $this->types;
153✔
278
    }
279

280
    /**
281
     * @param string[]|string $types
282
     */
283
    public function withTypes($types): self
284
    {
285
        $self = clone $this;
12✔
286
        $self->types = (array) $types;
12✔
287

288
        return $self;
12✔
289
    }
290

291
    public function getFormats()
292
    {
293
        return $this->formats;
21✔
294
    }
295

296
    public function withFormats($formats = null): self
297
    {
298
        $self = clone $this;
3✔
299
        $self->formats = $formats;
3✔
300

301
        return $self;
3✔
302
    }
303

304
    public function getInputFormats()
305
    {
306
        return $this->inputFormats;
60✔
307
    }
308

309
    public function withInputFormats($inputFormats = null): self
310
    {
311
        $self = clone $this;
18✔
312
        $self->inputFormats = $inputFormats;
18✔
313

314
        return $self;
18✔
315
    }
316

317
    public function getOutputFormats()
318
    {
319
        return $this->outputFormats;
138✔
320
    }
321

322
    public function withOutputFormats($outputFormats = null): self
323
    {
324
        $self = clone $this;
12✔
325
        $self->outputFormats = $outputFormats;
12✔
326

327
        return $self;
12✔
328
    }
329

330
    public function getUriVariables()
331
    {
332
        return $this->uriVariables;
165✔
333
    }
334

335
    public function withUriVariables($uriVariables): self
336
    {
337
        $self = clone $this;
39✔
338
        $self->uriVariables = $uriVariables;
39✔
339

340
        return $self;
39✔
341
    }
342

343
    public function getRoutePrefix(): ?string
344
    {
345
        return $this->routePrefix;
36✔
346
    }
347

348
    public function withRoutePrefix(string $routePrefix): self
349
    {
350
        $self = clone $this;
6✔
351
        $self->routePrefix = $routePrefix;
6✔
352

353
        return $self;
6✔
354
    }
355

356
    public function getRouteName(): ?string
357
    {
358
        return $this->routeName;
36✔
359
    }
360

361
    public function withRouteName(?string $routeName): self
362
    {
363
        $self = clone $this;
×
364
        $self->routeName = $routeName;
×
365

366
        return $self;
×
367
    }
368

369
    public function getDefaults(): ?array
370
    {
371
        return $this->defaults;
33✔
372
    }
373

374
    public function withDefaults(array $defaults): self
375
    {
376
        $self = clone $this;
6✔
377
        $self->defaults = $defaults;
6✔
378

379
        return $self;
6✔
380
    }
381

382
    public function getRequirements(): ?array
383
    {
384
        return $this->requirements;
33✔
385
    }
386

387
    public function withRequirements(array $requirements): self
388
    {
389
        $self = clone $this;
6✔
390
        $self->requirements = $requirements;
6✔
391

392
        return $self;
6✔
393
    }
394

395
    public function getOptions(): ?array
396
    {
397
        return $this->options;
33✔
398
    }
399

400
    public function withOptions(array $options): self
401
    {
402
        $self = clone $this;
3✔
403
        $self->options = $options;
3✔
404

405
        return $self;
3✔
406
    }
407

408
    public function getStateless(): ?bool
409
    {
410
        return $this->stateless;
33✔
411
    }
412

413
    public function withStateless($stateless): self
414
    {
415
        $self = clone $this;
3✔
416
        $self->stateless = $stateless;
3✔
417

418
        return $self;
3✔
419
    }
420

421
    public function getSunset(): ?string
422
    {
423
        return $this->sunset;
108✔
424
    }
425

426
    public function withSunset(string $sunset): self
427
    {
428
        $self = clone $this;
3✔
429
        $self->sunset = $sunset;
3✔
430

431
        return $self;
3✔
432
    }
433

434
    public function getAcceptPatch(): ?string
435
    {
436
        return $this->acceptPatch;
108✔
437
    }
438

439
    public function withAcceptPatch(string $acceptPatch): self
440
    {
441
        $self = clone $this;
6✔
442
        $self->acceptPatch = $acceptPatch;
6✔
443

444
        return $self;
6✔
445
    }
446

447
    public function getStatus(): ?int
448
    {
449
        return $this->status;
153✔
450
    }
451

452
    public function withStatus(int $status): self
453
    {
454
        $self = clone $this;
24✔
455
        $self->status = $status;
24✔
456

457
        return $self;
24✔
458
    }
459

460
    public function getHost(): ?string
461
    {
462
        return $this->host;
33✔
463
    }
464

465
    public function withHost(string $host): self
466
    {
467
        $self = clone $this;
3✔
468
        $self->host = $host;
3✔
469

470
        return $self;
3✔
471
    }
472

473
    public function getSchemes(): ?array
474
    {
475
        return $this->schemes;
33✔
476
    }
477

478
    public function withSchemes(array $schemes): self
479
    {
480
        $self = clone $this;
3✔
481
        $self->schemes = $schemes;
3✔
482

483
        return $self;
3✔
484
    }
485

486
    public function getCondition(): ?string
487
    {
488
        return $this->condition;
33✔
489
    }
490

491
    public function withCondition(string $condition): self
492
    {
493
        $self = clone $this;
3✔
494
        $self->condition = $condition;
3✔
495

496
        return $self;
3✔
497
    }
498

499
    public function getController(): ?string
500
    {
501
        return $this->controller;
228✔
502
    }
503

504
    public function withController(string $controller): self
505
    {
506
        $self = clone $this;
14✔
507
        $self->controller = $controller;
14✔
508

509
        return $self;
14✔
510
    }
511

512
    public function getCacheHeaders(): ?array
513
    {
514
        return $this->cacheHeaders;
105✔
515
    }
516

517
    public function withCacheHeaders(array $cacheHeaders): self
518
    {
519
        $self = clone $this;
12✔
520
        $self->cacheHeaders = $cacheHeaders;
12✔
521

522
        return $self;
12✔
523
    }
524

525
    public function getPaginationViaCursor(): ?array
526
    {
527
        return $this->paginationViaCursor;
24✔
528
    }
529

530
    public function withPaginationViaCursor(array $paginationViaCursor): self
531
    {
532
        $self = clone $this;
6✔
533
        $self->paginationViaCursor = $paginationViaCursor;
6✔
534

535
        return $self;
6✔
536
    }
537

538
    public function getHydraContext(): ?array
539
    {
540
        return $this->hydraContext;
27✔
541
    }
542

543
    public function withHydraContext(array $hydraContext): self
544
    {
545
        $self = clone $this;
6✔
546
        $self->hydraContext = $hydraContext;
6✔
547

548
        return $self;
6✔
549
    }
550

551
    public function getOpenapiContext(): ?array
552
    {
553
        return $this->openapiContext;
27✔
554
    }
555

556
    public function withOpenapiContext(array $openapiContext): self
557
    {
558
        $self = clone $this;
3✔
559
        $self->openapiContext = $openapiContext;
3✔
560

561
        return $self;
3✔
562
    }
563

564
    public function getOpenapi(): bool|OpenApiOperation|null
565
    {
566
        return $this->openapi;
27✔
567
    }
568

569
    public function withOpenapi(bool|OpenApiOperation $openapi): self
570
    {
571
        $self = clone $this;
3✔
572
        $self->openapi = $openapi;
3✔
573

574
        return $self;
3✔
575
    }
576

577
    public function getExceptionToStatus(): ?array
578
    {
579
        return $this->exceptionToStatus;
66✔
580
    }
581

582
    public function withExceptionToStatus(array $exceptionToStatus): self
583
    {
584
        $self = clone $this;
33✔
585
        $self->exceptionToStatus = $exceptionToStatus;
33✔
586

587
        return $self;
33✔
588
    }
589

590
    public function getQueryParameterValidationEnabled(): ?bool
591
    {
592
        return $this->queryParameterValidationEnabled;
102✔
593
    }
594

595
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): self
596
    {
597
        $self = clone $this;
×
598
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
599

600
        return $self;
×
601
    }
602

603
    public function getLinks(): ?array
604
    {
605
        return $this->links;
82✔
606
    }
607

608
    /**
609
     * @param WebLink[] $links
610
     */
611
    public function withLinks(array $links): self
612
    {
613
        $self = clone $this;
×
614
        $self->links = $links;
×
615

616
        return $self;
×
617
    }
618
}
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

© 2026 Coveralls, Inc