From 9335ca219282c8699275393808c564232164c342 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 20 Mar 2024 23:42:31 +0200 Subject: [PATCH 1/3] Fix types --- composer.json | 7 +++---- src/Normalizer/RamseyUuidNormalizer.php | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 1b103b4..abd4838 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,13 @@ "spiral/config": "^3.7", "doctrine/annotations": "^1.12 || ^2.0", "spiral/serializer": "^3.7", - "symfony/serializer": "^5.4 || ^6.0 || ^7.0", - "symfony/property-access": "^5.4 || ^6.0 || ^7.0" + "symfony/serializer": "^6.4 || ^7.0", + "symfony/property-access": "^6.4 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^10.2", "spiral/testing": "^2.7", - "symfony/yaml": "^5.4 || ^6.0 || ^7.0", - "symfony/yaml": "^5.4 || ^6.0", + "symfony/yaml": "^6.4 || ^7.0", "vimeo/psalm": "^5.12", "ramsey/uuid": "^4.7" }, diff --git a/src/Normalizer/RamseyUuidNormalizer.php b/src/Normalizer/RamseyUuidNormalizer.php index 0739fc8..aa9a8f1 100644 --- a/src/Normalizer/RamseyUuidNormalizer.php +++ b/src/Normalizer/RamseyUuidNormalizer.php @@ -16,12 +16,12 @@ final class RamseyUuidNormalizer implements NormalizerInterface, DenormalizerInt * @param UuidInterface $object * @psalm-suppress MoreSpecificImplementedParamType */ - public function normalize(mixed $object, string $format = null, array $context = []): string + public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null { return $object->toString(); } - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { return $data instanceof UuidInterface; } @@ -37,7 +37,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar } } - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool { return \is_string($data) && \is_a($type, UuidInterface::class, true) && Uuid::isValid($data); } From 84c842201b89d9085c64926e69e9c800098302e5 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 20 Mar 2024 23:45:06 +0200 Subject: [PATCH 2/3] Remove php from GitHub actions --- .github/workflows/phpunit.yml | 3 --- .github/workflows/psalm.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index caff662..2ce528a 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -2,7 +2,6 @@ on: pull_request: null push: branches: - - master - '*.*' name: phpunit @@ -14,7 +13,5 @@ jobs: extensions: sockets, grpc os: >- ['ubuntu-latest'] - php: >- - ['8.1', '8.2'] stability: >- ['prefer-stable'] diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 96e14a6..143566f 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -2,7 +2,6 @@ on: pull_request: null push: branches: - - master - '*.*' name: static analysis @@ -13,5 +12,3 @@ jobs: with: os: >- ['ubuntu-latest'] - php: >- - ['8.1'] From ea39b43c0910844231c9e422906766ef9d2ee853 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Wed, 20 Mar 2024 23:49:05 +0200 Subject: [PATCH 3/3] Fix Psalm issues --- src/Config/SerializerConfig.php | 2 ++ src/Normalizer/RamseyUuidNormalizer.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/Config/SerializerConfig.php b/src/Config/SerializerConfig.php index a82e5bf..3463b18 100644 --- a/src/Config/SerializerConfig.php +++ b/src/Config/SerializerConfig.php @@ -46,7 +46,9 @@ public function getMetadataLoader(): LoaderInterface return new AttributeLoader(); } + /** @psalm-suppress DeprecatedClass */ if (\class_exists(AnnotationLoader::class)) { + /** @psalm-suppress TooManyArguments, InvalidReturnStatement */ return new AnnotationLoader(new AnnotationReader()); } diff --git a/src/Normalizer/RamseyUuidNormalizer.php b/src/Normalizer/RamseyUuidNormalizer.php index aa9a8f1..ef82d6e 100644 --- a/src/Normalizer/RamseyUuidNormalizer.php +++ b/src/Normalizer/RamseyUuidNormalizer.php @@ -42,6 +42,9 @@ public function supportsDenormalization(mixed $data, string $type, ?string $form return \is_string($data) && \is_a($type, UuidInterface::class, true) && Uuid::isValid($data); } + /** + * @return array + */ public function getSupportedTypes(?string $format): array { return [