From 267419bd07b7279336d4022dc5e6c2894d30df6f Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:55:00 +0700 Subject: [PATCH] deps: support api-platform 4 (#38) * deps: support api-platform 4 * don't fail on deprecation for now * silence deprecations --- CHANGELOG.md | 4 ++++ composer.json | 16 +++++++++------- phpunit.xml.dist | 5 +++-- tests/config/packages/api_platform.yaml | 2 -- tests/src/Kernel.php | 17 +++++++++++++++++ 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0285cb3..ff5cdaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.8.0 + +* deps: support api-platform 4 + ## 0.7.7 * deps: bump rekapager diff --git a/composer.json b/composer.json index 254a2d1..6c38cbd 100644 --- a/composer.json +++ b/composer.json @@ -20,19 +20,21 @@ ], "require": { "php": ">=8.2", - "api-platform/core": "^3.2.12 || ^3.3", + "api-platform/core": "^3.2.12 || ^3.3 || ^4.0", "doctrine/collections": "^2.2", - "rekalogika/mapper": "^1.1", - "rekalogika/rekapager-api-platform": "^0.18", - "rekalogika/rekapager-doctrine-collections-adapter": "^0.18", - "rekalogika/rekapager-doctrine-orm-adapter": "^0.18", + "rekalogika/mapper": "^1.13.3 || ^1.14", + "rekalogika/rekapager-api-platform": "^0.19", + "rekalogika/rekapager-doctrine-collections-adapter": "^0.19", + "rekalogika/rekapager-doctrine-orm-adapter": "^0.19", "symfony/dependency-injection": "^6.4 || ^7.0", "symfony/http-kernel": "^6.4 || ^7.0", "symfony/security-core": "^6.4 || ^7.0", "symfony/service-contracts": "^3.4" }, "require-dev": { + "composer-runtime-api": "^2.2", "bnf/phpstan-psr-container": "^1.0", + "composer/semver": "^3.4", "doctrine/doctrine-bundle": "^2.12", "doctrine/doctrine-fixtures-bundle": "^3.5", "doctrine/orm": "^2.14 || ^3.0", @@ -48,15 +50,15 @@ "rekalogika/doctrine-collections-decorator": "^2.2", "symfony/asset": "^6.4 || ^7.0", "symfony/browser-kit": "^6.4 || ^7.0", - "symfony/doctrine-bridge": "^6.4 || ^7.0", "symfony/debug-bundle": "^6.4 || ^7.0", + "symfony/doctrine-bridge": "^6.4 || ^7.0", "symfony/event-dispatcher": "^6.4 || ^7.0", "symfony/expression-language": "^6.4 || ^7.0", "symfony/framework-bundle": "^6.4 || ^7.0", "symfony/http-client": "^6.4 || ^7.0", + "symfony/maker-bundle": "^1.55", "symfony/property-access": "^6.4.4 || ^7.0.4 || ^7.1", "symfony/property-info": "6.4.0 - 6.4.8 || 7.0.0 - 7.0.8 || 7.1.0 - 7.1.1 || ^7.2", - "symfony/maker-bundle": "^1.55", "symfony/routing": "^6.4 || ^7.0", "symfony/runtime": "^6.4 || ^7.0", "symfony/security-bundle": "^6.4 || ^7.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f05b8e3..54cca39 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,6 +7,7 @@ beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="false" + failOnDeprecation="false" cacheDirectory=".phpunit.cache" beStrictAboutCoverageMetadata="true" displayDetailsOnTestsThatTriggerDeprecations="true" @@ -16,7 +17,7 @@ + value="0" /> @@ -41,4 +42,4 @@ src - \ No newline at end of file + diff --git a/tests/config/packages/api_platform.yaml b/tests/config/packages/api_platform.yaml index 6e76078..3df72ac 100644 --- a/tests/config/packages/api_platform.yaml +++ b/tests/config/packages/api_platform.yaml @@ -22,8 +22,6 @@ api_platform: rfc_7807_compliant_errors: true normalization_context: skip_null_values: false - event_listeners_backward_compatibility_layer: false - keep_legacy_inflector: false mapping: paths: - '%kernel.project_dir%/tests/src/ApiResource' diff --git a/tests/src/Kernel.php b/tests/src/Kernel.php index 63cd63e..8791a9a 100644 --- a/tests/src/Kernel.php +++ b/tests/src/Kernel.php @@ -5,6 +5,8 @@ namespace App; use ApiPlatform\Symfony\Bundle\ApiPlatformBundle; +use Composer\InstalledVersions; +use Composer\Semver\VersionParser; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle; use Rekalogika\ApiLite\RekalogikaApiLiteBundle; @@ -68,5 +70,20 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(function (ContainerBuilder $container) { $container->loadFromExtension('rekalogika_api_lite', $this->config); }); + + $loader->load(function (ContainerBuilder $container): void { + if (InstalledVersions::satisfies(new VersionParser(), 'api-platform/core', '3.*')) { + $container->loadFromExtension('api_platform', [ + 'event_listeners_backward_compatibility_layer' => false, + 'keep_legacy_inflector' => false, + ]); + } elseif (InstalledVersions::satisfies(new VersionParser(), 'api-platform/core', '4.*')) { + $container->loadFromExtension('api_platform', [ + 'serializer' => [ + 'hydra_prefix' => true, + ], + ]); + } + }); } }