From f1ed1f396fc71c23eac327a8115fa9cb933a9771 Mon Sep 17 00:00:00 2001 From: Erwan N Date: Wed, 29 Nov 2023 14:59:04 +0100 Subject: [PATCH] added symfony 7.x compatibility and drop outdated symfony support --- .github/workflows/tests.yml | 11 ++++++----- composer.json | 16 ++++++++-------- .../FileToBase64EncodedStringTransformer.php | 4 ++-- src/Serializer/Base64EncodedFileNormalizer.php | 11 +++++++++-- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 96d42e0..6f4df8d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,13 +10,14 @@ jobs: strategy: matrix: include: + - php: 8.2 + - php: 8.2 + composer-dependencies: symfony/symfony:^7 + - php: 8.1 + - php: 8.1 + composer-dependencies: symfony/symfony:^6 - php: 8.1 - - php: 8.0 - - php: 7.4 - - php: 7.4 composer-dependencies: symfony/symfony:^5 - - php: 7.4 - composer-dependencies: symfony/symfony:^4 steps: - name: Checkout uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index 9cc585c..696488e 100644 --- a/composer.json +++ b/composer.json @@ -10,16 +10,16 @@ ], "require": { "php": "^7.4.0 || ^8.0.0", - "symfony/http-foundation": "^4.4.7 || ^5.0.7 || ^6.0", - "symfony/mime": "^4.3.8 || ^5.0 || ^6.0" + "symfony/http-foundation": "^5.4 || ^6.0 || ^7.0", + "symfony/mime": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { - "symfony/form": "^4.0 || ^5.0 || ^6.0", - "symfony/serializer": "^4.0 || ^5.0 || ^6.0", + "symfony/form": "^5.4 || ^6.0 || ^7.0", + "symfony/serializer": "^5.4 || ^6.0 || ^7.0", "phpunit/phpunit": "^9.0.0", - "symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0", - "symfony/config": "^4.0 || ^5.0 || ^6.0", - "symfony/http-kernel": "^4.0 || ^5.0 || ^6.0" + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0" }, "suggest": { "symfony/form": "to use base64_encoded_file type", @@ -43,7 +43,7 @@ }, "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } } } diff --git a/src/Form/DataTransformer/FileToBase64EncodedStringTransformer.php b/src/Form/DataTransformer/FileToBase64EncodedStringTransformer.php index 536f6d2..e75cd51 100644 --- a/src/Form/DataTransformer/FileToBase64EncodedStringTransformer.php +++ b/src/Form/DataTransformer/FileToBase64EncodedStringTransformer.php @@ -29,7 +29,7 @@ public function __construct($strict = true) /** * {@inheritdoc} */ - public function transform($value) + public function transform(mixed $value): mixed { if (! $value instanceof \SplFileInfo) { return ''; @@ -45,7 +45,7 @@ public function transform($value) /** * {@inheritdoc} */ - public function reverseTransform($value) + public function reverseTransform(mixed $value): mixed { if (empty($value)) { return null; diff --git a/src/Serializer/Base64EncodedFileNormalizer.php b/src/Serializer/Base64EncodedFileNormalizer.php index 6d6b376..3337b4d 100644 --- a/src/Serializer/Base64EncodedFileNormalizer.php +++ b/src/Serializer/Base64EncodedFileNormalizer.php @@ -10,13 +10,20 @@ */ final class Base64EncodedFileNormalizer implements DenormalizerInterface { - public function denormalize($data, $class, $format = null, array $context = array()) + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed { return new Base64EncodedFile($data); } - public function supportsDenormalization($data, $type, $format = null) + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return Base64EncodedFile::class === $type && \is_string($data); } + + public function getSupportedTypes(?string $format): array + { + return [ + '*' => true, + ]; + } }