Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support symfony 7 #34

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 44 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
name: Tests

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "0 7 * * 1"
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '0 7 * * 1'

jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ["7.4", "8.0", "8.1"]
sf: ["5.4.*", "6.0.*", "6.1.*"]
exclude:
- php: "7.4"
sf: "6.1.*"
- php: "8.0"
sf: "6.1.*"
- php: "7.4"
sf: "6.0.*"
steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
with:
php_version: "${{ matrix.php }}"
command: require symfony/serializer:${{ matrix.sf }} --no-update
- uses: php-actions/composer@v6
with:
php_version: "${{ matrix.php }}"
command: update
- uses: php-actions/phpunit@v3
with:
configuration: phpunit.xml.dist
memory_limit: 256M
php_version: "${{ matrix.php }}"
- uses: php-actions/phpstan@v3
with:
php_version: "${{ matrix.php }}"
level: max
path: src/
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
sf: ['5.4.*', '6.4.*', '7.0.*']
exclude:
- php: '7.4'
sf: '6.4.*'
- php: '8.0'
sf: '6.4.*'
- php: '7.4'
sf: '7.0.*'
- php: '8.0'
sf: '7.0.*'
- php: '8.1'
sf: '7.0.*'
steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
with:
php_version: '${{ matrix.php }}'
command: require symfony/serializer:${{ matrix.sf }} --no-update
- uses: php-actions/composer@v6
with:
php_version: '${{ matrix.php }}'
command: update
- uses: php-actions/phpunit@v3
with:
configuration: phpunit.xml.dist
memory_limit: 256M
php_version: '${{ matrix.php }}'
version: 9.5
- uses: php-actions/phpstan@v3
with:
php_version: '${{ matrix.php }}'
level: max
path: src/
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
}
},
"require": {
"php": "^7.4|^8.0|^8.1",
"php": "^7.4|^8.0",
"ramsey/uuid": "^4.0",
"symfony/serializer": "^5.4|^6.0"
"symfony/serializer": "^5.4|^6.0|^7.0"
},
"require-dev": {
"symfony/property-access": "^5.4|^6.0",
"symfony/property-access": "^5.4|^6.0|^7.0",
"phpdocumentor/reflection-docblock": "^5.3",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.8"
Expand Down
20 changes: 12 additions & 8 deletions src/UuidDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
class UuidDenormalizer implements DenormalizerInterface
{
/**
* {@inheritdoc}
*
* @param array<mixed> $context
*
* @throws UnexpectedValueException
*
* @return UuidInterface|null
*/
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize($data, string $type, string $format = null, array $context = []): ?UuidInterface
{
if (null === $data) {
return null;
Expand All @@ -37,12 +33,20 @@ public function denormalize($data, $type, $format = null, array $context = [])
}

/**
* {@inheritdoc}
*
* @param array<mixed> $context
*/
public function supportsDenormalization($data, string $type, string $format = null, array $context = [])
public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool
{
return Uuid::class === $type || UuidInterface::class === $type;
}

/**
* @return array<string, bool>
*/
public function getSupportedTypes(?string $format): array
{
return [
UuidInterface::class => true,
];
}
}
27 changes: 17 additions & 10 deletions src/UuidNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,32 @@
class UuidNormalizer implements NormalizerInterface
{
/**
* {@inheritdoc}
*
* @param array<mixed> $context
* @param UuidInterface $object
*
* @return string
* @param array<mixed> $context
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): string
{
if (!$object instanceof UuidInterface) {
throw new \InvalidArgumentException('Expected a UuidInterface.');
}

return $object->toString();
}

/**
* {@inheritdoc}
*
* @param array<mixed> $context
*/
public function supportsNormalization($data, $format = null, array $context = [])
public function supportsNormalization($data, $format = null, array $context = []): bool
{
return $data instanceof UuidInterface;
}

/**
* @return array<string, bool>
*/
public function getSupportedTypes(?string $format): array
{
return [
UuidInterface::class => true,
];
}
}