From a546f09cb6bdb9f289a8fcd462437b86c19d9f90 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Fri, 15 Sep 2023 17:40:30 -0400 Subject: [PATCH] Add Symfony 7 support --- .github/workflows/run-tests.yml | 9 ++++-- composer.json | 32 +++++++++---------- src/BabDevPagerfantaBundle.php | 2 +- .../Normalizer/PagerfantaNormalizerTest.php | 9 ++++++ 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c161a0d..8cbc58e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,8 +9,8 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.1', '8.2'] - symfony: ['5.4.*', '6.2.*', '6.3.*'] + php: ['8.1', '8.2', '8.3'] + symfony: ['5.4.*', '6.3.*', '6.4.*', '7.0.*'] pagerfanta: [''] composer-flags: ['--prefer-stable'] can-fail: [false] @@ -18,7 +18,7 @@ jobs: include: # Run "no Twig" build on latest PHP and Symfony LTS - php: '8.2' - symfony: '5.4.*' + symfony: '6.4.*' composer-flags: '--prefer-stable' can-fail: false with-twig: false @@ -27,6 +27,9 @@ jobs: composer-flags: '--prefer-stable --prefer-lowest' can-fail: false with-twig: true + exclude: + - php: '8.1' + symfony: '7.0.*' name: "PHP ${{ matrix.php }}${{ matrix.pagerfanta != '' && format(' - Pagerfanta {0}', matrix.pagerfanta) || '' }}${{ matrix.with-twig == false && ' - Without Twig' || '' }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}" diff --git a/composer.json b/composer.json index c4e260b..ee9510c 100644 --- a/composer.json +++ b/composer.json @@ -8,38 +8,38 @@ "php": "^8.1", "pagerfanta/core": "^3.7 || ^4.0", "psr/container": "^1.0 || ^2.0", - "symfony/config": "^5.4 || ^6.2", - "symfony/dependency-injection": "^5.4 || ^6.2", - "symfony/http-foundation": "^5.4 || ^6.2", - "symfony/http-kernel": "^5.4 || ^6.2", - "symfony/property-access": "^5.4 || ^6.2", - "symfony/routing": "^5.4 || ^6.2" + "symfony/config": "^5.4 || ^6.3 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.3 || ^7.0", + "symfony/http-foundation": "^5.4 || ^6.3 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.3 || ^7.0", + "symfony/property-access": "^5.4 || ^6.3 || ^7.0", + "symfony/routing": "^5.4 || ^6.3 || ^7.0" }, "require-dev": { "jms/serializer": "^3.18", "jms/serializer-bundle": "^4.2 || ^5.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.3.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.0@dev", "pagerfanta/twig": "^3.7 || ^4.0", "phpstan/extension-installer": "^1.2", "phpstan/phpstan": "1.10.34", "phpstan/phpstan-phpunit": "1.3.14", "phpstan/phpstan-symfony": "1.3.2", "phpunit/phpunit": "9.6.12", - "symfony/phpunit-bridge": "^5.4 || ^6.2", - "symfony/serializer": "^5.4 || ^6.2", - "symfony/twig-bridge": "^5.4 || ^6.2", - "symfony/twig-bundle": "^5.4 || ^6.2", - "symfony/translation": "^5.4 || ^6.2", + "symfony/phpunit-bridge": "^5.4 || ^6.3 || ^7.0", + "symfony/serializer": "^5.4 || ^6.3 || ^7.0", + "symfony/twig-bridge": "^5.4 || ^6.3 || ^7.0", + "symfony/twig-bundle": "^5.4 || ^6.3 || ^7.0", + "symfony/translation": "^5.4 || ^6.3 || ^7.0", "twig/twig": "^2.13 || ^3.0" }, "conflict": { "jms/serializer": "<3.18", "jms/serializer-bundle": "<4.2", "pagerfanta/twig": "<3.7", - "symfony/serializer": "<5.4 || >=6.0,<6.2", - "symfony/translation": "<5.4 || >=6.0,<6.2", - "symfony/twig-bridge": "<5.4 || >=6.0,<6.2", - "symfony/twig-bundle": "<5.4 || >=6.0,<6.2", + "symfony/serializer": "<5.4 || >=6.0,<6.3", + "symfony/translation": "<5.4 || >=6.0,<6.3", + "symfony/twig-bridge": "<5.4 || >=6.0,<6.3", + "symfony/twig-bundle": "<5.4 || >=6.0,<6.3", "twig/twig": "<2.13", "white-october/pagerfanta-bundle": "*" }, diff --git a/src/BabDevPagerfantaBundle.php b/src/BabDevPagerfantaBundle.php index 05d88ed..da17d03 100644 --- a/src/BabDevPagerfantaBundle.php +++ b/src/BabDevPagerfantaBundle.php @@ -21,7 +21,7 @@ public function build(ContainerBuilder $container): void public function getContainerExtension(): ?ExtensionInterface { - if (null === $this->extension) { + if (!isset($this->extension)) { $this->extension = new BabDevPagerfantaExtension(); } diff --git a/tests/Serializer/Normalizer/PagerfantaNormalizerTest.php b/tests/Serializer/Normalizer/PagerfantaNormalizerTest.php index 13412dd..cac7adc 100644 --- a/tests/Serializer/Normalizer/PagerfantaNormalizerTest.php +++ b/tests/Serializer/Normalizer/PagerfantaNormalizerTest.php @@ -10,6 +10,7 @@ use Pagerfanta\PagerfantaInterface; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Exception\InvalidArgumentException; +use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; use Symfony\Component\Serializer\Serializer; final class PagerfantaNormalizerTest extends TestCase @@ -42,6 +43,10 @@ public function testNormalize(): void */ public function testNormalizeWithLegacyDecorator(): void { + if (!interface_exists(CacheableSupportsMethodInterface::class)) { + self::markTestSkipped('Test requires symfony/serializer:<6.4'); + } + $pager = new Pagerfanta( new NullAdapter(25), ); @@ -90,6 +95,10 @@ public function testSupportsNormalization(mixed $data, bool $supported): void */ public function testHasCacheableSupportsMethod(): void { + if (!interface_exists(CacheableSupportsMethodInterface::class)) { + self::markTestSkipped('Test requires symfony/serializer:<6.4'); + } + self::assertTrue((new LegacyPagerfantaNormalizer(new PagerfantaNormalizer()))->hasCacheableSupportsMethod()); }