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

api-platform / core / 20847864477

09 Jan 2026 09:47AM UTC coverage: 29.1% (+0.005%) from 29.095%
20847864477

Pull #7649

github

web-flow
Merge b342dd5db into d640d106b
Pull Request #7649: feat(validator): uuid/ulid parameter validation

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

15050 existing lines in 491 files now uncovered.

16996 of 58406 relevant lines covered (29.1%)

81.8 hits per line

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

72.73
/src/Metadata/Metadata.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\State\OptionsInterface;
17

18
/**
19
 * @psalm-inheritors ApiResource|Operation
20
 */
21
abstract class Metadata
22
{
23
    protected ?Parameters $parameters = null;
24

25
    /**
26
     * @param class-string                                                                      $class
27
     * @param string|null                                                                       $deprecationReason       https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
28
     * @param string|\Stringable|null                                                           $security                https://api-platform.com/docs/core/security
29
     * @param string|\Stringable|null                                                           $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
30
     * @param mixed|null                                                                        $mercure
31
     * @param mixed|null                                                                        $messenger
32
     * @param mixed|null                                                                        $input
33
     * @param mixed|null                                                                        $output
34
     * @param mixed|null                                                                        $provider
35
     * @param mixed|null                                                                        $processor
36
     * @param Parameters|array<string, Parameter>                                               $parameters
37
     * @param callable|string|array<string, \Illuminate\Contracts\Validation\Rule|array|string> $rules                   Laravel rules can be a FormRequest class, a callable or an array of rules
38
     */
39
    public function __construct(
40
        protected ?string $shortName = null,
41
        protected ?string $class = null,
42
        protected ?string $description = null,
43
        protected ?int $urlGenerationStrategy = null,
44
        protected ?string $deprecationReason = null,
45
        protected ?array $normalizationContext = null,
46
        protected ?array $denormalizationContext = null,
47
        protected ?bool $collectDenormalizationErrors = null,
48
        protected ?array $validationContext = null,
49
        protected ?array $filters = null,
50
        protected $mercure = null,
51
        protected $messenger = null,
52
        protected $input = null,
53
        protected $output = null,
54
        protected ?array $order = null,
55
        protected ?bool $fetchPartial = null,
56
        protected ?bool $forceEager = null,
57
        protected ?bool $paginationEnabled = null,
58
        protected ?string $paginationType = null,
59
        protected ?int $paginationItemsPerPage = null,
60
        protected ?int $paginationMaximumItemsPerPage = null,
61
        protected ?bool $paginationPartial = null,
62
        protected ?bool $paginationClientEnabled = null,
63
        protected ?bool $paginationClientItemsPerPage = null,
64
        protected ?bool $paginationClientPartial = null,
65
        protected ?bool $paginationFetchJoinCollection = null,
66
        protected ?bool $paginationUseOutputWalkers = null,
67
        protected string|\Stringable|null $security = null,
68
        protected ?string $securityMessage = null,
69
        protected string|\Stringable|null $securityPostDenormalize = null,
70
        protected ?string $securityPostDenormalizeMessage = null,
71
        protected string|\Stringable|null $securityPostValidation = null,
72
        protected ?string $securityPostValidationMessage = null,
73
        protected $provider = null,
74
        protected $processor = null,
75
        protected ?OptionsInterface $stateOptions = null,
76
        array|Parameters|null $parameters = null,
77
        protected mixed $rules = null,
78
        protected ?string $policy = null,
79
        protected array|string|null $middleware = null,
80
        protected ?bool $queryParameterValidationEnabled = null,
81
        protected ?bool $strictQueryParameterValidation = null,
82
        protected ?bool $hideHydraOperation = null,
83
        protected ?bool $jsonStream = null,
84
        protected ?bool $map = null,
85
        protected array $extraProperties = [],
86
    ) {
UNCOV
87
        if (\is_array($parameters) && $parameters) {
2,408✔
UNCOV
88
            $parameters = new Parameters($parameters);
49✔
89
        }
90

UNCOV
91
        $this->parameters = $parameters;
2,408✔
92
    }
93

94
    public function canMap(): ?bool
95
    {
UNCOV
96
        return $this->map;
2,364✔
97
    }
98

99
    public function withMap(bool $map): static
100
    {
UNCOV
101
        $self = clone $this;
5✔
UNCOV
102
        $self->map = $map;
5✔
103

UNCOV
104
        return $self;
5✔
105
    }
106

107
    public function getShortName(): ?string
108
    {
UNCOV
109
        return $this->shortName;
2,177✔
110
    }
111

112
    public function withShortName(string $shortName): static
113
    {
UNCOV
114
        $self = clone $this;
280✔
UNCOV
115
        $self->shortName = $shortName;
280✔
116

UNCOV
117
        return $self;
280✔
118
    }
119

120
    /**
121
     * @return class-string|null
122
     */
123
    public function getClass(): ?string
124
    {
UNCOV
125
        return $this->class;
2,533✔
126
    }
127

128
    /**
129
     * @param class-string $class
130
     */
131
    public function withClass(string $class): static
132
    {
UNCOV
133
        $self = clone $this;
2,033✔
UNCOV
134
        $self->class = $class;
2,033✔
135

UNCOV
136
        return $self;
2,033✔
137
    }
138

139
    public function getDescription(): ?string
140
    {
UNCOV
141
        return $this->description;
657✔
142
    }
143

144
    public function withDescription(?string $description = null): static
145
    {
UNCOV
146
        $self = clone $this;
243✔
UNCOV
147
        $self->description = $description;
243✔
148

UNCOV
149
        return $self;
243✔
150
    }
151

152
    public function getUrlGenerationStrategy(): ?int
153
    {
UNCOV
154
        return $this->urlGenerationStrategy;
2,305✔
155
    }
156

157
    public function withUrlGenerationStrategy(int $urlGenerationStrategy): static
158
    {
159
        $self = clone $this;
2✔
160
        $self->urlGenerationStrategy = $urlGenerationStrategy;
2✔
161

162
        return $self;
2✔
163
    }
164

165
    public function getDeprecationReason(): ?string
166
    {
UNCOV
167
        return $this->deprecationReason;
657✔
168
    }
169

170
    /**
171
     * @param string $deprecationReason
172
     */
173
    public function withDeprecationReason($deprecationReason): static
174
    {
UNCOV
175
        $self = clone $this;
4✔
UNCOV
176
        $self->deprecationReason = $deprecationReason;
4✔
177

UNCOV
178
        return $self;
4✔
179
    }
180

181
    public function getNormalizationContext(): ?array
182
    {
UNCOV
183
        return $this->normalizationContext;
2,482✔
184
    }
185

186
    public function withNormalizationContext(array $normalizationContext): static
187
    {
UNCOV
188
        $self = clone $this;
500✔
UNCOV
189
        $self->normalizationContext = $normalizationContext;
500✔
190

UNCOV
191
        return $self;
500✔
192
    }
193

194
    public function getDenormalizationContext(): ?array
195
    {
UNCOV
196
        return $this->denormalizationContext;
2,450✔
197
    }
198

199
    public function withDenormalizationContext(array $denormalizationContext): static
200
    {
UNCOV
201
        $self = clone $this;
477✔
UNCOV
202
        $self->denormalizationContext = $denormalizationContext;
477✔
203

UNCOV
204
        return $self;
477✔
205
    }
206

207
    public function getCollectDenormalizationErrors(): ?bool
208
    {
UNCOV
209
        return $this->collectDenormalizationErrors;
2,119✔
210
    }
211

212
    public function withCollectDenormalizationErrors(?bool $collectDenormalizationErrors = null): static
213
    {
UNCOV
214
        $self = clone $this;
3✔
UNCOV
215
        $self->collectDenormalizationErrors = $collectDenormalizationErrors;
3✔
216

UNCOV
217
        return $self;
3✔
218
    }
219

220
    public function getValidationContext(): ?array
221
    {
UNCOV
222
        return $this->validationContext;
823✔
223
    }
224

225
    public function withValidationContext(array $validationContext): static
226
    {
227
        $self = clone $this;
×
228
        $self->validationContext = $validationContext;
×
229

230
        return $self;
×
231
    }
232

233
    /**
234
     * @return string[]|null
235
     */
236
    public function getFilters(): ?array
237
    {
UNCOV
238
        return $this->filters;
2,435✔
239
    }
240

241
    public function withFilters(array $filters): static
242
    {
UNCOV
243
        $self = clone $this;
207✔
UNCOV
244
        $self->filters = $filters;
207✔
245

UNCOV
246
        return $self;
207✔
247
    }
248

249
    public function getMercure(): mixed
250
    {
UNCOV
251
        return $this->mercure;
2,395✔
252
    }
253

254
    public function withMercure(mixed $mercure): static
255
    {
UNCOV
256
        $self = clone $this;
4✔
UNCOV
257
        $self->mercure = $mercure;
4✔
258

UNCOV
259
        return $self;
4✔
260
    }
261

262
    public function getMessenger(): mixed
263
    {
UNCOV
264
        return $this->messenger;
209✔
265
    }
266

267
    public function withMessenger(mixed $messenger): static
268
    {
269
        $self = clone $this;
×
270
        $self->messenger = $messenger;
×
271

272
        return $self;
×
273
    }
274

275
    public function getInput(): mixed
276
    {
UNCOV
277
        return $this->input;
2,451✔
278
    }
279

280
    public function withInput(mixed $input): static
281
    {
UNCOV
282
        $self = clone $this;
233✔
UNCOV
283
        $self->input = $input;
233✔
284

UNCOV
285
        return $self;
233✔
286
    }
287

288
    public function getOutput(): mixed
289
    {
UNCOV
290
        return $this->output;
2,487✔
291
    }
292

293
    public function withOutput(mixed $output): static
294
    {
UNCOV
295
        $self = clone $this;
203✔
UNCOV
296
        $self->output = $output;
203✔
297

UNCOV
298
        return $self;
203✔
299
    }
300

301
    public function getOrder(): ?array
302
    {
UNCOV
303
        return $this->order;
963✔
304
    }
305

306
    public function withOrder(array $order): static
307
    {
308
        $self = clone $this;
2✔
309
        $self->order = $order;
2✔
310

311
        return $self;
2✔
312
    }
313

314
    public function getFetchPartial(): ?bool
315
    {
UNCOV
316
        return $this->fetchPartial;
1,038✔
317
    }
318

319
    public function withFetchPartial(bool $fetchPartial): static
320
    {
321
        $self = clone $this;
×
322
        $self->fetchPartial = $fetchPartial;
×
323

324
        return $self;
×
325
    }
326

327
    public function getForceEager(): ?bool
328
    {
UNCOV
329
        return $this->forceEager;
1,038✔
330
    }
331

332
    public function withForceEager(bool $forceEager): static
333
    {
334
        $self = clone $this;
2✔
335
        $self->forceEager = $forceEager;
2✔
336

337
        return $self;
2✔
338
    }
339

340
    public function getPaginationEnabled(): ?bool
341
    {
UNCOV
342
        return $this->paginationEnabled;
1,283✔
343
    }
344

345
    public function withPaginationEnabled(bool $paginationEnabled): static
346
    {
UNCOV
347
        $self = clone $this;
3✔
UNCOV
348
        $self->paginationEnabled = $paginationEnabled;
3✔
349

UNCOV
350
        return $self;
3✔
351
    }
352

353
    public function getPaginationType(): ?string
354
    {
UNCOV
355
        return $this->paginationType;
494✔
356
    }
357

358
    public function withPaginationType(string $paginationType): static
359
    {
360
        $self = clone $this;
×
361
        $self->paginationType = $paginationType;
×
362

363
        return $self;
×
364
    }
365

366
    public function getPaginationItemsPerPage(): ?int
367
    {
UNCOV
368
        return $this->paginationItemsPerPage;
1,060✔
369
    }
370

371
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
372
    {
UNCOV
373
        $self = clone $this;
191✔
UNCOV
374
        $self->paginationItemsPerPage = $paginationItemsPerPage;
191✔
375

UNCOV
376
        return $self;
191✔
377
    }
378

379
    public function getPaginationMaximumItemsPerPage(): ?int
380
    {
UNCOV
381
        return $this->paginationMaximumItemsPerPage;
1,060✔
382
    }
383

384
    public function withPaginationMaximumItemsPerPage(int $paginationMaximumItemsPerPage): static
385
    {
386
        $self = clone $this;
×
387
        $self->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
×
388

389
        return $self;
×
390
    }
391

392
    public function getPaginationPartial(): ?bool
393
    {
UNCOV
394
        return $this->paginationPartial;
995✔
395
    }
396

397
    public function withPaginationPartial(bool $paginationPartial): static
398
    {
399
        $self = clone $this;
2✔
400
        $self->paginationPartial = $paginationPartial;
2✔
401

402
        return $self;
2✔
403
    }
404

405
    public function getPaginationClientEnabled(): ?bool
406
    {
UNCOV
407
        return $this->paginationClientEnabled;
1,025✔
408
    }
409

410
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
411
    {
UNCOV
412
        $self = clone $this;
191✔
UNCOV
413
        $self->paginationClientEnabled = $paginationClientEnabled;
191✔
414

UNCOV
415
        return $self;
191✔
416
    }
417

418
    public function getPaginationClientItemsPerPage(): ?bool
419
    {
UNCOV
420
        return $this->paginationClientItemsPerPage;
1,060✔
421
    }
422

423
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
424
    {
UNCOV
425
        $self = clone $this;
191✔
UNCOV
426
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
191✔
427

UNCOV
428
        return $self;
191✔
429
    }
430

431
    public function getPaginationClientPartial(): ?bool
432
    {
UNCOV
433
        return $this->paginationClientPartial;
1,060✔
434
    }
435

436
    public function withPaginationClientPartial(bool $paginationClientPartial): static
437
    {
UNCOV
438
        $self = clone $this;
191✔
UNCOV
439
        $self->paginationClientPartial = $paginationClientPartial;
191✔
440

UNCOV
441
        return $self;
191✔
442
    }
443

444
    public function getPaginationFetchJoinCollection(): ?bool
445
    {
UNCOV
446
        return $this->paginationFetchJoinCollection;
749✔
447
    }
448

449
    public function withPaginationFetchJoinCollection(bool $paginationFetchJoinCollection): static
450
    {
451
        $self = clone $this;
×
452
        $self->paginationFetchJoinCollection = $paginationFetchJoinCollection;
×
453

454
        return $self;
×
455
    }
456

457
    public function getPaginationUseOutputWalkers(): ?bool
458
    {
UNCOV
459
        return $this->paginationUseOutputWalkers;
749✔
460
    }
461

462
    public function withPaginationUseOutputWalkers(bool $paginationUseOutputWalkers): static
463
    {
464
        $self = clone $this;
×
465
        $self->paginationUseOutputWalkers = $paginationUseOutputWalkers;
×
466

467
        return $self;
×
468
    }
469

470
    public function getSecurity(): ?string
471
    {
UNCOV
472
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
2,390✔
473
    }
474

475
    public function withSecurity(string|\Stringable|null $security = null): static
476
    {
UNCOV
477
        $self = clone $this;
8✔
UNCOV
478
        $self->security = $security;
8✔
479

UNCOV
480
        return $self;
8✔
481
    }
482

483
    public function getSecurityMessage(): ?string
484
    {
UNCOV
485
        return $this->securityMessage;
2,356✔
486
    }
487

488
    public function withSecurityMessage(string $securityMessage): static
489
    {
490
        $self = clone $this;
×
491
        $self->securityMessage = $securityMessage;
×
492

493
        return $self;
×
494
    }
495

496
    public function getSecurityPostDenormalize(): ?string
497
    {
UNCOV
498
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
2,040✔
499
    }
500

501
    public function withSecurityPostDenormalize(string|\Stringable|null $securityPostDenormalize = null): static
502
    {
503
        $self = clone $this;
×
504
        $self->securityPostDenormalize = $securityPostDenormalize;
×
505

506
        return $self;
×
507
    }
508

509
    public function getSecurityPostDenormalizeMessage(): ?string
510
    {
UNCOV
511
        return $this->securityPostDenormalizeMessage;
2,040✔
512
    }
513

514
    public function withSecurityPostDenormalizeMessage(string $securityPostDenormalizeMessage): static
515
    {
516
        $self = clone $this;
×
517
        $self->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
×
518

519
        return $self;
×
520
    }
521

522
    public function getSecurityPostValidation(): ?string
523
    {
UNCOV
524
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
2,317✔
525
    }
526

527
    public function withSecurityPostValidation(string|\Stringable|null $securityPostValidation = null): static
528
    {
529
        $self = clone $this;
×
530
        $self->securityPostValidation = $securityPostValidation;
×
531

532
        return $self;
×
533
    }
534

535
    public function getSecurityPostValidationMessage(): ?string
536
    {
UNCOV
537
        return $this->securityPostValidationMessage;
2,317✔
538
    }
539

540
    public function withSecurityPostValidationMessage(?string $securityPostValidationMessage = null): static
541
    {
542
        $self = clone $this;
×
543
        $self->securityPostValidationMessage = $securityPostValidationMessage;
×
544

545
        return $self;
×
546
    }
547

548
    public function getProcessor(): callable|string|null
549
    {
UNCOV
550
        return $this->processor;
769✔
551
    }
552

553
    public function withProcessor(callable|string|null $processor): static
554
    {
UNCOV
555
        $self = clone $this;
132✔
UNCOV
556
        $self->processor = $processor;
132✔
557

UNCOV
558
        return $self;
132✔
559
    }
560

561
    public function getProvider(): callable|string|null
562
    {
UNCOV
563
        return $this->provider;
2,106✔
564
    }
565

566
    public function withProvider(callable|string|null $provider): static
567
    {
UNCOV
568
        $self = clone $this;
146✔
UNCOV
569
        $self->provider = $provider;
146✔
570

UNCOV
571
        return $self;
146✔
572
    }
573

574
    public function getStateOptions(): ?OptionsInterface
575
    {
UNCOV
576
        return $this->stateOptions;
2,393✔
577
    }
578

579
    public function withStateOptions(?OptionsInterface $stateOptions): static
580
    {
UNCOV
581
        $self = clone $this;
120✔
UNCOV
582
        $self->stateOptions = $stateOptions;
120✔
583

UNCOV
584
        return $self;
120✔
585
    }
586

587
    /**
588
     * @return string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string>
589
     */
590
    public function getRules(): mixed
591
    {
UNCOV
592
        return $this->rules;
209✔
593
    }
594

595
    /**
596
     * @param string|callable|array<string, \Illuminate\Contracts\Validation\Rule|array|string> $rules
597
     */
598
    public function withRules(mixed $rules): static
599
    {
600
        $self = clone $this;
×
601
        $self->rules = $rules;
×
602

603
        return $self;
×
604
    }
605

606
    public function getParameters(): ?Parameters
607
    {
UNCOV
608
        return $this->parameters;
2,433✔
609
    }
610

611
    public function withParameters(array|Parameters $parameters): static
612
    {
UNCOV
613
        $self = clone $this;
992✔
UNCOV
614
        $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters;
992✔
615

UNCOV
616
        return $self;
992✔
617
    }
618

619
    public function getQueryParameterValidationEnabled(): ?bool
620
    {
UNCOV
621
        return $this->queryParameterValidationEnabled;
2,095✔
622
    }
623

624
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): static
625
    {
626
        $self = clone $this;
×
627
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
628

629
        return $self;
×
630
    }
