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

api-platform / core / 18118664137

30 Sep 2025 04:22AM UTC coverage: 0.0% (-22.0%) from 21.956%
18118664137

Pull #7397

github

web-flow
Merge d1e60d9d5 into 55fd65795
Pull Request #7397: fix(jsonschema/jsonld): make `@id` and `@type` properties required only in the JSON-LD schema for output

0 of 17 new or added lines in 2 files covered. (0.0%)

12143 existing lines in 402 files now uncovered.

0 of 53916 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/Parameter.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\Parameter as OpenApiParameter;
17
use ApiPlatform\State\ParameterNotFound;
18
use ApiPlatform\State\ParameterProviderInterface;
19
use Symfony\Component\TypeInfo\Type;
20

21
abstract class Parameter
22
{
23
    /**
24
     * @param (array<string, mixed>&array{type?: string, default?: mixed})|null $schema
25
     * @param array<string, mixed>                                              $extraProperties
26
     * @param ParameterProviderInterface|callable|string|null                   $provider
27
     * @param list<string>                                                      $properties       a list of properties this parameter applies to (works with the :property placeholder)
28
     * @param FilterInterface|string|null                                       $filter
29
     * @param mixed                                                             $constraints      an array of Symfony constraints, or an array of Laravel rules
30
     * @param Type                                                              $nativeType       the PHP native type, we cast values to an array if its a CollectionType, if not and it's an array with a single value we use it (eg: HTTP Header)
31
     * @param ?bool                                                             $castToNativeType whether API Platform should cast your parameter to the nativeType declared
32
     * @param ?callable(mixed): mixed                                           $castFn           the closure used to cast your parameter, this gets called only when $castToNativeType is set
33
     */
34
    public function __construct(
35
        protected ?string $key = null,
36
        protected ?array $schema = null,
37
        protected OpenApiParameter|array|false|null $openApi = null,
38
        protected mixed $provider = null,
39
        protected mixed $filter = null,
40
        protected ?string $property = null,
41
        protected ?string $description = null,
42
        protected ?array $properties = null,
43
        protected ?bool $required = null,
44
        protected ?int $priority = null,
45
        protected ?false $hydra = null,
46
        protected mixed $constraints = null,
47
        protected string|\Stringable|null $security = null,
48
        protected ?string $securityMessage = null,
49
        protected ?array $extraProperties = [],
50
        protected array|string|null $filterContext = null,
51
        protected ?Type $nativeType = null,
52
        protected ?bool $castToArray = null,
53
        protected ?bool $castToNativeType = null,
54
        protected mixed $castFn = null,
55
    ) {
UNCOV
56
    }
×
57

58
    public function getKey(): ?string
59
    {
UNCOV
60
        return $this->key;
×
61
    }
62

63
    /**
64
     * @return (array<string, mixed>&array{type?: string, default?: mixed})|null $schema
65
     */
66
    public function getSchema(): ?array
67
    {
UNCOV
68
        return $this->schema;
×
69
    }
70

71
    /**
72
     * @return OpenApiParameter[]|OpenApiParameter|bool|null
73
     */
74
    public function getOpenApi(): OpenApiParameter|array|bool|null
75
    {
UNCOV
76
        return $this->openApi;
×
77
    }
78

79
    public function getProvider(): mixed
80
    {
UNCOV
81
        return $this->provider;
×
82
    }
83

84
    public function getProperty(): ?string
85
    {
UNCOV
86
        return $this->property;
×
87
    }
88

89
    public function getFilter(): mixed
90
    {
UNCOV
91
        return $this->filter;
×
92
    }
93

94
    public function getDescription(): ?string
95
    {
UNCOV
96
        return $this->description;
×
97
    }
98

99
    public function getRequired(): ?bool
100
    {
UNCOV
101
        return $this->required;
×
102
    }
103

104
    public function getPriority(): ?int
105
    {
UNCOV
106
        return $this->priority;
×
107
    }
108

109
    public function getHydra(): ?bool
110
    {
UNCOV
111
        return $this->hydra;
×
112
    }
113

114
    public function getConstraints(): mixed
115
    {
UNCOV
116
        return $this->constraints;
×
117
    }
118

119
    public function getSecurity(): string|\Stringable|null
120
    {
UNCOV
121
        return $this->security;
×
122
    }
123

124
    public function getSecurityMessage(): ?string
125
    {
UNCOV
126
        return $this->securityMessage;
×
127
    }
128

129
    /**
130
     * The computed value of this parameter, located into extraProperties['_api_values'].
131
     */
132
    public function getValue(mixed $default = new ParameterNotFound()): mixed
133
    {
UNCOV
134
        return $this->extraProperties['_api_values'] ?? $default;
×
135
    }
136

137
    /**
138
     * Only use this in a parameter provider, the ApiPlatform\State\Provider\ParameterProvider
139
     * resets this value to extract the correct value on each request.
140
     * It's also possible to set the `_api_query_parameters` request attribute directly and
141
     * API Platform will extract the value from there.
142
     */
143
    public function setValue(mixed $value): static
144
    {
UNCOV
145
        $this->extraProperties['_api_values'] = $value;
×
146

UNCOV
147
        return $this;
×
148
    }
149

150
    /**
151
     * @return array<string, mixed>
152
     */
153
    public function getExtraProperties(): array
154
    {
UNCOV
155
        return $this->extraProperties;
×
156
    }
157

158
    public function getFilterContext(): array|string|null
159
    {
UNCOV
160
        return $this->filterContext;
×
161
    }
162

163
    public function withKey(string $key): static
164
    {
UNCOV
165
        $self = clone $this;
×
UNCOV
166
        $self->key = $key;
×
167

UNCOV
168
        return $self;
×
169
    }
170

171
    public function withPriority(int $priority): static
172
    {
UNCOV
173
        $self = clone $this;
×
UNCOV
174
        $self->priority = $priority;
×
175

UNCOV
176
        return $self;
×
177
    }
178

179
    /**
180
     * @param array{type?: string} $schema
181
     */
182
    public function withSchema(array $schema): static
183
    {
UNCOV
184
        $self = clone $this;
×
UNCOV
185
        $self->schema = $schema;
×
186

UNCOV
187
        return $self;
×
188
    }
189

190
    /**
191
     * @param OpenApiParameter[]|OpenApiParameter|bool $openApi
192
     */
193
    public function withOpenApi(OpenApiParameter|array|bool $openApi): static
194
    {
UNCOV
195
        $self = clone $this;
×
UNCOV
196
        $self->openApi = $openApi;
×
197

UNCOV
198
        return $self;
×
199
    }
200

201
    /**
202
     * @param ParameterProviderInterface|string $provider
203
     */
204
    public function withProvider(mixed $provider): static
205
    {
UNCOV
206
        $self = clone $this;
×
UNCOV
207
        $self->provider = $provider;
×
208

UNCOV
209
        return $self;
×
210
    }
211

212
    /**
213
     * @param FilterInterface|string $filter
214
     */
215
    public function withFilter(mixed $filter): static
216
    {
217
        $self = clone $this;
×
218
        $self->filter = $filter;
×
219

220
        return $self;
×
221
    }
222

223
    public function withFilterContext(array|string $filterContext): static
224
    {
225
        $self = clone $this;
×
226
        $self->filterContext = $filterContext;
×
227

228
        return $self;
×
229
    }
230

231
    public function withProperty(string $property): static
232
    {
UNCOV
233
        $self = clone $this;
×
UNCOV
234
        $self->property = $property;
×
235

UNCOV
236
        return $self;
×
237
    }
238

239
    public function withDescription(string $description): static
240
    {
241
        $self = clone $this;
×
242
        $self->description = $description;
×
243

244
        return $self;
×
245
    }
246

247
    public function withRequired(bool $required): static
248
    {
249
        $self = clone $this;
×
250
        $self->required = $required;
×
251

252
        return $self;
×
253
    }
254

255
    public function withHydra(false $hydra): static
256
    {
257
        $self = clone $this;
×
258
        $self->hydra = $hydra;
×
259

260
        return $self;
×
261
    }
262

263
    public function withConstraints(mixed $constraints): static
264
    {
UNCOV
265
        $self = clone $this;
×
UNCOV
266
        $self->constraints = $constraints;
×
267

UNCOV
268
        return $self;
×
269
    }
270

271
    public function withSecurity(string|\Stringable|null $security): static
272
    {
273
        $self = clone $this;
×
274
        $self->security = $security;
×
275

276
        return $self;
×
277
    }
278

279
    public function withSecurityMessage(?string $securityMessage): static
280
    {
281
        $self = clone $this;
×
282
        $self->securityMessage = $securityMessage;
×
283

284
        return $self;
×
285
    }
286

287
    /**
288
     * @param array<string, mixed> $extraProperties
289
     */
290
    public function withExtraProperties(array $extraProperties): static
291
    {
UNCOV
292
        $self = clone $this;
×
UNCOV
293
        $self->extraProperties = $extraProperties;
×
294

UNCOV
295
        return $self;
×
296
    }
297

298
    public function getProperties(): ?array
299
    {
UNCOV
300
        return $this->properties;
×
301
    }
302

303
    public function withProperties(?array $properties): self
304
    {
305
        $self = clone $this;
×
306
        $self->properties = $properties;
×
307

308
        return $self;
×
309
    }
310

311
    public function getNativeType(): ?Type
312
    {
UNCOV
313
        return $this->nativeType;
×
314
    }
315

316
    public function withNativeType(Type $nativeType): self
317
    {
UNCOV
318
        $self = clone $this;
×
UNCOV
319
        $self->nativeType = $nativeType;
×
320

UNCOV
321
        return $self;
×
322
    }
323

324
    public function getCastToArray(): ?bool
325
    {
UNCOV
326
        return $this->castToArray;
×
327
    }
328

329
    public function withCastToArray(bool $castToArray): self
330
    {
331
        $self = clone $this;
×
332
        $self->castToArray = $castToArray;
×
333

334
        return $self;
×
335
    }
336

337
    public function getCastToNativeType(): ?bool
338
    {
UNCOV
339
        return $this->castToNativeType;
×
340
    }
341

342
    public function withCastToNativeType(bool $castToNativeType): self
343
    {
344
        $self = clone $this;
×
345
        $self->castToNativeType = $castToNativeType;
×
346

347
        return $self;
×
348
    }
349

350
    public function getCastFn(): ?callable
351
    {
UNCOV
352
        return $this->castFn;
×
353
    }
354

355
    /**
356
     * @param callable(mixed): mixed $castFn
357
     */
358
    public function withCastFn(mixed $castFn): self
359
    {
UNCOV
360
        $self = clone $this;
×
UNCOV
361
        $self->castFn = $castFn;
×
362

UNCOV
363
        return $self;
×
364
    }
365
}
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