Skip to content

Commit 1f2aab6

Browse files
committed
Enable phpdoc_add_missing_param_annotation rule
1 parent 98ecf1f commit 1f2aab6

File tree

10 files changed

+50
-18
lines changed

10 files changed

+50
-18
lines changed

.php_cs.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ return PhpCsFixer\Config::create()
8888
'php_unit_test_annotation' => [
8989
'style' => 'prefix',
9090
],
91+
'phpdoc_add_missing_param_annotation' => [
92+
'only_untyped' => true,
93+
],
9194
'phpdoc_order' => true,
9295
'phpdoc_trim_consecutive_blank_line_separation' => true,
9396
'phpdoc_var_annotation_correct_order' => true,

src/Bridge/Doctrine/Common/Filter/SearchFilterTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ protected function normalizeValues(array $values, string $property): ?array
150150

151151
/**
152152
* When the field should be an integer, check that the given value is a valid one.
153+
*
154+
* @param mixed|null $type
153155
*/
154156
protected function hasValidValues(array $values, $type = null): bool
155157
{

src/DataProvider/Pagination.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ private function getEnabled(array $context, string $resourceClass = null, string
180180

181181
/**
182182
* Gets the given pagination parameter name from the given context.
183+
*
184+
* @param mixed|null $default
183185
*/
184186
private function getParameterFromContext(array $context, string $parameterName, $default = null)
185187
{

src/GraphQl/ExecutorInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ interface ExecutorInterface
2727
{
2828
/**
2929
* @see http://webonyx.github.io/graphql-php/executing-queries/#using-facade-method
30+
*
31+
* @param mixed|null $rootValue
32+
* @param mixed|null $context
3033
*/
3134
public function executeQuery(Schema $schema, $source, $rootValue = null, $context = null, array $variableValues = null, string $operationName = null, callable $fieldResolver = null, array $validationRules = null): ExecutionResult;
3235
}

src/GraphQl/Resolver/ResourceAccessCheckerTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
trait ResourceAccessCheckerTrait
2929
{
3030
/**
31+
* @param mixed|null $object
32+
*
3133
* @throws Error
3234
*/
3335
public function canAccess(?ResourceAccessCheckerInterface $resourceAccessChecker, ResourceMetadata $resourceMetadata, string $resourceClass, ResolveInfo $info, $object = null, string $operationName = null): void

src/Hydra/Serializer/CollectionNormalizer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public function supportsNormalization($data, $format = null)
6262

6363
/**
6464
* {@inheritdoc}
65+
*
66+
* @param iterable $object
6567
*/
6668
public function normalize($object, $format = null, array $context = [])
6769
{
@@ -117,7 +119,7 @@ public function hasCacheableSupportsMethod(): bool
117119
/**
118120
* Normalizes a raw collection (not API resources).
119121
*/
120-
private function normalizeRawCollection($object, $format = null, array $context = []): array
122+
private function normalizeRawCollection(iterable $object, ?string $format, array $context): array
121123
{
122124
$data = [];
123125
foreach ($object as $index => $obj) {

src/Metadata/Property/PropertyMetadata.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public function getAttributes(): ?array
238238

239239
/**
240240
* Gets an attribute.
241+
*
242+
* @param mixed|null $defaultValue
241243
*/
242244
public function getAttribute(string $key, $defaultValue = null)
243245
{

src/Metadata/Resource/ResourceMetadata.php

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public function withSubresourceOperations(array $subresourceOperations): self
159159

160160
/**
161161
* Gets a collection operation attribute, optionally fallback to a resource attribute.
162+
*
163+
* @param mixed|null $defaultValue
162164
*/
163165
public function getCollectionOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
164166
{
@@ -167,6 +169,8 @@ public function getCollectionOperationAttribute(?string $operationName, string $
167169

168170
/**
169171
* Gets an item operation attribute, optionally fallback to a resource attribute.
172+
*
173+
* @param mixed|null $defaultValue
170174
*/
171175
public function getItemOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
172176
{
@@ -175,28 +179,14 @@ public function getItemOperationAttribute(?string $operationName, string $key, $
175179

176180
/**
177181
* Gets a subresource operation attribute, optionally fallback to a resource attribute.
182+
*
183+
* @param mixed|null $defaultValue
178184
*/
179185
public function getSubresourceOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
180186
{
181187
return $this->findOperationAttribute($this->subresourceOperations, $operationName, $key, $defaultValue, $resourceFallback);
182188
}
183189

184-
/**
185-
* Gets an operation attribute, optionally fallback to a resource attribute.
186-
*/
187-
private function findOperationAttribute(?array $operations, ?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
188-
{
189-
if (null !== $operationName && isset($operations[$operationName][$key])) {
190-
return $operations[$operationName][$key];
191-
}
192-
193-
if ($resourceFallback && isset($this->attributes[$key])) {
194-
return $this->attributes[$key];
195-
}
196-
197-
return $defaultValue;
198-
}
199-
200190
public function getGraphqlAttribute(string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
201191
{
202192
if (isset($this->graphql[$operationName][$key])) {
@@ -212,6 +202,8 @@ public function getGraphqlAttribute(string $operationName, string $key, $default
212202

213203
/**
214204
* Gets the first available operation attribute according to the following order: collection, item, subresource, optionally fallback to a default value.
205+
*
206+
* @param mixed|null $defaultValue
215207
*/
216208
public function getOperationAttribute(array $attributes, string $key, $defaultValue = null, bool $resourceFallback = false)
217209
{
@@ -236,6 +228,8 @@ public function getOperationAttribute(array $attributes, string $key, $defaultVa
236228

237229
/**
238230
* Gets an attribute for a given operation type and operation name.
231+
*
232+
* @param mixed|null $defaultValue
239233
*/
240234
public function getTypedOperationAttribute(string $operationType, string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
241235
{
@@ -259,6 +253,8 @@ public function getAttributes(): ?array
259253

260254
/**
261255
* Gets an attribute.
256+
*
257+
* @param mixed|null $defaultValue
262258
*/
263259
public function getAttribute(string $key, $defaultValue = null)
264260
{
@@ -294,4 +290,22 @@ public function withGraphql(array $graphql): self
294290

295291
return $metadata;
296292
}
293+
294+
/**
295+
* Gets an operation attribute, optionally fallback to a resource attribute.
296+
*
297+
* @param mixed|null $defaultValue
298+
*/
299+
private function findOperationAttribute(?array $operations, ?string $operationName, string $key, $defaultValue, bool $resourceFallback)
300+
{
301+
if (null !== $operationName && isset($operations[$operationName][$key])) {
302+
return $operations[$operationName][$key];
303+
}
304+
305+
if ($resourceFallback && isset($this->attributes[$key])) {
306+
return $this->attributes[$key];
307+
}
308+
309+
return $defaultValue;
310+
}
297311
}

src/Serializer/AbstractCollectionNormalizer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public function normalize($object, $format = null, array $context = [])
9696

9797
/**
9898
* Normalizes a raw collection (not API resources).
99+
*
100+
* @param string|null $format
99101
*/
100102
protected function normalizeRawCollection($object, $format = null, array $context = []): array
101103
{

tests/Metadata/Property/Factory/AnnotationSubresourceMetadataFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AnnotationSubresourceMetadataFactoryTest extends TestCase
3232
/**
3333
* @dataProvider dependenciesProvider
3434
*/
35-
public function testCreateProperty($reader, $decorated = null)
35+
public function testCreateProperty($reader, $decorated)
3636
{
3737
$factory = new AnnotationSubresourceMetadataFactory($reader->reveal(), $decorated->reveal());
3838
$metadata = $factory->create(Dummy::class, 'relatedDummies');

0 commit comments

Comments
 (0)