631

632
    public function getPolicy(): ?string
633
    {
UNCOV
634
        return $this->policy;
209✔
635
    }
636

637
    public function withPolicy(string $policy): static
638
    {
639
        $self = clone $this;
×
640
        $self->policy = $policy;
×
641

642
        return $self;
×
643
    }
644

645
    public function getMiddleware(): mixed
646
    {
UNCOV
647
        return $this->middleware;
209✔
648
    }
649

650
    public function withMiddleware(string|array $middleware): static
651
    {
652
        $self = clone $this;
×
653
        $self->middleware = $middleware;
×
654

655
        return $self;
×
656
    }
657

658
    public function getExtraProperties(): ?array
659
    {
UNCOV
660
        return $this->extraProperties;
1,604✔
661
    }
662

663
    public function withExtraProperties(array $extraProperties = []): static
664
    {
UNCOV
665
        $self = clone $this;
209✔
UNCOV
666
        $self->extraProperties = $extraProperties;
209✔
667

UNCOV
668
        return $self;
209✔
669
    }
670

671
    public function getStrictQueryParameterValidation(): ?bool
672
    {
UNCOV
673
        return $this->strictQueryParameterValidation;
2,097✔
674
    }
675

676
    public function withStrictQueryParameterValidation(bool $strictQueryParameterValidation): static
677
    {
678
        $self = clone $this;
×
679
        $self->strictQueryParameterValidation = $strictQueryParameterValidation;
×
680

681
        return $self;
×
682
    }
683

684
    public function getHideHydraOperation(): ?bool
685
    {
UNCOV
686
        return $this->hideHydraOperation;
227✔
687
    }
688

689
    public function withHideHydraOperation(bool $hideHydraOperation): static
690
    {
UNCOV
691
        $self = clone $this;
4✔
UNCOV
692
        $self->hideHydraOperation = $hideHydraOperation;
4✔
693

UNCOV
694
        return $self;
4✔
695
    }
696

697
    public function getJsonStream(): ?bool
698
    {
UNCOV
699
        return $this->jsonStream;
2,094✔
700
    }
701

702
    public function withJsonStream(bool $jsonStream): static
703
    {
UNCOV
704
        $self = clone $this;
3✔
UNCOV
705
        $self->jsonStream = $jsonStream;
3✔
706

UNCOV
707
        return $self;
3✔
708
    }
709
}
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