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

api-platform / core / 18223414080

03 Oct 2025 01:18PM UTC coverage: 0.0% (-22.0%) from 21.956%
18223414080

Pull #7397

github

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

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

12304 existing lines in 405 files now uncovered.

0 of 53965 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>|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
     * @phpstan-param array<string, mixed>|null $schema
35
     *
36
     * @psalm-param array{type?: string, default?: mixed, ...<string, mixed>}|null $schema
37
     */
38
    public function __construct(
39
        protected ?string $key = null,
40
        protected ?array $schema = null,
41
        protected OpenApiParameter|array|false|null $openApi = null,
42
        protected mixed $provider = null,
43
        protected mixed $filter = null,
44
        protected ?string $property = null,
45
        protected ?string $description = null,
46
        protected ?array $properties = null,
47
        protected ?bool $required = null,
48
        protected ?int $priority = null,
49
        protected ?false $hydra = null,
50
        protected mixed $constraints = null,
51
        protected string|\Stringable|null $security = null,
52
        protected ?string $securityMessage = null,
53
        protected ?array $extraProperties = [],
54
        protected array|string|null $filterContext = null,
55
        protected ?Type $nativeType = null,
56
        protected ?bool $castToArray = null,
57
        protected ?bool $castToNativeType = null,
58
        protected mixed $castFn = null,
59
    ) {
UNCOV
60
    }
×
61

62
    public function getKey(): ?string
63
    {
UNCOV
64
        return $this->key;
×
65
    }
66

67
    /**
68
     * @return array<string, mixed>|null
69
     *
70
     * @phpstan-return array<string, mixed>|null
71
     *
72
     * @psalm-return array{type?: string, default?: string, ...<string, mixed>}|null
73
     */
74
    public function getSchema(): ?array
75
    {
UNCOV
76
        return $this->schema;
×
77
    }
78

79
    /**
80
     * @return OpenApiParameter[]|OpenApiParameter|bool|null
81
     */
82
    public function getOpenApi(): OpenApiParameter|array|bool|null
83
    {
UNCOV
84
        return $this->openApi;
×
85
    }
86

87
    public function getProvider(): mixed
88
    {
UNCOV
89
        return $this->provider;
×
90
    }
91

92
    public function getProperty(): ?string
93
    {
UNCOV
94
        return $this->property;
×
95
    }
96

97
    public function getFilter(): mixed
98
    {
UNCOV
99
        return $this->filter;
×
100
    }
101

102
    public function getDescription(): ?string
103
    {
UNCOV
104
        return $this->description;
×
105
    }
106

107
    public function getRequired(): ?bool
108
    {
UNCOV
109
        return $this->required;
×
110
    }
111

112
    public function getPriority(): ?int
113
    {
UNCOV
114
        return $this->priority;
×
115
    }
116

117
    public function getHydra(): ?bool
118
    {
UNCOV
119
        return $this->hydra;
×
120
    }
121

122
    public function getConstraints(): mixed
123
    {
UNCOV
124
        return $this->constraints;
×
125
    }
126

127
    public function getSecurity(): string|\Stringable|null
128
    {
UNCOV
129
        return $this->security;
×
130
    }
131

132
    public function getSecurityMessage(): ?string
133
    {
UNCOV
134
        return $this->securityMessage;
×
135
    }
136

137
    /**
138
     * The computed value of this parameter, located into extraProperties['_api_values'].
139
     */
140
    public function getValue(mixed $default = new ParameterNotFound()): mixed
141
    {
UNCOV
142
        return $this->extraProperties['_api_values'] ?? $default;
×
143
    }
144

145
    /**
146
     * Only use this in a parameter provider, the ApiPlatform\State\Provider\ParameterProvider
147
     * resets this value to extract the correct value on each request.
148
     * It's also possible to set the `_api_query_parameters` request attribute directly and
149
     * API Platform will extract the value from there.
150
     */
151
    public function setValue(mixed $value): static
152
    {
UNCOV
153
        $this->extraProperties['_api_values'] = $value;
×
154

UNCOV
155
        return $this;
×
156
    }
157

158
    /**
159
     * @return array<string, mixed>
160
     */
161
    public function getExtraProperties(): array
162
    {
UNCOV
163
        return $this->extraProperties;
×
164
    }
165

166
    public function getFilterContext(): array|string|null
167
    {
UNCOV
168
        return $this->filterContext;
×
169
    }
170

171
    public function withKey(string $key): static
172
    {
UNCOV
173
        $self = clone $this;
×
UNCOV
174
        $self->key = $key;
×
175

UNCOV
176
        return $self;
×
177
    }
178

179
    public function withPriority(int $priority): static
180
    {
UNCOV
181
        $self = clone $this;
×
UNCOV
182
        $self->priority = $priority;
×
183

UNCOV
184
        return $self;
×
185
    }
186

187
    /**
188
     * @param array{type?: string} $schema
189
     */
