From 919f0b0230ce9982e53ccc4afd81ec3faf02ab92 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 4 Dec 2025 09:02:26 +0100 Subject: [PATCH] Add phpdoc for array --- phpstan.neon.dist | 16 ++++++++++++++++ .../DefinitionNameFactoryInterface.php | 3 ++- src/JsonSchema/SchemaFactoryInterface.php | 2 ++ .../Exception/HttpExceptionInterface.php | 2 ++ .../Extractor/PropertyExtractorInterface.php | 2 ++ src/Metadata/UriVariableTransformerInterface.php | 12 ++++++------ src/Metadata/UriVariablesConverterInterface.php | 7 ++++--- src/Serializer/Filter/FilterInterface.php | 5 +++++ src/State/SerializerContextBuilderInterface.php | 2 ++ ...ropertySchemaRestrictionMetadataInterface.php | 2 +- src/Validator/ValidatorInterface.php | 2 ++ 11 files changed, 44 insertions(+), 11 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2165b919de2..53161050b25 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -113,6 +113,22 @@ parameters: # Level 6 - identifier: missingType.iterableValue + paths: + - src/Doctrine/Common/Tests + - src/Doctrine/Odm/Tests + - src/Doctrine/Orm/Tests + - src/Elasticsearch/Tests + - src/GraphQl/Tests + - src/Hydra/Tests + - src/JsonApi/Tests + - src/JsonSchema/Tests + - src/Metadata/Tests + - src/OpenApi/Tests + - src/Serializer/Tests + - src/State/Tests + - src/Symfony/Tests + - tests + - src # TODO - identifier: missingType.generics - diff --git a/src/JsonSchema/DefinitionNameFactoryInterface.php b/src/JsonSchema/DefinitionNameFactoryInterface.php index 26de6f1d3f1..012ea841a6a 100644 --- a/src/JsonSchema/DefinitionNameFactoryInterface.php +++ b/src/JsonSchema/DefinitionNameFactoryInterface.php @@ -25,7 +25,8 @@ interface DefinitionNameFactoryInterface /** * Creates a resource definition name. * - * @param class-string $className + * @param class-string $className + * @param array $serializerContext * * @return string the definition name */ diff --git a/src/JsonSchema/SchemaFactoryInterface.php b/src/JsonSchema/SchemaFactoryInterface.php index 64b270764a6..bd598ab4796 100644 --- a/src/JsonSchema/SchemaFactoryInterface.php +++ b/src/JsonSchema/SchemaFactoryInterface.php @@ -26,6 +26,8 @@ interface SchemaFactoryInterface /** * Builds the JSON Schema document corresponding to the given PHP class. + * + * @param array|null $serializerContext */ public function buildSchema(string $className, string $format = 'json', string $type = Schema::TYPE_OUTPUT, ?Operation $operation = null, ?Schema $schema = null, ?array $serializerContext = null, bool $forceCollection = false): Schema; } diff --git a/src/Metadata/Exception/HttpExceptionInterface.php b/src/Metadata/Exception/HttpExceptionInterface.php index 45a9905fb09..7d9a00325c4 100644 --- a/src/Metadata/Exception/HttpExceptionInterface.php +++ b/src/Metadata/Exception/HttpExceptionInterface.php @@ -22,6 +22,8 @@ public function getStatusCode(): int; /** * Returns response headers. + * + * @return array */ public function getHeaders(): array; } diff --git a/src/Metadata/Extractor/PropertyExtractorInterface.php b/src/Metadata/Extractor/PropertyExtractorInterface.php index 8930c78efc4..863a9bca771 100644 --- a/src/Metadata/Extractor/PropertyExtractorInterface.php +++ b/src/Metadata/Extractor/PropertyExtractorInterface.php @@ -26,6 +26,8 @@ interface PropertyExtractorInterface * Parses all metadata files and convert them in an array. * * @throws InvalidArgumentException + * + * @return array>> */ public function getProperties(): array; } diff --git a/src/Metadata/UriVariableTransformerInterface.php b/src/Metadata/UriVariableTransformerInterface.php index b9f9476065b..889a6cdb371 100644 --- a/src/Metadata/UriVariableTransformerInterface.php +++ b/src/Metadata/UriVariableTransformerInterface.php @@ -20,9 +20,9 @@ interface UriVariableTransformerInterface /** * Transforms the value of a URI variable (identifier) to its type. * - * @param mixed $value The URI variable value to transform - * @param array $types The guessed type behind the URI variable - * @param array $context Options available to the transformer + * @param mixed $value The URI variable value to transform + * @param array $types The guessed type behind the URI variable + * @param array $context Options available to the transformer * * @throws InvalidUriVariableException Occurs when the URI variable could not be transformed * @@ -33,9 +33,9 @@ public function transform(mixed $value, array $types, array $context = []); /** * Checks whether the value of a URI variable can be transformed to its type by this transformer. * - * @param mixed $value The URI variable value to transform - * @param array $types The types to which the URI variable value should be transformed - * @param array $context Options available to the transformer + * @param mixed $value The URI variable value to transform + * @param array $types The types to which the URI variable value should be transformed + * @param array $context Options available to the transformer */ public function supportsTransformation(mixed $value, array $types, array $context = []): bool; } diff --git a/src/Metadata/UriVariablesConverterInterface.php b/src/Metadata/UriVariablesConverterInterface.php index 344de031994..575ffe9503a 100644 --- a/src/Metadata/UriVariablesConverterInterface.php +++ b/src/Metadata/UriVariablesConverterInterface.php @@ -26,13 +26,14 @@ interface UriVariablesConverterInterface /** * Takes an array of strings representing URI variables (identifiers) and transform their values to the expected type. * - * @param array $data URI variables to convert to PHP values - * @param string $class The class to which the URI variables belong to + * @param array $data URI variables to convert to PHP values + * @param string $class The class to which the URI variables belong to + * @param array $context * * @throws InvalidIdentifierException * @throws InvalidUriVariableException * - * @return array Array indexed by identifiers properties with their values denormalized + * @return array Array indexed by identifiers properties with their values denormalized */ public function convert(array $data, string $class, array $context = []): array; } diff --git a/src/Serializer/Filter/FilterInterface.php b/src/Serializer/Filter/FilterInterface.php index 22868870e4b..07e21dae390 100644 --- a/src/Serializer/Filter/FilterInterface.php +++ b/src/Serializer/Filter/FilterInterface.php @@ -25,6 +25,11 @@ interface FilterInterface extends BaseFilterInterface { /** * Apply a filter to the serializer context. + * + * @param array $attributes + * @param array $context + * + * @param-out array $context */ public function apply(Request $request, bool $normalization, array $attributes, array &$context): void; } diff --git a/src/State/SerializerContextBuilderInterface.php b/src/State/SerializerContextBuilderInterface.php index 1b2c79164ae..99247373712 100644 --- a/src/State/SerializerContextBuilderInterface.php +++ b/src/State/SerializerContextBuilderInterface.php @@ -30,6 +30,8 @@ interface SerializerContextBuilderInterface /** * Creates a serialization context from a Request. * + * @param array|null $extractedAttributes + * * @throws RuntimeException * * @return array diff --git a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRestrictionMetadataInterface.php b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRestrictionMetadataInterface.php index 1e087ec2928..75f5e6e7829 100644 --- a/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRestrictionMetadataInterface.php +++ b/src/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaRestrictionMetadataInterface.php @@ -31,7 +31,7 @@ interface PropertySchemaRestrictionMetadataInterface * @param Constraint $constraint The validation constraint * @param ApiProperty $propertyMetadata The property metadata * - * @return array The array of restrictions + * @return array The array of restrictions */ public function create(Constraint $constraint, ApiProperty $propertyMetadata): array; diff --git a/src/Validator/ValidatorInterface.php b/src/Validator/ValidatorInterface.php index 323d0f5d67d..874acae599b 100644 --- a/src/Validator/ValidatorInterface.php +++ b/src/Validator/ValidatorInterface.php @@ -25,6 +25,8 @@ interface ValidatorInterface /** * Validates an item. * + * @param array $context + * * @throws ValidationException */ public function validate(object $data, array $context = []): void;