From 3571ebce7d3de64c7c42933b07a4eb8e25e94f16 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:37:43 +0200 Subject: [PATCH 1/7] Bump doctrine/coding-standard version to 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3ba7d6b..387935d 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require-dev": { "phpunit/phpunit": "^7 | ^9.5.10", - "doctrine/coding-standard": "^5.0 | ^8.0", + "doctrine/coding-standard": "^12.0", "doctrine/persistence": "^1.3.4 | ^2.0 | ^3.0", "pagerfanta/core": "^2.4 || ^3.0", "phpdocumentor/type-resolver": "^1.5.1", From fc6af9af19776dd6b3d1ba3a60253bd5ce1eb9be Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:44:03 +0200 Subject: [PATCH 2/7] Fix @inheritDoc annotations --- src/Configuration/Metadata/Driver/AnnotationDriver.php | 2 +- src/Configuration/Metadata/Driver/AttributeDriver.php | 2 +- src/Configuration/Provider/ChainProvider.php | 2 +- src/Configuration/Provider/ExpressionEvaluatorProvider.php | 2 +- src/Configuration/Provider/FunctionProvider.php | 2 +- src/Configuration/Provider/StaticMethodProvider.php | 2 +- src/Hateoas.php | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Configuration/Metadata/Driver/AnnotationDriver.php b/src/Configuration/Metadata/Driver/AnnotationDriver.php index 8e2c5c5..549eb2a 100644 --- a/src/Configuration/Metadata/Driver/AnnotationDriver.php +++ b/src/Configuration/Metadata/Driver/AnnotationDriver.php @@ -28,7 +28,7 @@ public function __construct( } /** - * {@inheritdoc} + * {@inheritDoc} */ protected function getClassAnnotations(\ReflectionClass $class): array { diff --git a/src/Configuration/Metadata/Driver/AttributeDriver.php b/src/Configuration/Metadata/Driver/AttributeDriver.php index b06ef83..d0194c0 100644 --- a/src/Configuration/Metadata/Driver/AttributeDriver.php +++ b/src/Configuration/Metadata/Driver/AttributeDriver.php @@ -7,7 +7,7 @@ class AttributeDriver extends AnnotationOrAttributeDriver { /** - * {@inheritdoc} + * {@inheritDoc} */ protected function getClassAnnotations(\ReflectionClass $class): array { diff --git a/src/Configuration/Provider/ChainProvider.php b/src/Configuration/Provider/ChainProvider.php index 4fac547..19279ed 100644 --- a/src/Configuration/Provider/ChainProvider.php +++ b/src/Configuration/Provider/ChainProvider.php @@ -24,7 +24,7 @@ public function addProvider(RelationProviderInterface $resolver): void } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRelations(RelationProvider $configuration, string $class): array { diff --git a/src/Configuration/Provider/ExpressionEvaluatorProvider.php b/src/Configuration/Provider/ExpressionEvaluatorProvider.php index 772aca7..82bc288 100644 --- a/src/Configuration/Provider/ExpressionEvaluatorProvider.php +++ b/src/Configuration/Provider/ExpressionEvaluatorProvider.php @@ -20,7 +20,7 @@ public function __construct(ExpressionEvaluatorInterface $expressionEvaluator) } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRelations(RelationProvider $configuration, string $class): array { diff --git a/src/Configuration/Provider/FunctionProvider.php b/src/Configuration/Provider/FunctionProvider.php index 6ff1201..0145032 100644 --- a/src/Configuration/Provider/FunctionProvider.php +++ b/src/Configuration/Provider/FunctionProvider.php @@ -9,7 +9,7 @@ class FunctionProvider implements RelationProviderInterface { /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRelations(RelationProvider $configuration, string $class): array { diff --git a/src/Configuration/Provider/StaticMethodProvider.php b/src/Configuration/Provider/StaticMethodProvider.php index 40198b0..7b9374f 100644 --- a/src/Configuration/Provider/StaticMethodProvider.php +++ b/src/Configuration/Provider/StaticMethodProvider.php @@ -9,7 +9,7 @@ class StaticMethodProvider implements RelationProviderInterface { /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRelations(RelationProvider $configuration, string $class): array { diff --git a/src/Hateoas.php b/src/Hateoas.php index 294a26a..7157e8d 100644 --- a/src/Hateoas.php +++ b/src/Hateoas.php @@ -28,7 +28,7 @@ public function __construct(SerializerInterface $serializer, LinkHelper $linkHel } /** - * {@inheritdoc} + * {@inheritDoc} */ public function serialize($data, string $format, ?SerializationContext $context = null, ?string $type = null): string { @@ -36,7 +36,7 @@ public function serialize($data, string $format, ?SerializationContext $context } /** - * {@inheritdoc} + * {@inheritDoc} */ public function deserialize(string $data, string $type, string $format, ?DeserializationContext $context = null) { From a0bc847c05ba275947be59eea5385a5e694a5de3 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:45:19 +0200 Subject: [PATCH 3/7] Remove superfluous type hints --- src/Configuration/Metadata/Driver/CheckExpressionTrait.php | 1 - src/Configuration/Relation.php | 4 ---- src/Factory/EmbeddedsFactory.php | 4 ---- src/Factory/LinkFactory.php | 7 ------- src/HateoasBuilder.php | 4 ---- src/Model/Link.php | 6 ------ src/Representation/AbstractSegmentedRepresentation.php | 2 -- src/Representation/OffsetRepresentation.php | 2 -- src/Representation/PaginatedRepresentation.php | 2 -- src/Representation/RouteAwareRepresentation.php | 4 ---- 10 files changed, 36 deletions(-) diff --git a/src/Configuration/Metadata/Driver/CheckExpressionTrait.php b/src/Configuration/Metadata/Driver/CheckExpressionTrait.php index 0c83e76..e847631 100644 --- a/src/Configuration/Metadata/Driver/CheckExpressionTrait.php +++ b/src/Configuration/Metadata/Driver/CheckExpressionTrait.php @@ -16,7 +16,6 @@ trait CheckExpressionTrait /** * @param mixed $exp - * @param array $names * * @return Expression|mixed */ diff --git a/src/Configuration/Relation.php b/src/Configuration/Relation.php index b46c649..202e136 100644 --- a/src/Configuration/Relation.php +++ b/src/Configuration/Relation.php @@ -39,7 +39,6 @@ class Relation * @param string|Expression $name * @param string|Route $href * @param Embedded|string|mixed $embedded - * @param array $attributes */ public function __construct(string $name, $href = null, $embedded = null, array $attributes = [], ?Exclusion $exclusion = null) { @@ -71,9 +70,6 @@ public function getHref() return $this->href; } - /** - * @return array - */ public function getAttributes(): array { return $this->attributes; diff --git a/src/Factory/EmbeddedsFactory.php b/src/Factory/EmbeddedsFactory.php index 6f74148..8119fa6 100644 --- a/src/Factory/EmbeddedsFactory.php +++ b/src/Factory/EmbeddedsFactory.php @@ -48,9 +48,6 @@ public function create(object $object, SerializationContext $context): array if (null !== ($classMetadata = $this->metadataFactory->getMetadataForClass(get_class($object)))) { $langugeData = ['object' => $object, 'context' => $context]; - /** - * @var $relation Relation - */ foreach ($classMetadata->getRelations() as $relation) { if ($this->exclusionManager->shouldSkipEmbedded($object, $relation, $context)) { continue; @@ -71,7 +68,6 @@ public function create(object $object, SerializationContext $context): array /** * @param mixed $exp - * @param array $data * * @return mixed */ diff --git a/src/Factory/LinkFactory.php b/src/Factory/LinkFactory.php index 044c875..edd3a87 100644 --- a/src/Factory/LinkFactory.php +++ b/src/Factory/LinkFactory.php @@ -75,7 +75,6 @@ public function createLink(object $object, Relation $relation, SerializationCont /** * @param mixed $exp - * @param array $data * * @return mixed */ @@ -88,12 +87,6 @@ private function checkExpression($exp, array $data) } } - /** - * @param array $array - * @param array $data - * - * @return array - */ private function evaluateArray(array $array, array $data): array { $newArray = []; diff --git a/src/HateoasBuilder.php b/src/HateoasBuilder.php index dc2fd8c..81a5fb9 100644 --- a/src/HateoasBuilder.php +++ b/src/HateoasBuilder.php @@ -303,8 +303,6 @@ public function includeInterfaceMetadata(bool $include): HateoasBuilder * Set a map of namespace prefixes to directories. * * This method overrides any previously defined directories. - * - * @param array $namespacePrefixToDirMap */ public function setMetadataDirs(array $namespacePrefixToDirMap): HateoasBuilder { @@ -357,8 +355,6 @@ public function addMetadataDir(string $dir, string $namespacePrefix = ''): Hateo /** * Add a map of namespace prefixes to directories. - * - * @param array $namespacePrefixToDirMap */ public function addMetadataDirs(array $namespacePrefixToDirMap): HateoasBuilder { diff --git a/src/Model/Link.php b/src/Model/Link.php index 0c0c19e..0b2a3e0 100644 --- a/src/Model/Link.php +++ b/src/Model/Link.php @@ -21,9 +21,6 @@ class Link */ private $attributes; - /** - * @param array $attributes - */ public function __construct(string $rel, string $href, array $attributes = []) { $this->rel = $rel; @@ -31,9 +28,6 @@ public function __construct(string $rel, string $href, array $attributes = []) $this->attributes = $attributes; } - /** - * @return array - */ public function getAttributes(): array { return $this->attributes; diff --git a/src/Representation/AbstractSegmentedRepresentation.php b/src/Representation/AbstractSegmentedRepresentation.php index bb39f7a..f0e67d9 100644 --- a/src/Representation/AbstractSegmentedRepresentation.php +++ b/src/Representation/AbstractSegmentedRepresentation.php @@ -60,8 +60,6 @@ public function getLimit(): int /** * @param null $limit - * - * @return array */ public function getParameters(?int $limit = null): array { diff --git a/src/Representation/OffsetRepresentation.php b/src/Representation/OffsetRepresentation.php index cf5db67..bf2847b 100644 --- a/src/Representation/OffsetRepresentation.php +++ b/src/Representation/OffsetRepresentation.php @@ -94,8 +94,6 @@ public function getOffset(): ?int /** * @param null $offset * @param null $limit - * - * @return array */ public function getParameters(?int $offset = null, ?int $limit = null): array { diff --git a/src/Representation/PaginatedRepresentation.php b/src/Representation/PaginatedRepresentation.php index 9fe8c33..ef864bc 100644 --- a/src/Representation/PaginatedRepresentation.php +++ b/src/Representation/PaginatedRepresentation.php @@ -109,8 +109,6 @@ public function getPage(): int /** * @param null $page * @param null $limit - * - * @return array */ public function getParameters($page = null, $limit = null): array { diff --git a/src/Representation/RouteAwareRepresentation.php b/src/Representation/RouteAwareRepresentation.php index f346395..6532c90 100644 --- a/src/Representation/RouteAwareRepresentation.php +++ b/src/Representation/RouteAwareRepresentation.php @@ -46,7 +46,6 @@ class RouteAwareRepresentation /** * @param mixed $inline - * @param array $parameters */ public function __construct($inline, string $route, array $parameters = [], bool $absolute = false) { @@ -69,9 +68,6 @@ public function getRoute(): string return $this->route; } - /** - * @return array - */ public function getParameters(): array { return $this->parameters; From b4b6921846224ae0828828765de4462964473b16 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:45:39 +0200 Subject: [PATCH 4/7] Remove superfluous @phpcsSuppress annotation --- src/Expression/LinkExpressionFunction.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Expression/LinkExpressionFunction.php b/src/Expression/LinkExpressionFunction.php index 7cdfa04..670671b 100644 --- a/src/Expression/LinkExpressionFunction.php +++ b/src/Expression/LinkExpressionFunction.php @@ -11,8 +11,6 @@ class LinkExpressionFunction implements ExpressionFunctionProviderInterface { /** * @return ExpressionFunction[] - * - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint */ public function getFunctions(): array { From 0434784c7b1bce55d20ab64d70e4c60a301678d5 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:46:18 +0200 Subject: [PATCH 5/7] Add empty line after parent call --- src/Configuration/Metadata/Driver/XmlDriver.php | 1 + src/Configuration/Metadata/Driver/YamlDriver.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Configuration/Metadata/Driver/XmlDriver.php b/src/Configuration/Metadata/Driver/XmlDriver.php index a397341..7d17cec 100644 --- a/src/Configuration/Metadata/Driver/XmlDriver.php +++ b/src/Configuration/Metadata/Driver/XmlDriver.php @@ -41,6 +41,7 @@ public function __construct( ParserInterface $typeParser ) { parent::__construct($locator); + $this->relationProvider = $relationProvider; $this->expressionLanguage = $expressionLanguage; $this->typeParser = $typeParser; diff --git a/src/Configuration/Metadata/Driver/YamlDriver.php b/src/Configuration/Metadata/Driver/YamlDriver.php index 2d39acf..da057fc 100644 --- a/src/Configuration/Metadata/Driver/YamlDriver.php +++ b/src/Configuration/Metadata/Driver/YamlDriver.php @@ -40,6 +40,7 @@ public function __construct( ParserInterface $typeParser ) { parent::__construct($locator); + $this->relationProvider = $relationProvider; $this->expressionLanguage = $expressionLanguage; $this->typeParser = $typeParser; From 423d2303a95ade46712b65bc123cee6853ed2bf8 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:50:46 +0200 Subject: [PATCH 6/7] Apply cs sniff SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch.DisallowedStringExpressionPropertyFetch --- src/Configuration/Metadata/Driver/XmlDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configuration/Metadata/Driver/XmlDriver.php b/src/Configuration/Metadata/Driver/XmlDriver.php index 7d17cec..c171fd0 100644 --- a/src/Configuration/Metadata/Driver/XmlDriver.php +++ b/src/Configuration/Metadata/Driver/XmlDriver.php @@ -178,7 +178,7 @@ private function createEmbedded($embedded): Embedded { $embeddedExclusion = isset($embedded->exclusion) ? $this->parseExclusion($embedded->exclusion) : null; $xmlElementName = isset($embedded->attributes('')->{'xml-element-name'}) ? $this->checkExpression((string) $embedded->attributes('')->{'xml-element-name'}) : null; - $type = isset($embedded->attributes('')->{'type'}) ? $this->typeParser->parse((string) $embedded->attributes('')->{'type'}) : null; + $type = isset($embedded->attributes('')->type) ? $this->typeParser->parse((string) $embedded->attributes('')->type) : null; return new Embedded( $this->checkExpression((string) $embedded->content), From 0812530b0a78cc940f69867371e4a7bd01ca609b Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 15 Oct 2024 11:51:01 +0200 Subject: [PATCH 7/7] Exclude some sniffs --- phpcs.xml.dist | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index bf60569..60a288a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -31,12 +31,17 @@ + + + + + @@ -99,10 +104,6 @@ tests/* - - tests/* - -