Skip to content

Commit

Permalink
Add support for Symfony 7 and drop support for Symfony <6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Dec 17, 2023
1 parent 0596709 commit 8c32ccd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
45 changes: 14 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,36 @@ jobs:
strategy:
matrix:
php:
- "8.1"
- "8.2"
- "8.3"

env:
extensions: ctype, dom, intl, json, mbstring, openssl, xml, zip, zlib
key: cache-v1 # can be any string, change to clear the extension cache.
symfony:
- "^6.4"
- "^7.0"
include:
- php: "8.1"
symfony: "^6.4"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- uses: actions/checkout@v4

- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
tools: composer, pecl
coverage: xdebug
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: "ramsey/composer-install@v2"
- name: Install composer requirements
run: composer require -W "symfony/serializer:${{ matrix.symfony }}"

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup Problem Matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run PHPStan
run: vendor/bin/phpstan

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: vendor/bin/phpunit --testdox --coverage-text
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Added support for PHP 8.3
* Dropped support for PHP 8.0
* Added support for Symfony 7
* Dropped support for Symfony <6.4

## 3.0.0 - 2022-04-05

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"ramsey/uuid": "^4.3.1",
"symfony/serializer": "^6.0"
"ramsey/uuid": "^4.7.5",
"symfony/serializer": "^6.4 || ^7.0.1"
},
"require-dev": {
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.50",
"phpstan/phpstan-phpunit": "^1.3.15",
"phpunit/phpunit": "^10.5.3",
"symfony/property-access": "^6.0"
"symfony/property-access": "^6.4 || ^7.0"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 19 additions & 2 deletions src/Normalizer/UuidNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
return Uuid::fromString($data);
}

public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
/**
* @param array<string, mixed> $context
*/
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);
}
Expand All @@ -31,8 +34,22 @@ public function normalize(mixed $object, string $format = null, array $context =
return $object->toString();
}

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

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

0 comments on commit 8c32ccd

Please sign in to comment.