From 82217b49528e8da980bba1c7eafa13a21e7d3c67 Mon Sep 17 00:00:00 2001 From: Steevan BARBOYON Date: Fri, 24 May 2024 16:14:39 +0200 Subject: [PATCH] Add Symfony 7.0 support --- .github/workflows/ci.yml | 10 ++++++++++ bin/ci/phpstan | 2 +- bin/ci/phpunit | 2 +- bin/ci/phpunit-coverage | 2 +- bin/ci/phpunit.inc.php | 5 ++++- bin/ci/validate | 2 +- .../Normalizer/ObjectCollectionDenormalizer.php | 12 +++++++++++- .../Normalizer/ScalarCollectionDenormalizer.php | 16 +++++++++++++++- changelog.md | 2 ++ docker/ci/Dockerfile | 8 ++++++-- 10 files changed, 52 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3438bca..e0167a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,3 +59,13 @@ jobs: - uses: actions/checkout@v2 - uses: ./.github/actions/ci-env - run: bin/ci/phpunit ${{ matrix.php }} ${{ matrix.symfony }} + + phpunit-symfony-7: + runs-on: ubuntu-latest + strategy: + matrix: + php: [--php=8.2, --php=8.3] + steps: + - uses: actions/checkout@v2 + - uses: ./.github/actions/ci-env + - run: bin/ci/phpunit ${{ matrix.php }} --symfony=7.0 diff --git a/bin/ci/phpstan b/bin/ci/phpstan index c081843..3d1ee3a 100755 --- a/bin/ci/phpstan +++ b/bin/ci/phpstan @@ -26,7 +26,7 @@ if [ "${clearCache}" == true ] && [ -d "${ROOT_DIR}"/var/ci/phpstan ]; then fi if [ "${phpVersion}" == "" ]; then - php8.1 "${ROOT_DIR}"/bin/ci/phpstan.php ${phpstanParameters} + php8.2 "${ROOT_DIR}"/bin/ci/phpstan.php ${phpstanParameters} else echo "PHP ${phpVersion}" diff --git a/bin/ci/phpunit b/bin/ci/phpunit index 90d59c9..4311bf8 100755 --- a/bin/ci/phpunit +++ b/bin/ci/phpunit @@ -20,7 +20,7 @@ for arg in "${@}"; do done if [ "${phpVersion}" == "" ] || [ "${symfonyVersion}" == "" ]; then - php8.1 "${ROOT_DIR}"/bin/ci/phpunit.php "${@}" + php8.2 "${ROOT_DIR}"/bin/ci/phpunit.php "${@}" else echo "PHP ${phpVersion} - Symfony ${symfonyVersion}" diff --git a/bin/ci/phpunit-coverage b/bin/ci/phpunit-coverage index e9bb2c9..9a45c22 100755 --- a/bin/ci/phpunit-coverage +++ b/bin/ci/phpunit-coverage @@ -9,7 +9,7 @@ readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")" echo "PHP 8.1 - Symfony 6.1" set +e XDEBUG_MODE=coverage \ - php8.1 \ + php8.2 \ "${ROOT_DIR}"/vendor/bin/phpunit \ --bootstrap "${COMPOSER_HOME_SYMFONY_6_1}"/vendor/autoload.php \ --coverage-html "${ROOT_DIR}"/var/ci/phpunit/coverage/html \ diff --git a/bin/ci/phpunit.inc.php b/bin/ci/phpunit.inc.php index bbe127c..f6a8b47 100644 --- a/bin/ci/phpunit.inc.php +++ b/bin/ci/phpunit.inc.php @@ -12,12 +12,15 @@ function createPhpunitProcesses(string $phpVersion = null, string $symfonyVersio { $phpVersions = new StringCollection(is_string($phpVersion) ? [$phpVersion] : ['8.1', '8.2', '8.3']); $symfonyVersions = new StringCollection( - is_string($symfonyVersion) ? [$symfonyVersion] : ['6.1', '6.2', '6.3', '6.4'] + is_string($symfonyVersion) ? [$symfonyVersion] : ['6.1', '6.2', '6.3', '6.4', '7.0'] ); $return = new ProcessInterfaceCollection(); foreach ($phpVersions->toArray() as $loopPhpVersion) { foreach ($symfonyVersions->toArray() as $loopSymfonyVersion) { + if ($loopSymfonyVersion === '7.0' && in_array($loopPhpVersion, ['8.2', '8.3'], true) === false) { + continue; + } $return->add(createPhpunitProcess($loopPhpVersion, $loopSymfonyVersion)); } } diff --git a/bin/ci/validate b/bin/ci/validate index 064e2e6..b42da73 100755 --- a/bin/ci/validate +++ b/bin/ci/validate @@ -6,4 +6,4 @@ readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")" . "${ROOT_DIR}"/bin/common.inc.sh . "${ROOT_DIR}"/bin/dockerise.inc.bash -php8.1 "${ROOT_DIR}"/bin/ci/validate.php "${@}" +php8.2 "${ROOT_DIR}"/bin/ci/validate.php "${@}" diff --git a/bridge/Symfony/Normalizer/ObjectCollectionDenormalizer.php b/bridge/Symfony/Normalizer/ObjectCollectionDenormalizer.php index 67016f8..c99b63f 100644 --- a/bridge/Symfony/Normalizer/ObjectCollectionDenormalizer.php +++ b/bridge/Symfony/Normalizer/ObjectCollectionDenormalizer.php @@ -19,13 +19,23 @@ class ObjectCollectionDenormalizer implements DenormalizerInterface, Denormalize { use DenormalizerAwareTrait; - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + /** @param array $context */ + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return is_subclass_of($type, AbstractObjectCollection::class) || is_subclass_of($type, AbstractObjectNullableCollection::class); } + /** @return array */ + public function getSupportedTypes(?string $format): array + { + return [ + AbstractObjectCollection::class => false, + AbstractObjectNullableCollection::class => false + ]; + } + /** * @param array $context * @return AbstractObjectCollection|AbstractObjectNullableCollection diff --git a/bridge/Symfony/Normalizer/ScalarCollectionDenormalizer.php b/bridge/Symfony/Normalizer/ScalarCollectionDenormalizer.php index fc008a0..d0d88e6 100644 --- a/bridge/Symfony/Normalizer/ScalarCollectionDenormalizer.php +++ b/bridge/Symfony/Normalizer/ScalarCollectionDenormalizer.php @@ -17,7 +17,8 @@ class ScalarCollectionDenormalizer implements DenormalizerInterface { - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + /** @param array $context */ + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { return in_array( $type, @@ -33,6 +34,19 @@ public function supportsDenormalization(mixed $data, string $type, string $forma ); } + /** @return array */ + public function getSupportedTypes(?string $format): array + { + return [ + FloatCollection::class => false, + FloatNullableCollection::class => false, + IntegerCollection::class => false, + IntegerNullableCollection::class => false, + StringCollection::class => false, + StringNullableCollection::class => false + ]; + } + /** * @param array $context * @return CollectionInterface diff --git a/changelog.md b/changelog.md index 70c60f4..d5324c0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ ### master +- Add support for Symfony `7.0` + ### [6.0.1](../../compare/6.0.0...6.0.1) - 2024-05-15 - Documentation diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile index b276e64..109f541 100644 --- a/docker/ci/Dockerfile +++ b/docker/ci/Dockerfile @@ -7,6 +7,7 @@ ENV COMPOSER_HOME_SYMFONY_6_1=/composer/symfony-6-1 ENV COMPOSER_HOME_SYMFONY_6_2=/composer/symfony-6-2 ENV COMPOSER_HOME_SYMFONY_6_3=/composer/symfony-6-3 ENV COMPOSER_HOME_SYMFONY_6_4=/composer/symfony-6-4 +ENV COMPOSER_HOME_SYMFONY_7_0=/composer/symfony-7-0 ENV PHPSTAN_BIN_PATH=/usr/local/bin/phpstan COPY docker/ci/composer.json ${COMPOSER_HOME}/composer.json @@ -26,11 +27,11 @@ RUN \ php8.3-cli \ php8.3-simplexml \ # For Composer - curl zip php8.1-curl php8.1-zip \ + curl zip php8.1-curl php8.1-zip php8.2-curl php8.2-zip \ # For unused-scanner and phpunit php8.1-mbstring php8.2-mbstring php8.3-mbstring \ # For coverage - php8.1-xdebug \ + php8.2-xdebug \ && update-alternatives --set php /usr/bin/php8.1 \ # Install CI tools @@ -47,6 +48,9 @@ RUN \ && COMPOSER_HOME=${COMPOSER_HOME_SYMFONY_6_3} composer global require symfony/serializer:6.3.* \ && COMPOSER_HOME=${COMPOSER_HOME_SYMFONY_6_4} composer global require symfony/serializer:6.4.* \ + && update-alternatives --set php /usr/bin/php8.2 \ + && COMPOSER_HOME=${COMPOSER_HOME_SYMFONY_7_0} composer global require symfony/serializer:7.0.* \ + # Purge && apt-get purge -y software-properties-common \ && apt-get autoremove -y \