From 1d93c33af20f90a6025d9dffc79538b09dd6b544 Mon Sep 17 00:00:00 2001 From: DerManoMann Date: Fri, 15 Mar 2024 15:22:29 +1300 Subject: [PATCH] Enable `no_superfluous_phpdoc_tags` CS rule --- .php-cs-fixer.dist.php | 2 +- src/Analysers/DocBlockParser.php | 3 +-- src/Annotations/AbstractAnnotation.php | 9 --------- src/Annotations/Link.php | 2 -- src/Annotations/MediaType.php | 2 -- src/Annotations/Parameter.php | 2 -- src/Annotations/Schema.php | 6 ------ src/Attributes/OperationTrait.php | 1 - src/Attributes/Schema.php | 1 - src/Context.php | 2 -- src/Generator.php | 3 --- src/Processors/AugmentParameters.php | 2 -- src/Processors/OperationId.php | 2 -- src/Serializer.php | 4 ---- tests/Annotations/AttributesSyncTest.php | 2 +- tests/Fixtures/Annotations/CustomAttachable.php | 2 -- tests/Fixtures/Attributes/CustomAttachable.php | 2 -- tests/Fixtures/Scratch/ComplexCustomAttributes.php | 4 ---- tests/Fixtures/Scratch/MergeTraits.php | 2 -- tests/Fixtures/Scratch/PromotedProperty.php | 2 -- tests/Fixtures/TypedProperties.php | 2 -- tests/OpenApiTestCase.php | 5 ----- 22 files changed, 3 insertions(+), 59 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 438004aa9..87e51f3cd 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -66,7 +66,7 @@ 'nullable_type_declaration_for_default_null_value' => true, 'no_empty_phpdoc' => true, - // 7.3 only 'no_superfluous_phpdoc_tags' => true, + 'no_superfluous_phpdoc_tags' => true, 'phpdoc_align' => true, 'general_phpdoc_tag_rename' => true, 'phpdoc_inline_tag_normalizer' => true, diff --git a/src/Analysers/DocBlockParser.php b/src/Analysers/DocBlockParser.php index 024e592f8..7bcd88ce5 100644 --- a/src/Analysers/DocBlockParser.php +++ b/src/Analysers/DocBlockParser.php @@ -50,8 +50,7 @@ public function setAliases(array $aliases): void /** * Use doctrine to parse the comment block and return the detected annotations. * - * @param string $comment a T_DOC_COMMENT - * @param Context $context + * @param string $comment a T_DOC_COMMENT * * @return array */ diff --git a/src/Annotations/AbstractAnnotation.php b/src/Annotations/AbstractAnnotation.php index 2d3e883ba..b6989ce74 100644 --- a/src/Annotations/AbstractAnnotation.php +++ b/src/Annotations/AbstractAnnotation.php @@ -156,9 +156,6 @@ public function __get(string $property) $this->_context->logger->warning('Property "' . $property . '" doesn\'t exist in a ' . $this->identity() . ', existing properties: "' . implode('", "', array_keys($properties)) . '" in ' . $this->_context); } - /** - * @param mixed $value - */ public function __set(string $property, $value): void { $fields = get_object_vars($this); @@ -287,9 +284,6 @@ public function __debugInfo() return $properties; } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function jsonSerialize() { @@ -741,8 +735,6 @@ private function validateDefaultTypes(string $type, $value): bool /** * Validate array type. - * - * @param mixed $value */ private function validateArrayType($value): bool { @@ -764,7 +756,6 @@ private function validateArrayType($value): bool /** * Wrap the context with a reference to the annotation it is nested in. * - * @param AbstractAnnotation $annotation * * @return AbstractAnnotation */ diff --git a/src/Annotations/Link.php b/src/Annotations/Link.php index a4bec3bfa..30be649f5 100644 --- a/src/Annotations/Link.php +++ b/src/Annotations/Link.php @@ -75,8 +75,6 @@ class Link extends AbstractAnnotation /** * A literal value or {expression} to use as a request body when calling the target operation. - * - * @var mixed */ public $requestBody = Generator::UNDEFINED; diff --git a/src/Annotations/MediaType.php b/src/Annotations/MediaType.php index 624fe69a9..76348a4a0 100644 --- a/src/Annotations/MediaType.php +++ b/src/Annotations/MediaType.php @@ -39,8 +39,6 @@ class MediaType extends AbstractAnnotation * * Furthermore, if referencing a schema which contains an example, * the example value shall override the example provided by the schema. - * - * @var mixed */ public $example = Generator::UNDEFINED; diff --git a/src/Annotations/Parameter.php b/src/Annotations/Parameter.php index ccb3ab8e2..6e8334dbe 100644 --- a/src/Annotations/Parameter.php +++ b/src/Annotations/Parameter.php @@ -143,8 +143,6 @@ class Parameter extends AbstractAnnotation * The example object is mutually exclusive of the examples object. * Furthermore, if referencing a schema which contains an example, the example value shall override the example provided by the schema. * To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary. - * - * @var mixed */ public $example = Generator::UNDEFINED; diff --git a/src/Annotations/Schema.php b/src/Annotations/Schema.php index a668a22af..610263e82 100644 --- a/src/Annotations/Schema.php +++ b/src/Annotations/Schema.php @@ -133,8 +133,6 @@ class Schema extends AbstractAnnotation * Sets a default value to the parameter. The type of the value depends on the defined type. * * @see [JSON schema validation](http://json-schema.org/latest/json-schema-validation.html#anchor101) - * - * @var mixed */ public $default = Generator::UNDEFINED; @@ -318,8 +316,6 @@ class Schema extends AbstractAnnotation * * To represent examples that cannot naturally be represented in JSON or YAML, a string value can be used to * contain the example with escaping where necessary. - * - * @var mixed */ public $example = Generator::UNDEFINED; @@ -407,8 +403,6 @@ class Schema extends AbstractAnnotation /** * http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.3. - * - * @var mixed */ public $const = Generator::UNDEFINED; diff --git a/src/Attributes/OperationTrait.php b/src/Attributes/OperationTrait.php index 40d26fe82..ae337014c 100644 --- a/src/Attributes/OperationTrait.php +++ b/src/Attributes/OperationTrait.php @@ -11,7 +11,6 @@ trait OperationTrait { /** - * @param array $security * @param Server[] $servers * @param string[] $tags * @param Parameter[] $parameters diff --git a/src/Attributes/Schema.php b/src/Attributes/Schema.php index 4de75533a..ee55639b0 100644 --- a/src/Attributes/Schema.php +++ b/src/Attributes/Schema.php @@ -22,7 +22,6 @@ class Schema extends \OpenApi\Annotations\Schema * @param array $allOf * @param array $anyOf * @param array $oneOf - * @param mixed $const * @param array|null $x * @param Attachable[]|null $attachables */ diff --git a/src/Context.php b/src/Context.php index bb0a4f289..ed37942b0 100644 --- a/src/Context.php +++ b/src/Context.php @@ -46,8 +46,6 @@ class Context { /** * Prototypical inheritance for properties. - * - * @var Context|null */ private ?Context $parent; diff --git a/src/Generator.php b/src/Generator.php index 3e0ac31e0..cf3dc9494 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -73,9 +73,6 @@ public function __construct(?LoggerInterface $logger = null) $this->setNamespaces(self::DEFAULT_NAMESPACES); } - /** - * @param mixed $value - */ public static function isDefault($value): bool { return $value === Generator::UNDEFINED; diff --git a/src/Processors/AugmentParameters.php b/src/Processors/AugmentParameters.php index fc4f510c9..cb5818e16 100644 --- a/src/Processors/AugmentParameters.php +++ b/src/Processors/AugmentParameters.php @@ -29,8 +29,6 @@ public function isAugmentOperationParameters(): bool /** * If set to true try to find operation parameter descriptions in the operation docblock. - * - * @param bool $augmentOperationParameters */ public function setAugmentOperationParameters(bool $augmentOperationParameters): void { diff --git a/src/Processors/OperationId.php b/src/Processors/OperationId.php index 22522ab2b..0e799b079 100644 --- a/src/Processors/OperationId.php +++ b/src/Processors/OperationId.php @@ -29,8 +29,6 @@ public function isHash(): bool /** * If set to true generate ids (md5) instead of clear text operation ids. - * - * @param bool $hash */ public function setHash(bool $hash): OperationId { diff --git a/src/Serializer.php b/src/Serializer.php index 52af18056..739461585 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -128,10 +128,6 @@ protected function doDeserialize(\stdClass $c, string $class, Context $context): /** * Deserialize the annotation's property. - * - * @param mixed $value - * - * @return mixed */ protected function doDeserializeProperty(OA\AbstractAnnotation $annotation, string $property, $value, Context $context) { diff --git a/tests/Annotations/AttributesSyncTest.php b/tests/Annotations/AttributesSyncTest.php index c19869b5b..16675d69e 100644 --- a/tests/Annotations/AttributesSyncTest.php +++ b/tests/Annotations/AttributesSyncTest.php @@ -116,7 +116,7 @@ protected function prepDocComment(string $docComment): array protected function propertyType(\ReflectionProperty $property): ?string { - $var = null; + $var = 'mixed'; foreach ($this->prepDocComment($property->getDocComment()) as $line) { if (substr($line, 0, 5) === '@var ') { $var = trim(substr($line, 5)); diff --git a/tests/Fixtures/Annotations/CustomAttachable.php b/tests/Fixtures/Annotations/CustomAttachable.php index 0681fd610..da3f5ce63 100644 --- a/tests/Fixtures/Annotations/CustomAttachable.php +++ b/tests/Fixtures/Annotations/CustomAttachable.php @@ -16,8 +16,6 @@ class CustomAttachable extends OA\Attachable { /** * The attribute value. - * - * @var mixed */ public $value = Generator::UNDEFINED; diff --git a/tests/Fixtures/Attributes/CustomAttachable.php b/tests/Fixtures/Attributes/CustomAttachable.php index 55f559f72..0ab59d77d 100644 --- a/tests/Fixtures/Attributes/CustomAttachable.php +++ b/tests/Fixtures/Attributes/CustomAttachable.php @@ -14,8 +14,6 @@ class CustomAttachable extends OAT\Attachable { /** * The attribute value. - * - * @var mixed */ public $value = Generator::UNDEFINED; diff --git a/tests/Fixtures/Scratch/ComplexCustomAttributes.php b/tests/Fixtures/Scratch/ComplexCustomAttributes.php index 76064de59..cf1794487 100644 --- a/tests/Fixtures/Scratch/ComplexCustomAttributes.php +++ b/tests/Fixtures/Scratch/ComplexCustomAttributes.php @@ -23,10 +23,6 @@ class Schema extends OAT\Schema { /** * @param class-string $of - * @param string|null $description - * @param array $optional - * @param int|null $minLength - * @param int|null $maxLength * * @throws \ReflectionException */ diff --git a/tests/Fixtures/Scratch/MergeTraits.php b/tests/Fixtures/Scratch/MergeTraits.php index 5a99f49c6..0e7f594ab 100644 --- a/tests/Fixtures/Scratch/MergeTraits.php +++ b/tests/Fixtures/Scratch/MergeTraits.php @@ -15,8 +15,6 @@ trait HasId * format="int64", * readOnly=true, * ) - * - * @var int */ public int $id; } diff --git a/tests/Fixtures/Scratch/PromotedProperty.php b/tests/Fixtures/Scratch/PromotedProperty.php index 4453f8732..f0733ccea 100644 --- a/tests/Fixtures/Scratch/PromotedProperty.php +++ b/tests/Fixtures/Scratch/PromotedProperty.php @@ -14,8 +14,6 @@ class PromotedPropertyDescription { /** * Property name. - * - * @var string */ #[OAT\Property(property: 'thename')] public string $name = ''; diff --git a/tests/Fixtures/TypedProperties.php b/tests/Fixtures/TypedProperties.php index 4b06f25b6..501b2643e 100644 --- a/tests/Fixtures/TypedProperties.php +++ b/tests/Fixtures/TypedProperties.php @@ -72,8 +72,6 @@ class TypedProperties public string $annotationTrumpsNative; /** - * @var string - * * @OA\Property( * type="integer", * ) diff --git a/tests/OpenApiTestCase.php b/tests/OpenApiTestCase.php index ab5d16e94..601803e60 100644 --- a/tests/OpenApiTestCase.php +++ b/tests/OpenApiTestCase.php @@ -118,7 +118,6 @@ public function assertOpenApiLogEntryContains(string $needle, string $message = * * @param array|OA\OpenApi|\stdClass|string $actual The generated output * @param array|OA\OpenApi|\stdClass|string $expected The specification - * @param string $message * @param bool $normalized flag indicating whether the inputs are already normalized or * not */ @@ -255,8 +254,6 @@ protected function annotationsFromDocBlockParser(string $docBlock, array $extraA /** * Collect list of all non-abstract annotation classes. - * - * @return array */ public function allAnnotationClasses(): array { @@ -278,8 +275,6 @@ public function allAnnotationClasses(): array /** * Collect list of all non-abstract attribute classes. - * - * @return array */ public function allAttributeClasses(): array {