190
    public function withSchema(array $schema): static
191
    {
UNCOV
192
        $self = clone $this;
×
UNCOV
193
        $self->schema = $schema;
×
194

UNCOV
195
        return $self;
×
196
    }
197

198
    /**
199
     * @param OpenApiParameter[]|OpenApiParameter|bool $openApi
200
     */
201
    public function withOpenApi(OpenApiParameter|array|bool $openApi): static
202
    {
UNCOV
203
        $self = clone $this;
×
UNCOV
204
        $self->openApi = $openApi;
×
205

UNCOV
206
        return $self;
×
207
    }
208

209
    /**
210
     * @param ParameterProviderInterface|string $provider
211
     */
212
    public function withProvider(mixed $provider): static
213
    {
UNCOV
214
        $self = clone $this;
×
UNCOV
215
        $self->provider = $provider;
×
216

217
        return $self;
×
218
    }
219

220
    /**
221
     * @param FilterInterface|string $filter
222
     */
223
    public function withFilter(mixed $filter): static
224
    {
225
        $self = clone $this;
×
226
        $self->filter = $filter;
×
227

228
        return $self;
×
229
    }
230

231
    public function withFilterContext(array|string $filterContext): static
232
    {
UNCOV
233
        $self = clone $this;
×
UNCOV
234
        $self->filterContext = $filterContext;
×
235

UNCOV
236
        return $self;
×
237
    }
238

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

244
        return $self;
×
245
    }
246

247
    public function withDescription(string $description): static
248
    {
249
        $self = clone $this;
×
250
        $self->description = $description;
×
251

252
        return $self;
×
253
    }
254

255
    public function withRequired(bool $required): static
256
    {
257
        $self = clone $this;
×
258
        $self->required = $required;
×
259

260
        return $self;
×
261
    }
262

263
    public function withHydra(false $hydra): static
264
    {
UNCOV
265
        $self = clone $this;
×
UNCOV
266
        $self->hydra = $hydra;
×
267

UNCOV
268
        return $self;
×
269
    }
270

271
    public function withConstraints(mixed $constraints): static
272
    {
273
        $self = clone $this;
×
274
        $self->constraints = $constraints;
×
275

276
        return $self;
×
277
    }
278

279
    public function withSecurity(string|\Stringable|null $security): static
280
    {
281
        $self = clone $this;
×
282
        $self->security = $security;
×
283

284
        return $self;
×
285
    }
286

287
    public function withSecurityMessage(?string $securityMessage): static
288
    {
UNCOV
289
        $self = clone $this;
×
UNCOV
290
        $self->securityMessage = $securityMessage;
×
291

UNCOV
292
        return $self;
×
293
    }
294

295
    /**
296
     * @param array<string, mixed> $extraProperties
297
     */
298
    public function withExtraProperties(array $extraProperties): static
299
    {
UNCOV
300
        $self = clone $this;
×
UNCOV
301
        $self->extraProperties = $extraProperties;
×
302

UNCOV
303
        return $self;
×
304
    }
305

306
    public function getProperties(): ?array
307
    {
308
        return $this->properties;
×
309
    }
310

311
    public function withProperties(?array $properties): self
312
    {
UNCOV
313
        $self = clone $this;
×
UNCOV
314
        $self->properties = $properties;
×
315

UNCOV
316
        return $self;
×
317
    }
318

319
    public function getNativeType(): ?Type
320
    {
UNCOV
321
        return $this->nativeType;
×
322
    }
323

324
    public function withNativeType(Type $nativeType): self
325
    {
UNCOV
326
        $self = clone $this;
×
UNCOV
327
        $self->nativeType = $nativeType;
×
328

UNCOV
329
        return $self;
×
330
    }
331

332
    public function getCastToArray(): ?bool
333
    {
334
        return $this->castToArray;
×
335
    }
336

337
    public function withCastToArray(bool $castToArray): self
338
    {
UNCOV
339
        $self = clone $this;
×
UNCOV
340
        $self->castToArray = $castToArray;
×
341

UNCOV
342
        return $self;
×
343
    }
344

345
    public function getCastToNativeType(): ?bool
346
    {
347
        return $this->castToNativeType;
×
348
    }
349

350
    public function withCastToNativeType(bool $castToNativeType): self
351
    {
UNCOV
352
        $self = clone $this;
×
UNCOV
353
        $self->castToNativeType = $castToNativeType;
×
354

UNCOV
355
        return $self;
×
356
    }
357

358
    public function getCastFn(): ?callable
359
    {
UNCOV
360
        return $this->castFn;
×
361
    }
362

363
    /**
364
     * @param callable(mixed): mixed $castFn
365
     */
366
    public function withCastFn(mixed $castFn): self
367
    {
UNCOV
368
        $self = clone $this;
×
UNCOV
369
        $self->castFn = $castFn;
×
370

UNCOV
371
        return $self;
×
372
    }
373
}
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