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

api-platform / core / 16705318661

03 Aug 2025 01:05PM UTC coverage: 0.0% (-21.9%) from 21.944%
16705318661

Pull #7317

github

web-flow
Merge 1ca8642ff into d06b1a0a0
Pull Request #7317: Fix/4372 skip null values in hal

0 of 14 new or added lines in 3 files covered. (0.0%)

11680 existing lines in 376 files now uncovered.

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

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

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

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

82
    public function getProvider(): mixed
83
    {
UNCOV
84
        return $this->provider;
×
85
    }
86

87
    public function getProperty(): ?string
88
    {
UNCOV
89
        return $this->property;
×
90
    }
91

92
    public function getFilter(): mixed
93
    {
UNCOV
94
        return $this->filter;
×
95
    }
96

97
    public function getDescription(): ?string
98
    {
UNCOV
99
        return $this->description;
×
100
    }
101

102
    public function getRequired(): ?bool
103
    {
UNCOV
104
        return $this->required;
×
105
    }
106

107
    public function getPriority(): ?int
108
    {
UNCOV
109
        return $this->priority;
×
110
    }
111

112
    public function getHydra(): ?bool
113
    {
UNCOV
114
        return $this->hydra;
×
115
    }
116

117
    public function getConstraints(): mixed
118
    {
UNCOV
119
        return $this->constraints;
×
120
    }
121

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

127
    public function getSecurityMessage(): ?string
128
    {
UNCOV
129
        return $this->securityMessage;
×
130
    }
131

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

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

UNCOV
150
        return $this;
×
151
    }
152

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

161
    public function getFilterContext(): array|string|null
162
    {
UNCOV
163
        return $this->filterContext;
×
164
    }
165

166
    public function withKey(string $key): static
167
    {
UNCOV
168
        $self = clone $this;
×
UNCOV
169
        $self->key = $key;
×
170

UNCOV
171
        return $self;
×
172
    }
173

174
    public function withPriority(int $priority): static
175
    {
UNCOV
176
        $self = clone $this;
×
UNCOV
177
        $self->priority = $priority;
×
178

UNCOV
179
        return $self;
×
180
    }
181

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

UNCOV
190
        return $self;
×
191
    }
192

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

UNCOV
201
        return $self;
×
202
    }
203

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

UNCOV
212
        return $self;
×
213
    }
214

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

223
        return $self;
×
224
    }
225

226
    public function withFilterContext(array|string $filterContext): static
227
    {
228
        $self = clone $this;
×
229
        $self->filterContext = $filterContext;
×
230

231
        return $self;
×
232
    }
233

234
    public function withProperty(string $property): static
235
    {
UNCOV
236
        $self = clone $this;
×
UNCOV
237
        $self->property = $property;
×
238

UNCOV
239
        return $self;
×
240
    }
241

242
    public function withDescription(string $description): static
243
    {
244
        $self = clone $this;
×
245
        $self->description = $description;
×
246

247
        return $self;
×
248
    }
249

250
    public function withRequired(bool $required): static
251
    {
252
        $self = clone $this;
×
253
        $self->required = $required;
×
254

255
        return $self;
×
256
    }
257

258
    public function withHydra(false $hydra): static
259
    {
260
        $self = clone $this;
×
261
        $self->hydra = $hydra;
×
262

263
        return $self;
×
264
    }
265

266
    public function withConstraints(mixed $constraints): static
267
    {
UNCOV
268
        $self = clone $this;
×
UNCOV
269
        $self->constraints = $constraints;
×
270

UNCOV
271
        return $self;
×
272
    }
273

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

279
        return $self;
×
280
    }
281

282
    public function withSecurityMessage(?string $securityMessage): static
283
    {
284
        $self = clone $this;
×
285
        $self->securityMessage = $securityMessage;
×
286

287
        return $self;
×
288
    }
289

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

UNCOV
298
        return $self;
×
299
    }
300

301
    public function getProperties(): ?array
302
    {
UNCOV
303
        return $this->properties;
×
304
    }
305

306
    public function withProperties(?array $properties): self
307
    {
308
        $self = clone $this;
×
309
        $self->properties = $properties;
×
310

311
        return $self;
×
312
    }
313

314
    public function getNativeType(): ?Type
315
    {
UNCOV
316
        return $this->nativeType;
×
317
    }
318

319
    public function withNativeType(Type $nativeType): self
320
    {
UNCOV
321
        $self = clone $this;
×
UNCOV
322
        $self->nativeType = $nativeType;
×
323

UNCOV
324
        return $self;
×
325
    }
326

327
    public function getCastToArray(): ?bool
328
    {
UNCOV
329
        return $this->castToArray;
×
330
    }
331

332
    public function withCastToArray(bool $castToArray): self
333
    {
334
        $self = clone $this;
×
335
        $self->castToArray = $castToArray;
×
336

337
        return $self;
×
338
    }
339

340
    public function getCastToNativeType(): ?bool
341
    {
UNCOV
342
        return $this->castToNativeType;
×
343
    }
344

345
    public function withCastToNativeType(bool $castToNativeType): self
346
    {
347
        $self = clone $this;
×
348
        $self->castToNativeType = $castToNativeType;
×
349

350
        return $self;
×
351
    }
352

353
    public function getCastFn(): ?callable
354
    {
UNCOV
355
        return $this->castFn;
×
356
    }
357

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

UNCOV
366
        return $self;
×
367
    }
368
}
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