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

api-platform / core / 15133993414

20 May 2025 09:30AM UTC coverage: 26.313% (-1.2%) from 27.493%
15133993414

Pull #7161

github

web-flow
Merge e2c03d45f into 5459ba375
Pull Request #7161: fix(metadata): infer parameter string type from schema

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

11019 existing lines in 363 files now uncovered.

12898 of 49018 relevant lines covered (26.31%)

34.33 hits per line

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

67.21
/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
 * @internal
20
 */
21
abstract class Metadata
22
{
23
    protected ?Parameters $parameters = null;
24

25
    /**
26
     * @param string|null                                                                       $deprecationReason       https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
27
     * @param string|\Stringable|null                                                           $security                https://api-platform.com/docs/core/security
28
     * @param string|\Stringable|null                                                           $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
29
     * @param mixed|null                                                                        $mercure
30
     * @param mixed|null                                                                        $messenger
31
     * @param mixed|null                                                                        $input
32
     * @param mixed|null                                                                        $output
33
     * @param mixed|null                                                                        $provider
34
     * @param mixed|null                                                                        $processor
35
     * @param Parameters|array<string, Parameter>                                               $parameters
36
     * @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
37
     */
38
    public function __construct(
39
        protected ?string $shortName = null,
40
        protected ?string $class = null,
41
        protected ?string $description = null,
42
        protected ?int $urlGenerationStrategy = null,
43
        protected ?string $deprecationReason = null,
44
        protected ?array $normalizationContext = null,
45
        protected ?array $denormalizationContext = null,
46
        protected ?bool $collectDenormalizationErrors = null,
47
        protected ?array $validationContext = null,
48
        protected ?array $filters = null,
49
        protected ?bool $elasticsearch = 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
        /*
77
         * @experimental
78
         */
79
        array|Parameters|null $parameters = null,
80
        protected mixed $rules = null,
81
        protected ?string $policy = null,
82
        protected array|string|null $middleware = null,
83
        protected ?bool $queryParameterValidationEnabled = null,
84
        protected ?bool $strictQueryParameterValidation = null,
85
        protected ?bool $hideHydraOperation = null,
86
        protected array $extraProperties = [],
87
    ) {
UNCOV
88
        if (\is_array($parameters) && $parameters) {
981✔
UNCOV
89
            $parameters = new Parameters($parameters);
15✔
90
        }
91

UNCOV
92
        $this->parameters = $parameters;
981✔
93
    }
94

95
    public function getShortName(): ?string
96
    {
UNCOV
97
        return $this->shortName;
879✔
98
    }
99

100
    public function withShortName(string $shortName): static
101
    {
UNCOV
102
        $self = clone $this;
105✔
UNCOV
103
        $self->shortName = $shortName;
105✔
104

UNCOV
105
        return $self;
105✔
106
    }
107

108
    public function getClass(): ?string
109
    {
UNCOV
110
        return $this->class;
990✔
111
    }
112

113
    public function withClass(string $class): static
114
    {
UNCOV
115
        $self = clone $this;
826✔
UNCOV
116
        $self->class = $class;
826✔
117

UNCOV
118
        return $self;
826✔
119
    }
120

121
    public function getDescription(): ?string
122
    {
UNCOV
123
        return $this->description;
265✔
124
    }
125

126
    public function withDescription(?string $description = null): static
127
    {
UNCOV
128
        $self = clone $this;
77✔
UNCOV
129
        $self->description = $description;
77✔
130

UNCOV
131
        return $self;
77✔
132
    }
133

134
    public function getUrlGenerationStrategy(): ?int
135
    {
UNCOV
136
        return $this->urlGenerationStrategy;
905✔
137
    }
138

139
    public function withUrlGenerationStrategy(int $urlGenerationStrategy): static
140
    {
141
        $self = clone $this;
1✔
142
        $self->urlGenerationStrategy = $urlGenerationStrategy;
1✔
143

144
        return $self;
1✔
145
    }
146

147
    public function getDeprecationReason(): ?string
148
    {
UNCOV
149
        return $this->deprecationReason;
265✔
150
    }
151

152
    public function withDeprecationReason($deprecationReason): static
153
    {
154
        $self = clone $this;
1✔
155
        $self->deprecationReason = $deprecationReason;
1✔
156

157
        return $self;
1✔
158
    }
159

160
    public function getNormalizationContext(): ?array
161
    {
UNCOV
162
        return $this->normalizationContext;
981✔
163
    }
164

165
    public function withNormalizationContext(array $normalizationContext): static
166
    {
UNCOV
167
        $self = clone $this;
164✔
UNCOV
168
        $self->normalizationContext = $normalizationContext;
164✔
169

UNCOV
170
        return $self;
164✔
171
    }
172

173
    public function getDenormalizationContext(): ?array
174
    {
UNCOV
175
        return $this->denormalizationContext;
748✔
176
    }
177

178
    public function withDenormalizationContext(array $denormalizationContext): static
179
    {
UNCOV
180
        $self = clone $this;
3✔
UNCOV
181
        $self->denormalizationContext = $denormalizationContext;
3✔
182

UNCOV
183
        return $self;
3✔
184
    }
185

186
    public function getCollectDenormalizationErrors(): ?bool
187
    {
UNCOV
188
        return $this->collectDenormalizationErrors;
812✔
189
    }
190

191
    public function withCollectDenormalizationErrors(?bool $collectDenormalizationErrors = null): static
192
    {
193
        $self = clone $this;
×
194
        $self->collectDenormalizationErrors = $collectDenormalizationErrors;
×
195

196
        return $self;
×
197
    }
198

199
    public function getValidationContext(): ?array
200
    {
UNCOV
201
        return $this->validationContext;
319✔
202
    }
203

204
    public function withValidationContext(array $validationContext): static
205
    {
206
        $self = clone $this;
×
207
        $self->validationContext = $validationContext;
×
208

209
        return $self;
×
210
    }
211

212
    /**
213
     * @return string[]|null
214
     */
215
    public function getFilters(): ?array
216
    {
UNCOV
217
        return $this->filters;
964✔
218
    }
219

220
    public function withFilters(array $filters): static
221
    {
UNCOV
222
        $self = clone $this;
67✔
UNCOV
223
        $self->filters = $filters;
67✔
224

UNCOV
225
        return $self;
67✔
226
    }
227

228
    /**
229
     * @deprecated this will be removed in v4
230
     */
231
    public function getElasticsearch(): ?bool
232
    {
UNCOV
233
        return $this->elasticsearch;
68✔
234
    }
235

236
    /**
237
     * @deprecated this will be removed in v4
238
     */
239
    public function withElasticsearch(bool $elasticsearch): static
240
    {
241
        $self = clone $this;
×
242
        $self->elasticsearch = $elasticsearch;
×
243

244
        return $self;
×
245
    }
246

247
    /**
248
     * @return array|bool|mixed|null
249
     */
250
    public function getMercure()
251
    {
UNCOV
252
        return $this->mercure;
953✔
253
    }
254

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

UNCOV
260
        return $self;
2✔
261
    }
