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

api-platform / core / 9809380648

05 Jul 2024 01:51PM UTC coverage: 63.374% (+0.08%) from 63.297%
9809380648

push

github

web-flow
fix(state): allow to skip parameter validator provider (#6452)

23 of 25 new or added lines in 9 files covered. (92.0%)

717 existing lines in 31 files now uncovered.

11143 of 17583 relevant lines covered (63.37%)

52.79 hits per line

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

72.39
/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
     */
37
    public function __construct(
38
        protected ?string $shortName = null,
39
        protected ?string $class = null,
40
        protected ?string $description = null,
41
        protected ?int $urlGenerationStrategy = null,
42
        protected ?string $deprecationReason = null,
43
        protected ?array $normalizationContext = null,
44
        protected ?array $denormalizationContext = null,
45
        protected ?bool $collectDenormalizationErrors = null,
46
        protected ?array $validationContext = null,
47
        protected ?array $filters = null,
48
        protected ?bool $elasticsearch = null,
49
        protected $mercure = null,
50
        protected $messenger = null,
51
        protected $input = null,
52
        protected $output = null,
53
        protected ?array $order = null,
54
        protected ?bool $fetchPartial = null,
55
        protected ?bool $forceEager = null,
56
        protected ?bool $paginationEnabled = null,
57
        protected ?string $paginationType = null,
58
        protected ?int $paginationItemsPerPage = null,
59
        protected ?int $paginationMaximumItemsPerPage = null,
60
        protected ?bool $paginationPartial = null,
61
        protected ?bool $paginationClientEnabled = null,
62
        protected ?bool $paginationClientItemsPerPage = null,
63
        protected ?bool $paginationClientPartial = null,
64
        protected ?bool $paginationFetchJoinCollection = null,
65
        protected ?bool $paginationUseOutputWalkers = null,
66
        protected string|\Stringable|null $security = null,
67
        protected ?string $securityMessage = null,
68
        protected string|\Stringable|null $securityPostDenormalize = null,
69
        protected ?string $securityPostDenormalizeMessage = null,
70
        protected string|\Stringable|null $securityPostValidation = null,
71
        protected ?string $securityPostValidationMessage = null,
72
        protected $provider = null,
73
        protected $processor = null,
74
        protected ?OptionsInterface $stateOptions = null,
75
        /*
76
         * @experimental
77
         */
78
        array|Parameters|null $parameters = null,
79
        protected ?bool $queryParameterValidationEnabled = null,
80
        protected array $extraProperties = []
81
    ) {
82
        if (\is_array($parameters) && $parameters) {
1,119✔
83
            $parameters = new Parameters($parameters);
9✔
84
        }
85

86
        $this->parameters = $parameters;
1,119✔
87
    }
88

89
    public function getShortName(): ?string
90
    {
91
        return $this->shortName;
516✔
92
    }
93

94
    public function withShortName(string $shortName): static
95
    {
96
        $self = clone $this;
274✔
97
        $self->shortName = $shortName;
274✔
98

99
        return $self;
274✔
100
    }
101

102
    public function getClass(): ?string
103
    {
104
        return $this->class;
391✔
105
    }
106

107
    public function withClass(string $class): static
108
    {
109
        $self = clone $this;
212✔
110
        $self->class = $class;
212✔
111

112
        return $self;
212✔
113
    }
114

115
    public function getDescription(): ?string
116
    {
117
        return $this->description;
249✔
118
    }
119

120
    public function withDescription(?string $description = null): static
121
    {
122
        $self = clone $this;
28✔
123
        $self->description = $description;
28✔
124

125
        return $self;
28✔
126
    }
127

128
    public function getUrlGenerationStrategy(): ?int
129
    {
130
        return $this->urlGenerationStrategy;
308✔
131
    }
132

133
    public function withUrlGenerationStrategy(int $urlGenerationStrategy): static
134
    {
135
        $self = clone $this;
4✔
136
        $self->urlGenerationStrategy = $urlGenerationStrategy;
4✔
137

138
        return $self;
4✔
139
    }
140

141
    public function getDeprecationReason(): ?string
142
    {
143
        return $this->deprecationReason;
249✔
144
    }
145

146
    public function withDeprecationReason($deprecationReason): static
147
    {
148
        $self = clone $this;
4✔
149
        $self->deprecationReason = $deprecationReason;
4✔
150

151
        return $self;
4✔
152
    }
153

154
    public function getNormalizationContext(): ?array
155
    {
156
        return $this->normalizationContext;
427✔
157
    }
158

159
    public function withNormalizationContext(array $normalizationContext): static
160
    {
161
        $self = clone $this;
97✔
162
        $self->normalizationContext = $normalizationContext;
97✔
163

164
        return $self;
97✔
165
    }
166

167
    public function getDenormalizationContext(): ?array
168
    {
169
        return $this->denormalizationContext;
304✔
170
    }
171

172
    public function withDenormalizationContext(array $denormalizationContext): static
173
    {
174
        $self = clone $this;
4✔
175
        $self->denormalizationContext = $denormalizationContext;
4✔
176

177
        return $self;
4✔
178
    }
179

180
    public function getCollectDenormalizationErrors(): ?bool
181
    {
182
        return $this->collectDenormalizationErrors;
271✔
183
    }
184

185
    public function withCollectDenormalizationErrors(?bool $collectDenormalizationErrors = null): static
186
    {
187
        $self = clone $this;
4✔
188
        $self->collectDenormalizationErrors = $collectDenormalizationErrors;
4✔
189

190
        return $self;
4✔
191
    }
192

193
    public function getValidationContext(): ?array
194
    {
195
        return $this->validationContext;
273✔
196
    }
197

198
    public function withValidationContext(array $validationContext): static
199
    {
200
        $self = clone $this;
×
201
        $self->validationContext = $validationContext;
×
202

203
        return $self;
×
204
    }
205

206
    /**
207
     * @return string[]|null
208
     */
209
    public function getFilters(): ?array
210
    {
211
        return $this->filters;
311✔
212
    }
213

214
    public function withFilters(array $filters): static
215
    {
216
        $self = clone $this;
38✔
217
        $self->filters = $filters;
38✔
218

219
        return $self;
38✔
220
    }
221

222
    /**
223
     * @deprecated this will be removed in v4
224
     */
225
    public function getElasticsearch(): ?bool
226
    {
227
        return $this->elasticsearch;
26✔
228
    }
229

230
    /**
231
     * @deprecated this will be removed in v4
232
     */
233
    public function withElasticsearch(bool $elasticsearch): static
234
    {
235
        $self = clone $this;
×
236
        $self->elasticsearch = $elasticsearch;
×
237

238
        return $self;
×
239
    }
240

241
    /**
242
     * @return array|bool|mixed|null
243
     */
244
    public function getMercure()
245
    {
246
        return $this->mercure;
283✔
247
    }
248

249
    public function withMercure($mercure): static
250
    {
251
        $self = clone $this;
16✔
252
        $self->mercure = $mercure;
16✔
253

254
        return $self;
16✔
255
    }
256

257
    public function getMessenger()
258
    {
259
        return $this->messenger;
26✔
260
    }
261

262
    public function withMessenger($messenger): static
263
    {
264
        $self = clone $this;
×
265
        $self->messenger = $messenger;
×
266

267
        return $self;
×
268
    }
269

270
    public function getInput()
271
    {
272
        return $this->input;
311✔
273
    }
274

275
    public function withInput($input): static
276
    {
277
        $self = clone $this;
78✔
278
        $self->input = $input;
78✔
279

280
        return $self;
78✔
281
    }
282

283
    public function getOutput()
284
    {
285
        return $this->output;
411✔
286
    }
287

288
    public function withOutput($output): static
289
    {
290
        $self = clone $this;
26✔
291
        $self->output = $output;
26✔
292

293
        return $self;
26✔
294
    }
295

296
    public function getOrder(): ?array
297
    {
298
        return $this->order;
78✔
299
    }
300

301
    public function withOrder(array $order): static
302
    {
303
        $self = clone $this;
4✔
304
        $self->order = $order;
4✔
305

306
        return $self;
4✔
307
    }
308

309
    public function getFetchPartial(): ?bool
310
    {
311
        return $this->fetchPartial;
102✔
312
    }
313

314
    public function withFetchPartial(bool $fetchPartial): static
315
    {
316
        $self = clone $this;
×
317
        $self->fetchPartial = $fetchPartial;
×
318

319
        return $self;
×
320
    }
321

322
    public function getForceEager(): ?bool
323
    {
324
        return $this->forceEager;
102✔
325
    }
326

327
    public function withForceEager(bool $forceEager): static
328
    {
329
        $self = clone $this;
4✔
330
        $self->forceEager = $forceEager;
4✔
331

332
        return $self;
4✔
333
    }
334

335
    public function getPaginationEnabled(): ?bool
336
    {
337
        return $this->paginationEnabled;
101✔
338
    }
339

340
    public function withPaginationEnabled(bool $paginationEnabled): static
341
    {
342
        $self = clone $this;
×
343
        $self->paginationEnabled = $paginationEnabled;
×
344

345
        return $self;
×
346
    }
347

348
    public function getPaginationType(): ?string
349
    {
350
        return $this->paginationType;
26✔
351
    }
352

353
    public function withPaginationType(string $paginationType): static
354
    {
355
        $self = clone $this;
×
356
        $self->paginationType = $paginationType;
×
357

358
        return $self;
×
359
    }
360

361
    public function getPaginationItemsPerPage(): ?int
362
    {
363
        return $this->paginationItemsPerPage;
101✔
364
    }
365

366
    public function withPaginationItemsPerPage(int $paginationItemsPerPage): static
367
    {
368
        $self = clone $this;
14✔
369
        $self->paginationItemsPerPage = $paginationItemsPerPage;
14✔
370

371
        return $self;
14✔
372
    }
373

374
    public function getPaginationMaximumItemsPerPage(): ?int
375
    {
376
        return $this->paginationMaximumItemsPerPage;
101✔
377
    }
378

379
    public function withPaginationMaximumItemsPerPage(int $paginationMaximumItemsPerPage): static
380
    {
381
        $self = clone $this;
×
382
        $self->paginationMaximumItemsPerPage = $paginationMaximumItemsPerPage;
×
383

384
        return $self;
×
385
    }
386

387
    public function getPaginationPartial(): ?bool
388
    {
389
        return $this->paginationPartial;
78✔
390
    }
391

392
    public function withPaginationPartial(bool $paginationPartial): static
393
    {
394
        $self = clone $this;
4✔
395
        $self->paginationPartial = $paginationPartial;
4✔
396

397
        return $self;
4✔
398
    }
399

400
    public function getPaginationClientEnabled(): ?bool
401
    {
402
        return $this->paginationClientEnabled;
101✔
403
    }
404

405
    public function withPaginationClientEnabled(bool $paginationClientEnabled): static
406
    {
407
        $self = clone $this;
14✔
408
        $self->paginationClientEnabled = $paginationClientEnabled;
14✔
409

410
        return $self;
14✔
411
    }
412

413
    public function getPaginationClientItemsPerPage(): ?bool
414
    {
415
        return $this->paginationClientItemsPerPage;
101✔
416
    }
417

418
    public function withPaginationClientItemsPerPage(bool $paginationClientItemsPerPage): static
419
    {
420
        $self = clone $this;
14✔
421
        $self->paginationClientItemsPerPage = $paginationClientItemsPerPage;
14✔
422

423
        return $self;
14✔
424
    }
425

426
    public function getPaginationClientPartial(): ?bool
427
    {
428
        return $this->paginationClientPartial;
78✔
429
    }
430

431
    public function withPaginationClientPartial(bool $paginationClientPartial): static
432
    {
433
        $self = clone $this;
14✔
434
        $self->paginationClientPartial = $paginationClientPartial;
14✔
435

436
        return $self;
14✔
437
    }
438

439
    public function getPaginationFetchJoinCollection(): ?bool
440
    {
441
        return $this->paginationFetchJoinCollection;
78✔
442
    }
443

444
    public function withPaginationFetchJoinCollection(bool $paginationFetchJoinCollection): static
445
    {
446
        $self = clone $this;
×
447
        $self->paginationFetchJoinCollection = $paginationFetchJoinCollection;
×
448

449
        return $self;
×
450
    }
451

452
    public function getPaginationUseOutputWalkers(): ?bool
453
    {
454
        return $this->paginationUseOutputWalkers;
78✔
455
    }
456

457
    public function withPaginationUseOutputWalkers(bool $paginationUseOutputWalkers): static
458
    {
459
        $self = clone $this;
×
460
        $self->paginationUseOutputWalkers = $paginationUseOutputWalkers;
×
461

462
        return $self;
×
463
    }
464

465
    public function getSecurity(): ?string
466
    {
467
        return $this->security instanceof \Stringable ? (string) $this->security : $this->security;
291✔
468
    }
469

470
    public function withSecurity($security): static
471
    {
472
        $self = clone $this;
4✔
473
        $self->security = $security;
4✔
474

475
        return $self;
4✔
476
    }
477

478
    public function getSecurityMessage(): ?string
479
    {
480
        return $this->securityMessage;
291✔
481
    }
482

483
    public function withSecurityMessage(string $securityMessage): static
484
    {
485
        $self = clone $this;
×
486
        $self->securityMessage = $securityMessage;
×
487

488
        return $self;
×
489
    }
490

491
    public function getSecurityPostDenormalize(): ?string
492
    {
493
        return $this->securityPostDenormalize instanceof \Stringable ? (string) $this->securityPostDenormalize : $this->securityPostDenormalize;
267✔
494
    }
495

496
    public function withSecurityPostDenormalize($securityPostDenormalize): static
497
    {
498
        $self = clone $this;
×
499
        $self->securityPostDenormalize = $securityPostDenormalize;
×
500

501
        return $self;
×
502
    }
503

504
    public function getSecurityPostDenormalizeMessage(): ?string
505
    {
506
        return $this->securityPostDenormalizeMessage;
267✔
507
    }
508

509
    public function withSecurityPostDenormalizeMessage(string $securityPostDenormalizeMessage): static
510
    {
511
        $self = clone $this;
×
512
        $self->securityPostDenormalizeMessage = $securityPostDenormalizeMessage;
×
513

514
        return $self;
×
515
    }
516

517
    public function getSecurityPostValidation(): ?string
518
    {
519
        return $this->securityPostValidation instanceof \Stringable ? (string) $this->securityPostValidation : $this->securityPostValidation;
267✔
520
    }
521

522
    public function withSecurityPostValidation(string|\Stringable|null $securityPostValidation = null): static
523
    {
524
        $self = clone $this;
×
525
        $self->securityPostValidation = $securityPostValidation;
×
526

527
        return $self;
×
528
    }
529

530
    public function getSecurityPostValidationMessage(): ?string
531
    {
532
        return $this->securityPostValidationMessage;
267✔
533
    }
534

535
    public function withSecurityPostValidationMessage(?string $securityPostValidationMessage = null): static
536
    {
537
        $self = clone $this;
×
538
        $self->securityPostValidationMessage = $securityPostValidationMessage;
×
539

540
        return $self;
×
541
    }
542

543
    public function getProcessor(): callable|string|null
544
    {
545
        return $this->processor;
93✔
546
    }
547

548
    public function withProcessor(callable|string|null $processor): static
549
    {
550
        $self = clone $this;
32✔
551
        $self->processor = $processor;
32✔
552

553
        return $self;
32✔
554
    }
555

556
    public function getProvider(): callable|string|null
557
    {
558
        return $this->provider;
263✔
559
    }
560

561
    public function withProvider(callable|string|null $provider): static
562
    {
563
        $self = clone $this;
17✔
564
        $self->provider = $provider;
17✔
565

566
        return $self;
17✔
567
    }
568

569
    public function getStateOptions(): ?OptionsInterface
570
    {
571
        return $this->stateOptions;
291✔
572
    }
573

574
    public function withStateOptions(?OptionsInterface $stateOptions): static
575
    {
576
        $self = clone $this;
8✔
577
        $self->stateOptions = $stateOptions;
8✔
578

579
        return $self;
8✔
580
    }
581

582
    public function getParameters(): ?Parameters
583
    {
584
        return $this->parameters;
287✔
585
    }
586

587
    public function withParameters(array|Parameters $parameters): static
588
    {
589
        $self = clone $this;
251✔
590
        $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters;
251✔
591

592
        return $self;
251✔
593
    }
594

595
    public function getQueryParameterValidationEnabled(): ?bool
596
    {
597
        return $this->queryParameterValidationEnabled;
263✔
598
    }
599

600
    public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): static
601
    {
NEW
602
        $self = clone $this;
×
NEW
603
        $self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
×
604

UNCOV
605
        return $self;
×
606
    }
607

608
    public function getExtraProperties(): ?array
609
    {
610
        return $this->extraProperties;
295✔
611
    }
612

613
    public function withExtraProperties(array $extraProperties = []): static
614
    {
615
        $self = clone $this;
26✔
616
        $self->extraProperties = $extraProperties;
26✔
617

618
        return $self;
26✔
619
    }
620
}
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