• 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

61.84
/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
     */
35
    public function __construct(
36
        protected ?string $key = null,
37
        protected ?array $schema = null,
38
        protected OpenApiParameter|array|false|null $openApi = null,
39
        protected mixed $provider = null,
40
        protected mixed $filter = null,
41
        protected ?string $property = null,
42
        protected ?string $description = null,
43
        protected ?array $properties = null,
44
        protected ?bool $required = null,
45
        protected ?int $priority = null,
46
        protected ?false $hydra = null,
47
        protected mixed $constraints = null,
48
        protected string|\Stringable|null $security = null,
49
        protected ?string $securityMessage = null,
50
        protected ?array $extraProperties = [],
51
        protected array|string|null $filterContext = null,
52
        protected ?Type $nativeType = null,
53
        protected ?bool $castToArray = null,
54
    ) {
UNCOV
55
    }
84✔
56

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

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

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

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

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

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

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

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

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

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

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

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

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

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

136
    public function setValue(mixed $value): static
137
    {
138
        $this->extraProperties['_api_values'] = $value;
×
139

140
        return $this;
×
141
    }
142

143
    /**
144
     * @return array<string, mixed>
145
     */
146
    public function getExtraProperties(): array
147
    {
UNCOV
148
        return $this->extraProperties;
512✔
149
    }
150

151
    public function getFilterContext(): array|string|null
152
    {
UNCOV
153
        return $this->filterContext;
77✔
154
    }
155

156
    public function withKey(string $key): static
157
    {
UNCOV
158
        $self = clone $this;
15✔
UNCOV
159
        $self->key = $key;
15✔
160

UNCOV
161
        return $self;
15✔
162
    }
163

164
    public function withPriority(int $priority): static
165
    {
UNCOV
166
        $self = clone $this;
15✔
UNCOV
167
        $self->priority = $priority;
15✔
168

UNCOV
169
        return $self;
15✔
170
    }
171

172
    /**
173
     * @param array{type?: string} $schema
174
     */
175
    public function withSchema(array $schema): static
176
    {
UNCOV
177
        $self = clone $this;
10✔
UNCOV
178
        $self->schema = $schema;
10✔
179

UNCOV
180
        return $self;
10✔
181
    }
182

183
    /**
184
     * @param OpenApiParameter[]|OpenApiParameter|bool $openApi
185
     */
186
    public function withOpenApi(OpenApiParameter|array|bool $openApi): static
187
    {
UNCOV
188
        $self = clone $this;
6✔
UNCOV
189
        $self->openApi = $openApi;
6✔
190

UNCOV
191
        return $self;
6✔
192
    }
193

194
    /**
195
     * @param ParameterProviderInterface|string $provider
196
     */
197
    public function withProvider(mixed $provider): static
198
    {
UNCOV
199
        $self = clone $this;
2✔
UNCOV
200
        $self->provider = $provider;
2✔
201

UNCOV
202
        return $self;
2✔
203
    }
204

205
    /**
206
     * @param FilterInterface|string $filter
207
     */
208
    public function withFilter(mixed $filter): static
209
    {
210
        $self = clone $this;
×
211
        $self->filter = $filter;
×
212

213
        return $self;
×
214
    }
215

216
    public function withFilterContext(array|string $filterContext): static
217
    {
218
        $self = clone $this;
×
219
        $self->filterContext = $filterContext;
×
220

221
        return $self;
×
222
    }
223

224
    public function withProperty(string $property): static
225
    {
UNCOV
226
        $self = clone $this;
11✔
UNCOV
227
        $self->property = $property;
11✔
228

UNCOV
229
        return $self;
11✔
230
    }
231

232
    public function withDescription(string $description): static
233
    {
234
        $self = clone $this;
×
235
        $self->description = $description;
×
236

237
        return $self;
×
238
    }
239

240
    public function withRequired(bool $required): static
241
    {
242
        $self = clone $this;
×
243
        $self->required = $required;
×
244

245
        return $self;
×
246
    }
247

248
    public function withHydra(false $hydra): static
249
    {
250
        $self = clone $this;
×
251
        $self->hydra = $hydra;
×
252

253
        return $self;
×
254
    }
255

256
    public function withConstraints(mixed $constraints): static
257
    {
UNCOV
258
        $self = clone $this;
13✔
UNCOV
259
        $self->constraints = $constraints;
13✔
260

UNCOV
261
        return $self;
13✔
262
    }
263

264
    public function withSecurity(string|\Stringable|null $security): static
265
    {
266
        $self = clone $this;
×
267
        $self->security = $security;
×
268

269
        return $self;
×
270
    }
271

272
    public function withSecurityMessage(?string $securityMessage): static
273
    {
274
        $self = clone $this;
×
275
        $self->securityMessage = $securityMessage;
×
276

277
        return $self;
×
278
    }
279

280
    /**
281
     * @param array<string, mixed> $extraProperties
282
     */
283
    public function withExtraProperties(array $extraProperties): static
284
    {
UNCOV
285
        $self = clone $this;
376✔
UNCOV
286
        $self->extraProperties = $extraProperties;
376✔
287

UNCOV
288
        return $self;
376✔
289
    }
290

291
    public function getProperties(): ?array
292
    {
UNCOV
293
        return $this->properties;
30✔
294
    }
295

296
    public function withProperties(?array $properties): self
297
    {
298
        $self = clone $this;
×
299
        $self->properties = $properties;
×
300

301
        return $self;
×
302
    }
303

304
    public function getNativeType(): ?Type
305
    {
UNCOV
306
        return $this->nativeType;
255✔
307
    }
308

309
    public function withNativeType(Type $nativeType): self
310
    {
UNCOV
311
        $self = clone $this;
13✔
UNCOV
312
        $self->nativeType = $nativeType;
13✔
313

UNCOV
314
        return $self;
13✔
315
    }
316

317
    public function getCastToArray(): ?bool
318
    {
UNCOV
319
        return $this->castToArray;
60✔
320
    }
321

322
    public function withCastToArray(bool $castToArray): self
323
    {
324
        $self = clone $this;
×
325
        $self->castToArray = $castToArray;
×
326

327
        return $self;
×
328
    }
329
}
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