262

263
    public function getMessenger()
264
    {
UNCOV
265
        return $this->messenger;
68✔
266
    }
267

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

273
        return $self;
×
274
    }
275

276
    public function getInput()
277
    {
UNCOV
278
        return $this->input;
965✔
279
    }
280

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

UNCOV
286
        return $self;
79✔
287
    }
288

289
    public function getOutput()
290
    {
UNCOV
291
        return $this->output;
975✔
292
    }
293

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

UNCOV
299
        return $self;
65✔
300
    }
301

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

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

312
        return $self;
1✔
313
    }
314

315
    public function getFetchPartial(): ?bool
316
    {
UNCOV
317
        return $this->fetchPartial;
171✔
318
    }
319

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

325
        return $self;
×
326
    }
327

328
    public function getForceEager(): ?bool
329
    {
UNCOV
330
        return $this->forceEager;
171✔
331
    }
332

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

338
        return $self;
1✔
339
    }
340

341
    public function getPaginationEnabled(): ?bool
342
    {
UNCOV
343
        return $this->paginationEnabled;
523✔
344
    }
345

346
    public function withPaginationEnabled(bool $paginationEnabled): static
347
    {
348
        $self = clone $this;
×
349
        $self->paginationEnabled = $paginationEnabled;
×
350

351
        return $self;
×
352
    }
