Skip to content

Commit

Permalink
Merge pull request #28 from spiral-packages/fix-normalizer
Browse files Browse the repository at this point in the history
Fixed compatibility with `NormalizerInterface`
  • Loading branch information
msmakouz committed Mar 21, 2024
2 parents a81c894 + ea39b43 commit f484db5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ on:
pull_request: null
push:
branches:
- master
- '*.*'

name: phpunit
Expand All @@ -14,7 +13,5 @@ jobs:
extensions: sockets, grpc
os: >-
['ubuntu-latest']
php: >-
['8.1', '8.2']
stability: >-
['prefer-stable']
3 changes: 0 additions & 3 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ on:
pull_request: null
push:
branches:
- master
- '*.*'

name: static analysis
Expand All @@ -13,5 +12,3 @@ jobs:
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 2 additions & 0 deletions src/Config/SerializerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
9 changes: 6 additions & 3 deletions src/Normalizer/RamseyUuidNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -37,11 +37,14 @@ 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);
}

/**
* @return array<class-string, bool>
*/
public function getSupportedTypes(?string $format): array
{
return [
Expand Down

0 comments on commit f484db5

Please sign in to comment.