Skip to content

Commit

Permalink
feat: support symfony 7
Browse files Browse the repository at this point in the history
Ref: #33
  • Loading branch information
gbprod committed Jan 15, 2024
1 parent 062a3d9 commit 1aa39fb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 61 deletions.
78 changes: 39 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
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']
sf: ['5.4.*', '6.4.*', '7.0.*']
exclude:
- php: '7.4'
sf: '6.4.*'
- php: '8.0'
sf: '6.4.*'
- 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 }}'
- uses: php-actions/phpstan@v3
with:
php_version: '${{ matrix.php }}'
level: max
path: src/
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
}
},
"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",
"phpunit/phpunit": "^9.5<10.0",
"phpstan/phpstan": "^1.8"
},
"license": "WTFPL",
Expand Down
17 changes: 9 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(mixed $data, string $type, string $format = null, array $context = []): ?UuidInterface
{
if (null === $data) {
return null;
Expand All @@ -37,12 +33,17 @@ 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;
}

public function getSupportedTypes(?string $format): array
{
return [
UuidInterface::class => true,
];
}
}
20 changes: 10 additions & 10 deletions src/UuidNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
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(mixed $object, $format = null, array $context = []): string
{
return $object->toString();
}

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

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

0 comments on commit 1aa39fb

Please sign in to comment.