353

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

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

364
        return $self;
×
365
    }
366

367
    public function getPaginationItemsPerPage(): ?int
368
    {
UNCOV
369
        return $this->paginationItemsPerPage;
432✔
370
    }
371

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

UNCOV
377
        return $self;
63✔
378
    }
379

380
    public function getPaginationMaximumItemsPerPage(): ?int
381
    {
UNCOV
382
        return $this->paginationMaximumItemsPerPage;
432✔
383
    }
384

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

390
        return $self;
×
391
    }
392

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

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

403
        return $self;
1✔
404
    }
405

406
    public function getPaginationClientEnabled(): ?bool
407
    {
UNCOV
408
        return $this->paginationClientEnabled;
434✔
409
    }
410

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

UNCOV
416
        return $self;
63✔
417
    }
418

419
    public function getPaginationClientItemsPerPage(): ?bool
420
    {
UNCOV
421
        return $this->paginationClientItemsPerPage;
432✔
422
    }
423

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

UNCOV
429
        return $self;
63✔
430
    }
431

432
    public function getPaginationClientPartial(): ?bool
433
    {
UNCOV
434
        return $this->paginationClientPartial;
163✔
435
    }
436

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

UNCOV
442
        return $self;
63✔
443
    }
444

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

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

455
        return $self;
×
456
    }
457

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

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

468
        return $self;
×
469
    }
470

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

476
    public function withSecurity($security): static
477
    {
UNCOV
478
        $self = clone $this;
4✔
UNCOV
479
        $self->security = $security;
4✔
480

UNCOV
481
        return $self;
4✔
482
    }
483

484
    public function getSecurityMessage(): ?string
485
    {
UNCOV
486
        return $this->securityMessage;
940✔
487
    }
488

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

494
        return $self;
×
495
    }
496

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

502
    public function withSecurityPostDenormalize($securityPostDenormalize): static
503
    {
504
        $self = clone $this;
×
505
        $self->securityPostDenormalize = $securityPostDenormalize;
×
506

507
        return $self;
×
508
    }
509

510
    public function getSecurityPostDenormalizeMessage(): ?string
511
    {
UNCOV
512
        return $this->securityPostDenormalizeMessage;
938✔
513
    }
514

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

520
        return $self;
×
521
    }
522

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

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

533
        return $self;
×
534
    }
535

536
    public function getSecurityPostValidationMessage(): ?string
537
    {
UNCOV
538
        return $this->securityPostValidationMessage;
938✔
539
    }
540

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

546
        return $self;
×
547
    }
548

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

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

UNCOV
559
        return $self;
44✔
560
    }
561

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

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

UNCOV
572
        return $self;
49✔
573
    }
574

575
    public function getStateOptions(): ?OptionsInterface
576
    {
UNCOV
577
        return $this->stateOptions;
901✔
578
    }
579

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

UNCOV
585
        return $self;
41✔
586
    }
587

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

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

604
        return $self;
×
605
    }
606

607
    public function getParameters(): ?Parameters
608
    {
UNCOV
609
        return $this->parameters;
964✔
610
    }
611

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

UNCOV
617
        return $self;
379✔
618
    }
619

620
    public function getQueryParameterValidationEnabled(): ?bool
621
    {
UNCOV
622
        return $this->queryParameterValidationEnabled;
816✔
623
    }
624

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

630
        return $self;
×
631
    }
632

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

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

643
        return $self;
×
644
    }
645

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

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

656
        return $self;
×
657
    }
658

659
    public function getExtraProperties(): ?array
660
    {
UNCOV
661
        return $this->extraProperties;
760✔
662
    }
663

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

UNCOV
669
        return $self;
68✔
670
    }
671

672
    public function getStrictQueryParameterValidation(): ?bool
673
    {
UNCOV
674
        return $this->strictQueryParameterValidation;
816✔
675
    }
676

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

682
        return $self;
×
683
    }
684

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

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

UNCOV
695
        return $self;
2✔
696
    }
697
}
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