diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5765230f696..1154c097cb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - run: composer check-dependencies php-cs-fixer: @@ -119,7 +122,9 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies run: | - composer update --no-interaction --no-progress --ansi + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Run container lint run: tests/Fixtures/app/console lint:container @@ -157,7 +162,9 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies run: | - composer update --no-interaction --no-progress --ansi + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Cache PHPStan results @@ -217,7 +224,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -296,7 +306,9 @@ jobs: ini-values: memory_limit=-1 - name: Run ${{ matrix.component }} install run: | - composer update + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --permanent composer ${{matrix.component}} update - name: PHP version tweaks if: matrix.component == 'api-platform/metadata' && matrix.php != '8.1' @@ -371,7 +383,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -474,7 +489,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -524,7 +542,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -577,7 +598,9 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies run: | - composer update --no-interaction --no-progress --ansi + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --permanent composer require --dev doctrine/mongodb-odm-bundle - name: Install PHPUnit run: vendor/bin/simple-phpunit --version @@ -669,7 +692,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -754,7 +780,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -804,7 +833,11 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --prefer-lowest --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --permanent + composer update --prefer-lowest - name: Clear test app cache run: tests/Fixtures/app/console cache:clear --ansi - name: Run Behat tests @@ -840,7 +873,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -882,7 +918,10 @@ jobs: - name: Remove cache run: rm -Rf tests/Fixtures/app/var/cache/* - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -927,7 +966,10 @@ jobs: - name: Remove cache run: rm -Rf tests/Fixtures/app/var/cache/* - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -976,8 +1018,17 @@ jobs: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- + - name: Keep windows path + id: get-cwd + run: | + cwd=$(php -r 'echo(str_replace("\\", "\\\\", $_SERVER["argv"][1]));' '${{ github.workspace }}') + echo cwd=$cwd >> $GITHUB_OUTPUT + shell: bash - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --working-directory='${{ steps.get-cwd.outputs.cwd }}' - name: Install phpunit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -1028,8 +1079,17 @@ jobs: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- + - name: Keep windows path + id: get-cwd + run: | + cwd=$(php -r 'echo(str_replace("\\", "\\\\", $_SERVER["argv"][1]));' '${{ github.workspace }}') + echo cwd=$cwd >> $GITHUB_OUTPUT + shell: bash - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --working-directory='${{ steps.get-cwd.outputs.cwd }}' - name: Install phpunit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -1069,7 +1129,11 @@ jobs: - name: Remove cache run: rm -Rf tests/Fixtures/app/var/cache/* - name: Update project dependencies - run: composer update --prefer-lowest --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --permanent + composer update --prefer-lowest - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -1113,7 +1177,11 @@ jobs: - name: Remove cache run: rm -Rf tests/Fixtures/app/var/cache/* - name: Update project dependencies - run: composer update --prefer-lowest --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . --permanent + composer update --prefer-lowest - name: Clear test app cache run: tests/Fixtures/app/console cache:clear --ansi - name: Run Behat tests @@ -1157,7 +1225,10 @@ jobs: if: matrix.coverage run: echo "COVERAGE=1" >> $GITHUB_ENV - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -1230,7 +1301,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -1299,7 +1373,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache @@ -1368,7 +1445,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Update project dependencies - run: composer update --no-interaction --no-progress --ansi + run: | + composer global require soyuka/pmu + composer global config allow-plugins.soyuka/pmu true --no-interaction + composer global link . - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache diff --git a/composer.json b/composer.json index 72ec9581e23..d82aba7429c 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,23 @@ "willdurand/negotiation": "^3.0" }, "require-dev": { + "api-platform/json-schema": "^3.2 || ^4.0", + "api-platform/metadata": "^3.2 || ^4.0", + "api-platform/state": "^3.2 || ^4.0", + "api-platform/doctrine-common": "^3.2 || ^4.0", + "api-platform/doctrine-odm": "^3.2 || ^4.0", + "api-platform/doctrine-orm": "^3.2 || ^4.0", + "api-platform/openapi": "^3.2 || ^4.0", + "api-platform/ramsey-uuid": "^3.2 || ^4.0", + "api-platform/jsonld": "^3.2 || ^4.0", + "api-platform/serializer": "^3.2 || ^4.0", + "api-platform/json-api": "^3.3 || ^4.0", + "api-platform/http-cache": "^3.2 || ^4.0", + "api-platform/elasticsearch": "^3.2 || ^4.0", + "api-platform/hydra": "^3.2 || ^4.0", + "api-platform/documentation": "^3.2 || ^4.0", + "api-platform/validator": "^3.2 || ^4.0", + "api-platform/graphql": "^3.2 || ^4.0", "behat/behat": "^3.11", "behat/mink": "^1.9", "doctrine/cache": "^1.11 || ^2.1", @@ -67,7 +84,7 @@ "ramsey/uuid-doctrine": "^1.4 || ^2.0 || ^3.0", "sebastian/comparator": "<5.0", "soyuka/contexts": "v3.3.9", - "soyuka/pmu": "^0.0.4", + "soyuka/pmu": "^0.0.11", "soyuka/stubs-mongodb": "^1.0", "symfony/asset": "^6.4 || ^7.1", "symfony/browser-kit": "^6.4 || ^7.1", @@ -164,45 +181,8 @@ "symfony": { "require": "^6.4 || ^7.1" }, - "projects": [ - "api-platform/doctrine-common", - "api-platform/doctrine-orm", - "api-platform/doctrine-odm", - "api-platform/metadata", - "api-platform/json-schema", - "api-platform/elasticsearch", - "api-platform/jsonld", - "api-platform/hydra", - "api-platform/openapi", - "api-platform/graphql", - "api-platform/http-cache", - "api-platform/documentation", - "api-platform/parameter-validator", - "api-platform/ramsey-uuid", - "api-platform/serializer", - "api-platform/state", - "api-platform/symfony", - "api-platform/validator" - ] - }, - "repositories": [ - {"type": "path", "url": "./src/Doctrine/Common"}, - {"type": "path", "url": "./src/Doctrine/Orm"}, - {"type": "path", "url": "./src/Doctrine/Odm"}, - {"type": "path", "url": "./src/Metadata"}, - {"type": "path", "url": "./src/JsonSchema"}, - {"type": "path", "url": "./src/Elasticsearch"}, - {"type": "path", "url": "./src/JsonLd"}, - {"type": "path", "url": "./src/Hydra"}, - {"type": "path", "url": "./src/OpenApi"}, - {"type": "path", "url": "./src/GraphQl"}, - {"type": "path", "url": "./src/HttpCache"}, - {"type": "path", "url": "./src/Documentation"}, - {"type": "path", "url": "./src/ParameterValidator"}, - {"type": "path", "url": "./src/RamseyUuid"}, - {"type": "path", "url": "./src/Serializer"}, - {"type": "path", "url": "./src/State"}, - {"type": "path", "url": "./src/Symfony"}, - {"type": "path", "url": "./src/Validator"} - ] + "pmu": { + "projects": ["./src/*/composer.json", "src/Doctrine/*/composer.json"] + } + } } diff --git a/notes b/notes new file mode 100644 index 00000000000..fec926f7395 --- /dev/null +++ b/notes @@ -0,0 +1,11 @@ +makeHidden => serializer context builder + +supprimer PUT en 4.x + +trace => prod/dev +http cache => ?? +doc => ?? +hugo support github + +cast un decimal en objet money avec eloquent + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b955851e2f6..09c73664f39 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -86,7 +86,7 @@ parameters: # Expected, due to backward compatibility - message: "#Call to function method_exists\\(\\) with ApiPlatform\\\\JsonApi\\\\Serializer\\\\ItemNormalizer and 'setCircularReferenc…' will always evaluate to false\\.#" - path: tests/JsonApi/Serializer/ItemNormalizerTest.php + path: src/JsonApi/Tests/Serializer/ItemNormalizerTest.php - '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#' - '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#' # See https://github.com/phpstan/phpstan-symfony/issues/27 diff --git a/src/Doctrine/Odm/composer.json b/src/Doctrine/Odm/composer.json index ef7d2a2569a..f1c4e11ddd6 100644 --- a/src/Doctrine/Odm/composer.json +++ b/src/Doctrine/Odm/composer.json @@ -22,15 +22,15 @@ ], "require": { "php": ">=8.1", - "api-platform/doctrine-common": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/doctrine-common": "^3.1", + "api-platform/metadata": "^3.1", + "api-platform/state": "^3.1", "doctrine/mongodb-odm": "^2.2", "doctrine/mongodb-odm-bundle": "^5.0", "symfony/property-info": "^6.4 || ^7.1" }, "require-dev": { - "api-platform/parameter-validator": "*@dev || ^3.2", + "api-platform/parameter-validator": "^3.2", "doctrine/doctrine-bundle": "^2.11", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^10.0", @@ -69,4 +69,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/Doctrine/Orm/composer.json b/src/Doctrine/Orm/composer.json index 40bebfceb4a..0928b494eac 100644 --- a/src/Doctrine/Orm/composer.json +++ b/src/Doctrine/Orm/composer.json @@ -21,15 +21,15 @@ ], "require": { "php": ">=8.1", - "api-platform/doctrine-common": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/doctrine-common": "^3.1", + "api-platform/metadata": "^3.1", + "api-platform/state": "^3.1", "doctrine/doctrine-bundle": "^2.11", "doctrine/orm": "^2.17 || ^3.0", "symfony/property-info": "^6.4 || ^7.1" }, "require-dev": { - "api-platform/parameter-validator": "*@dev || ^3.2", + "api-platform/parameter-validator": "^3.2", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^10.0", "ramsey/uuid": "^4.7", @@ -69,4 +69,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/Documentation/composer.json b/src/Documentation/composer.json index 96f61a8c2e6..6dde071e215 100644 --- a/src/Documentation/composer.json +++ b/src/Documentation/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "api-platform/metadata": "*@dev || ^3.1" + "api-platform/metadata": "^3.1" }, "extra": { "branch-alias": { @@ -31,4 +31,4 @@ "require": "^6.4 || ^7.1" } } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/composer.json b/src/Elasticsearch/composer.json index 5c4791593aa..effab5ca976 100644 --- a/src/Elasticsearch/composer.json +++ b/src/Elasticsearch/composer.json @@ -22,9 +22,9 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/serializer": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", + "api-platform/serializer": "^3.1", + "api-platform/state": "^3.1", "elasticsearch/elasticsearch": "^8.9", "symfony/cache": "^6.4 || ^7.0", "symfony/console": "^6.4 || ^7.0", @@ -69,4 +69,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/GraphQl/composer.json b/src/GraphQl/composer.json index 851c1fe827c..25df3829820 100644 --- a/src/GraphQl/composer.json +++ b/src/GraphQl/composer.json @@ -21,10 +21,10 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/serializer": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", - "api-platform/validator": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", + "api-platform/serializer": "^3.1", + "api-platform/state": "^3.1", + "api-platform/validator": "^3.1", "symfony/property-info": "^6.4 || ^7.1", "symfony/serializer": "^6.4 || ^7.1", "webonyx/graphql-php": "^14.0 || ^15.0", @@ -32,16 +32,16 @@ }, "require-dev": { "phpspec/prophecy-phpunit": "^2.0", - "api-platform/validator": "*@dev || ^3.1", + "api-platform/validator": "^3.1", "twig/twig": "^3.7", "symfony/mercure-bundle": "*", "symfony/phpunit-bridge": "^6.4 || ^7.0", "symfony/routing": "^6.4 || ^7.0", "symfony/validator": "^6.4 || ^7.0", "sebastian/comparator": "<5.0", - "api-platform/doctrine-common": "*@dev || ^3.2", - "api-platform/doctrine-odm": "*@dev || ^3.2", - "api-platform/doctrine-orm": "*@dev || ^3.2" + "api-platform/doctrine-common": "^3.2", + "api-platform/doctrine-odm": "^3.2", + "api-platform/doctrine-orm": "^3.2" }, "autoload": { "psr-4": { diff --git a/src/HttpCache/composer.json b/src/HttpCache/composer.json index d37dd56bd0e..865e830a6c1 100644 --- a/src/HttpCache/composer.json +++ b/src/HttpCache/composer.json @@ -21,8 +21,8 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", + "api-platform/state": "^3.1", "symfony/http-foundation": "^6.4 || ^7.1" }, "require-dev": { @@ -63,4 +63,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/Hydra/Serializer/ConstraintViolationListNormalizer.php b/src/Hydra/Serializer/ConstraintViolationListNormalizer.php index 86c5d088930..671a277a735 100644 --- a/src/Hydra/Serializer/ConstraintViolationListNormalizer.php +++ b/src/Hydra/Serializer/ConstraintViolationListNormalizer.php @@ -13,7 +13,8 @@ namespace ApiPlatform\Hydra\Serializer; -use ApiPlatform\Api\UrlGeneratorInterface; +use ApiPlatform\Api\UrlGeneratorInterface as LegacyUrlGeneratorInterface; +use ApiPlatform\Metadata\UrlGeneratorInterface; use ApiPlatform\Serializer\AbstractConstraintViolationListNormalizer; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; @@ -26,7 +27,7 @@ final class ConstraintViolationListNormalizer extends AbstractConstraintViolatio { public const FORMAT = 'jsonld'; - public function __construct(private readonly UrlGeneratorInterface $urlGenerator, ?array $serializePayloadFields = null, ?NameConverterInterface $nameConverter = null) + public function __construct(private readonly UrlGeneratorInterface|LegacyUrlGeneratorInterface $urlGenerator, ?array $serializePayloadFields = null, ?NameConverterInterface $nameConverter = null) { parent::__construct($serializePayloadFields, $nameConverter); } diff --git a/src/Hydra/Serializer/ErrorNormalizer.php b/src/Hydra/Serializer/ErrorNormalizer.php index fa8c9634a58..c44b00eb7ea 100644 --- a/src/Hydra/Serializer/ErrorNormalizer.php +++ b/src/Hydra/Serializer/ErrorNormalizer.php @@ -13,7 +13,8 @@ namespace ApiPlatform\Hydra\Serializer; -use ApiPlatform\Api\UrlGeneratorInterface; +use ApiPlatform\Api\UrlGeneratorInterface as LegacyUrlGeneratorInterface; +use ApiPlatform\Metadata\UrlGeneratorInterface; use ApiPlatform\Serializer\CacheableSupportsMethodInterface; use ApiPlatform\State\ApiResource\Error; use Symfony\Component\ErrorHandler\Exception\FlattenException; @@ -36,7 +37,7 @@ final class ErrorNormalizer implements NormalizerInterface, CacheableSupportsMet public const TITLE = 'title'; private array $defaultContext = [self::TITLE => 'An error occurred']; - public function __construct(private readonly UrlGeneratorInterface $urlGenerator, private readonly bool $debug = false, array $defaultContext = []) + public function __construct(private readonly LegacyUrlGeneratorInterface|UrlGeneratorInterface $urlGenerator, private readonly bool $debug = false, array $defaultContext = []) { $this->defaultContext = array_merge($this->defaultContext, $defaultContext); } diff --git a/src/Hydra/composer.json b/src/Hydra/composer.json index 23037b10700..06cb3707a41 100644 --- a/src/Hydra/composer.json +++ b/src/Hydra/composer.json @@ -28,17 +28,17 @@ ], "require": { "php": ">=8.1", - "api-platform/state": "*@dev || ^3.1", - "api-platform/documentation": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/jsonld": "*@dev || ^3.1", - "api-platform/json-schema": "*@dev || ^3.1", - "api-platform/serializer": "*@dev || ^3.1" + "api-platform/state": "^3.1", + "api-platform/documentation": "^3.1", + "api-platform/metadata": "^3.1", + "api-platform/jsonld": "^3.1", + "api-platform/json-schema": "^3.1", + "api-platform/serializer": "^3.1" }, "require-dev": { - "api-platform/doctrine-odm": "*@dev || ^3.2", - "api-platform/doctrine-orm": "*@dev || ^3.2", - "api-platform/doctrine-common": "*@dev || ^3.2" + "api-platform/doctrine-odm": "^3.2", + "api-platform/doctrine-orm": "^3.2", + "api-platform/doctrine-common": "^3.2" }, "autoload": { "psr-4": { @@ -70,4 +70,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/JsonApi/.gitattributes b/src/JsonApi/.gitattributes new file mode 100644 index 00000000000..ae3c2e1685a --- /dev/null +++ b/src/JsonApi/.gitattributes @@ -0,0 +1,2 @@ +/.gitignore export-ignore +/Tests export-ignore diff --git a/src/JsonApi/.gitignore b/src/JsonApi/.gitignore new file mode 100644 index 00000000000..eb0a8e7b262 --- /dev/null +++ b/src/JsonApi/.gitignore @@ -0,0 +1,3 @@ +/composer.lock +/vendor +/.phpunit.result.cache diff --git a/src/JsonApi/Tests/Fixtures/CircularReference.php b/src/JsonApi/Tests/Fixtures/CircularReference.php new file mode 100644 index 00000000000..d9808dd2f3e --- /dev/null +++ b/src/JsonApi/Tests/Fixtures/CircularReference.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\JsonApi\Tests\Fixtures; + +class CircularReference +{ + public $id; + public CircularReference $parent; +} diff --git a/src/JsonApi/Tests/Fixtures/CustomConverter.php b/src/JsonApi/Tests/Fixtures/CustomConverter.php new file mode 100644 index 00000000000..2dd8b9781cb --- /dev/null +++ b/src/JsonApi/Tests/Fixtures/CustomConverter.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\JsonApi\Tests\Fixtures; + +use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface; +use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; +use Symfony\Component\Serializer\NameConverter\NameConverterInterface; + +/** + * Custom converter that will only convert a property named "nameConverted" + * with the same logic as Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter. + */ +class CustomConverter implements AdvancedNameConverterInterface +{ + private NameConverterInterface $nameConverter; + + public function __construct() + { + $this->nameConverter = new CamelCaseToSnakeCaseNameConverter(); + } + + public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string + { + return 'nameConverted' === $propertyName ? $this->nameConverter->normalize($propertyName) : $propertyName; + } + + public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string + { + return 'name_converted' === $propertyName ? $this->nameConverter->denormalize($propertyName) : $propertyName; + } +} diff --git a/src/JsonApi/Tests/Fixtures/Dummy.php b/src/JsonApi/Tests/Fixtures/Dummy.php new file mode 100644 index 00000000000..3f3b9e16b05 --- /dev/null +++ b/src/JsonApi/Tests/Fixtures/Dummy.php @@ -0,0 +1,206 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\JsonApi\Tests\Fixtures; + +use ApiPlatform\Metadata\ApiProperty; +use ApiPlatform\Metadata\ApiResource; +use Symfony\Component\Validator\Constraints as Assert; + +/** + * Dummy. + * + * @author Kévin Dunglas + */ +#[ApiResource(filters: ['my_dummy.boolean', 'my_dummy.date', 'my_dummy.exists', 'my_dummy.numeric', 'my_dummy.order', 'my_dummy.range', 'my_dummy.search', 'my_dummy.property'], extraProperties: ['standard_put' => false])] +class Dummy +{ + /** + * @var int|null The id + */ + private $id; + + /** + * @var string The dummy name + */ + #[ApiProperty(iris: ['https://schema.org/name'])] + #[Assert\NotBlank] + private string $name; + + /** + * @var string|null The dummy name alias + */ + #[ApiProperty(iris: ['https://schema.org/alternateName'])] + private $alias; + + /** + * @var array foo + */ + private ?array $foo = null; + + /** + * @var string|null A short description of the item + */ + #[ApiProperty(iris: ['https://schema.org/description'])] + public $description; + + /** + * @var string|null A dummy + */ + public $dummy; + + /** + * @var bool|null A dummy boolean + */ + public ?bool $dummyBoolean = null; + /** + * @var \DateTime|null A dummy date + */ + #[ApiProperty(iris: ['https://schema.org/DateTime'])] + public $dummyDate; + + /** + * @var float|null A dummy float + */ + public $dummyFloat; + + /** + * @var string|null A dummy price + */ + public $dummyPrice; + + /** + * @var array|null serialize data + */ + public $jsonData = []; + + /** + * @var array|null + */ + public $arrayData = []; + + /** + * @var string|null + */ + public $nameConverted; + + public static function staticMethod(): void + { + } + + public function getId() + { + return $this->id; + } + + public function setId($id): void + { + $this->id = $id; + } + + public function setName(string $name): void + { + $this->name = $name; + } + + public function getName(): string + { + return $this->name; + } + + public function setAlias($alias): void + { + $this->alias = $alias; + } + + public function getAlias() + { + return $this->alias; + } + + public function setDescription($description): void + { + $this->description = $description; + } + + public function getDescription() + { + return $this->description; + } + + public function fooBar($baz): void + { + } + + public function getFoo(): ?array + { + return $this->foo; + } + + public function setFoo(?array $foo = null): void + { + $this->foo = $foo; + } + + public function setDummyDate(?\DateTime $dummyDate = null): void + { + $this->dummyDate = $dummyDate; + } + + public function getDummyDate() + { + return $this->dummyDate; + } + + public function setDummyPrice($dummyPrice) + { + $this->dummyPrice = $dummyPrice; + + return $this; + } + + public function getDummyPrice() + { + return $this->dummyPrice; + } + + public function setJsonData($jsonData): void + { + $this->jsonData = $jsonData; + } + + public function getJsonData() + { + return $this->jsonData; + } + + public function setArrayData($arrayData): void + { + $this->arrayData = $arrayData; + } + + public function getArrayData() + { + return $this->arrayData; + } + + public function setDummy($dummy = null): void + { + $this->dummy = $dummy; + } + + public function getDummy() + { + return $this->dummy; + } +} diff --git a/src/JsonApi/Tests/Fixtures/RelatedDummy.php b/src/JsonApi/Tests/Fixtures/RelatedDummy.php new file mode 100644 index 00000000000..befb25d37c4 --- /dev/null +++ b/src/JsonApi/Tests/Fixtures/RelatedDummy.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\JsonApi\Tests\Fixtures; + +use ApiPlatform\Metadata\ApiProperty; +use ApiPlatform\Metadata\ApiResource; +use Symfony\Component\Serializer\Annotation\Groups; + +/** + * Related Dummy. + * + * @author Kévin Dunglas + */ +#[ApiResource] +class RelatedDummy implements \Stringable +{ + #[ApiProperty(writable: false)] + #[Groups(['chicago', 'friends'])] + private $id; + + /** + * @var string|null A name + */ + #[ApiProperty(iris: ['RelatedDummy.name'])] + #[Groups(['friends'])] + public $name; + + #[ApiProperty(deprecationReason: 'This property is deprecated for upgrade test')] + #[Groups(['barcelona', 'chicago', 'friends'])] + protected $symfony = 'symfony'; + + /** + * @var \DateTime|null A dummy date + */ + #[Groups(['friends'])] + public $dummyDate; + + /** + * @var bool|null A dummy bool + */ + #[Groups(['friends'])] + public ?bool $dummyBoolean = null; + + public function __construct() + { + } + + public function getId() + { + return $this->id; + } + + public function setId($id): void + { + $this->id = $id; + } + + public function setName($name): void + { + $this->name = $name; + } + + public function getName() + { + return $this->name; + } + + public function getSymfony() + { + return $this->symfony; + } + + public function setSymfony($symfony): void + { + $this->symfony = $symfony; + } + + public function setDummyDate(\DateTime $dummyDate): void + { + $this->dummyDate = $dummyDate; + } + + public function getDummyDate() + { + return $this->dummyDate; + } + + public function isDummyBoolean(): ?bool + { + return $this->dummyBoolean; + } + + /** + * @param bool $dummyBoolean + */ + public function setDummyBoolean($dummyBoolean): void + { + $this->dummyBoolean = $dummyBoolean; + } + + public function __toString(): string + { + return (string) $this->getId(); + } +} diff --git a/tests/JsonApi/JsonSchema/SchemaFactoryTest.php b/src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php similarity index 95% rename from tests/JsonApi/JsonSchema/SchemaFactoryTest.php rename to src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php index fa049800147..0c2548a7e07 100644 --- a/tests/JsonApi/JsonSchema/SchemaFactoryTest.php +++ b/src/JsonApi/Tests/JsonSchema/SchemaFactoryTest.php @@ -13,9 +13,8 @@ namespace ApiPlatform\Tests\JsonApi\JsonSchema; -use ApiPlatform\Hal\JsonSchema\SchemaFactory as HalSchemaFactory; -use ApiPlatform\Hydra\JsonSchema\SchemaFactory as HydraSchemaFactory; use ApiPlatform\JsonApi\JsonSchema\SchemaFactory; +use ApiPlatform\JsonApi\Tests\Fixtures\Dummy; use ApiPlatform\JsonSchema\DefinitionNameFactory; use ApiPlatform\JsonSchema\Schema; use ApiPlatform\JsonSchema\SchemaFactory as BaseSchemaFactory; @@ -29,7 +28,6 @@ use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; use ApiPlatform\Metadata\ResourceClassResolverInterface; -use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; @@ -62,13 +60,10 @@ protected function setUp(): void definitionNameFactory: $definitionNameFactory, ); - $halSchemaFactory = new HalSchemaFactory($baseSchemaFactory); - $hydraSchemaFactory = new HydraSchemaFactory($halSchemaFactory); - $resourceClassResolver = $this->prophesize(ResourceClassResolverInterface::class); $this->schemaFactory = new SchemaFactory( - schemaFactory: $hydraSchemaFactory, + schemaFactory: $baseSchemaFactory, propertyMetadataFactory: $propertyMetadataFactory->reveal(), resourceClassResolver: $resourceClassResolver->reveal(), resourceMetadataFactory: $resourceMetadataFactory->reveal(), diff --git a/tests/JsonApi/Serializer/CollectionNormalizerTest.php b/src/JsonApi/Tests/Serializer/CollectionNormalizerTest.php similarity index 99% rename from tests/JsonApi/Serializer/CollectionNormalizerTest.php rename to src/JsonApi/Tests/Serializer/CollectionNormalizerTest.php index 53adf6dadea..f165af89c9a 100644 --- a/tests/JsonApi/Serializer/CollectionNormalizerTest.php +++ b/src/JsonApi/Tests/Serializer/CollectionNormalizerTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\JsonApi\Serializer; +namespace ApiPlatform\JsonApi\Tests\Serializer; use ApiPlatform\Api\ResourceClassResolverInterface; use ApiPlatform\JsonApi\Serializer\CollectionNormalizer; diff --git a/tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php b/src/JsonApi/Tests/Serializer/ConstraintViolationNormalizerTest.php similarity index 91% rename from tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php rename to src/JsonApi/Tests/Serializer/ConstraintViolationNormalizerTest.php index 3c38247aefc..f5873210c91 100644 --- a/tests/JsonApi/Serializer/ConstraintViolationNormalizerTest.php +++ b/src/JsonApi/Tests/Serializer/ConstraintViolationNormalizerTest.php @@ -11,18 +11,17 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\JsonApi\Serializer; +namespace ApiPlatform\JsonApi\Tests\Serializer; use ApiPlatform\JsonApi\Serializer\ConstraintViolationListNormalizer; +use ApiPlatform\JsonApi\Tests\Fixtures\Dummy; +use ApiPlatform\JsonApi\Tests\Fixtures\RelatedDummy; use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; -use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; -use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\PropertyInfo\Type; use Symfony\Component\Serializer\NameConverter\NameConverterInterface; -use Symfony\Component\Serializer\Serializer; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\ConstraintViolationListInterface; @@ -34,9 +33,6 @@ class ConstraintViolationNormalizerTest extends TestCase { use ProphecyTrait; - /** - * @group legacy - */ public function testSupportNormalization(): void { $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class); @@ -49,10 +45,6 @@ public function testSupportNormalization(): void $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), ConstraintViolationListNormalizer::FORMAT)); $this->assertEmpty($normalizer->getSupportedTypes('json')); $this->assertSame([ConstraintViolationListInterface::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); - - if (!method_exists(Serializer::class, 'getSupportedTypes')) { - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); - } } public function testNormalize(): void diff --git a/tests/JsonApi/Serializer/EntrypointNormalizerTest.php b/src/JsonApi/Tests/Serializer/EntrypointNormalizerTest.php similarity index 90% rename from tests/JsonApi/Serializer/EntrypointNormalizerTest.php rename to src/JsonApi/Tests/Serializer/EntrypointNormalizerTest.php index eb035c848cc..23432530ed7 100644 --- a/tests/JsonApi/Serializer/EntrypointNormalizerTest.php +++ b/src/JsonApi/Tests/Serializer/EntrypointNormalizerTest.php @@ -11,10 +11,9 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\JsonApi\Serializer; +namespace ApiPlatform\JsonApi\Tests\Serializer; -use ApiPlatform\Api\Entrypoint; -use ApiPlatform\Documentation\Entrypoint as DocumentationEntrypoint; +use ApiPlatform\Documentation\Entrypoint; use ApiPlatform\JsonApi\Serializer\EntrypointNormalizer; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; @@ -33,7 +32,6 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use Symfony\Component\Serializer\Serializer; /** * @author Amrouche Hamza @@ -42,9 +40,6 @@ class EntrypointNormalizerTest extends TestCase { use ProphecyTrait; - /** - * @group legacy - */ public function testSupportNormalization(): void { $collection = new ResourceNameCollection(); @@ -60,11 +55,7 @@ public function testSupportNormalization(): void $this->assertFalse($normalizer->supportsNormalization($entrypoint, 'json')); $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), EntrypointNormalizer::FORMAT)); $this->assertEmpty($normalizer->getSupportedTypes('json')); - $this->assertSame([Entrypoint::class => true, DocumentationEntrypoint::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); - - if (!method_exists(Serializer::class, 'getSupportedTypes')) { - $this->assertTrue($normalizer->hasCacheableSupportsMethod()); - } + $this->assertSame([Entrypoint::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT)); } public function testNormalize(): void diff --git a/tests/JsonApi/Serializer/ItemNormalizerTest.php b/src/JsonApi/Tests/Serializer/ItemNormalizerTest.php similarity index 99% rename from tests/JsonApi/Serializer/ItemNormalizerTest.php rename to src/JsonApi/Tests/Serializer/ItemNormalizerTest.php index e8e40f06c04..9065dfdba26 100644 --- a/tests/JsonApi/Serializer/ItemNormalizerTest.php +++ b/src/JsonApi/Tests/Serializer/ItemNormalizerTest.php @@ -11,10 +11,13 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\JsonApi\Serializer; +namespace ApiPlatform\JsonApi\Tests\Serializer; use ApiPlatform\JsonApi\Serializer\ItemNormalizer; use ApiPlatform\JsonApi\Serializer\ReservedAttributeNameConverter; +use ApiPlatform\JsonApi\Tests\Fixtures\CircularReference; +use ApiPlatform\JsonApi\Tests\Fixtures\Dummy; +use ApiPlatform\JsonApi\Tests\Fixtures\RelatedDummy; use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; @@ -26,9 +29,6 @@ use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use ApiPlatform\Metadata\Resource\ResourceMetadataCollection; use ApiPlatform\Metadata\ResourceClassResolverInterface; -use ApiPlatform\Tests\Fixtures\TestBundle\Entity\CircularReference; -use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; -use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy; use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; use Prophecy\Argument; diff --git a/tests/JsonApi/Serializer/ReservedAttributeNameConverterTest.php b/src/JsonApi/Tests/Serializer/ReservedAttributeNameConverterTest.php similarity index 86% rename from tests/JsonApi/Serializer/ReservedAttributeNameConverterTest.php rename to src/JsonApi/Tests/Serializer/ReservedAttributeNameConverterTest.php index fbcd0368a94..7c261af1cc7 100644 --- a/tests/JsonApi/Serializer/ReservedAttributeNameConverterTest.php +++ b/src/JsonApi/Tests/Serializer/ReservedAttributeNameConverterTest.php @@ -11,10 +11,10 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\JsonApi\Serializer; +namespace ApiPlatform\JsonApi\Tests\Serializer; use ApiPlatform\JsonApi\Serializer\ReservedAttributeNameConverter; -use ApiPlatform\Tests\Fixtures\TestBundle\Serializer\NameConverter\CustomConverter; +use ApiPlatform\JsonApi\Tests\Fixtures\CustomConverter; use PHPUnit\Framework\TestCase; /** @@ -46,17 +46,13 @@ public static function propertiesProvider(): array ]; } - /** - * @dataProvider propertiesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('propertiesProvider')] public function testNormalize(string $propertyName, string $expectedPropertyName): void { $this->assertSame($expectedPropertyName, $this->reservedAttributeNameConverter->normalize($propertyName)); } - /** - * @dataProvider propertiesProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('propertiesProvider')] public function testDenormalize(string $expectedPropertyName, string $propertyName): void { $this->assertSame($expectedPropertyName, $this->reservedAttributeNameConverter->denormalize($propertyName)); diff --git a/tests/JsonApi/State/JsonApiProviderTest.php b/src/JsonApi/Tests/State/JsonApiProviderTest.php similarity index 83% rename from tests/JsonApi/State/JsonApiProviderTest.php rename to src/JsonApi/Tests/State/JsonApiProviderTest.php index 30e9106e584..180c5d5b89c 100644 --- a/tests/JsonApi/State/JsonApiProviderTest.php +++ b/src/JsonApi/Tests/State/JsonApiProviderTest.php @@ -11,12 +11,13 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\JsonApi\State; +namespace ApiPlatform\JsonApi\Tests\State; use ApiPlatform\JsonApi\State\JsonApiProvider; use ApiPlatform\Metadata\Get; use ApiPlatform\State\ProviderInterface; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; @@ -29,8 +30,7 @@ public function testProvide(): void $request->attributes = $this->createMock(ParameterBag::class); $request->attributes->expects($this->once())->method('get')->with('_api_filters', [])->willReturn([]); $request->attributes->method('set')->with($this->logicalOr('_api_filter_property', '_api_included', '_api_filters'), $this->logicalOr(['id', 'name', 'dummyFloat', 'relatedDummy' => ['id', 'name']], ['relatedDummy'], [])); - $request->query = $this->createMock(ParameterBag::class); // @phpstan-ignore-line - $request->query->method('all')->willReturn(['fields' => ['dummy' => 'id,name,dummyFloat', 'relatedDummy' => 'id,name'], 'include' => 'relatedDummy,foo']); + $request->query = new InputBag(['fields' => ['dummy' => 'id,name,dummyFloat', 'relatedDummy' => 'id,name'], 'include' => 'relatedDummy,foo']); $operation = new Get(class: 'dummy', shortName: 'dummy'); $context = ['request' => $request]; $decorated = $this->createMock(ProviderInterface::class); diff --git a/src/JsonApi/composer.json b/src/JsonApi/composer.json new file mode 100644 index 00000000000..62536cc88d3 --- /dev/null +++ b/src/JsonApi/composer.json @@ -0,0 +1,74 @@ +{ + "name": "api-platform/json-api", + "description": "API JSON-API support", + "type": "library", + "keywords": [ + "REST", + "GraphQL", + "API", + "JSON-LD", + "Hydra", + "JSONAPI", + "OpenAPI", + "HAL", + "Swagger" + ], + "homepage": "https://api-platform.com", + "license": "MIT", + "authors": [ + { + "name": "Kévin Dunglas", + "email": "kevin@dunglas.fr", + "homepage": "https://dunglas.fr" + }, + { + "name": "API Platform Community", + "homepage": "https://api-platform.com/community/contributors" + } + ], + "require": { + "php": ">=8.1", + "api-platform/documentation": "^3.2 || ^4.0", + "api-platform/json-schema": "^3.2 || ^4.0", + "api-platform/metadata": "^3.2 || ^4.0", + "api-platform/serializer": "^3.2 || ^4.0", + "api-platform/state": "^3.2 || ^4.0", + "symfony/error-handler": "^6.4 || ^7.1", + "symfony/http-foundation": "^6.4 || ^7.1" + }, + "require-dev": { + "phpspec/prophecy": "^1.19", + "phpspec/prophecy-phpunit": "^2.2", + "phpunit/phpunit": "^11.2" + }, + "autoload": { + "psr-4": { + "ApiPlatform\\JsonApi\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "config": { + "preferred-install": { + "*": "dist" + }, + "sort-packages": true, + "allow-plugins": { + "composer/package-versions-deprecated": true, + "phpstan/extension-installer": true + } + }, + "extra": { + "branch-alias": { + "dev-main": "4.0.x-dev", + "dev-3.4": "3.4.x-dev" + }, + "symfony": { + "require": "^6.1" + } + }, + "scripts": { + "test": "./vendor/bin/phpunit" + } +} diff --git a/src/JsonApi/phpunit.xml.dist b/src/JsonApi/phpunit.xml.dist new file mode 100644 index 00000000000..5c65d384cc4 --- /dev/null +++ b/src/JsonApi/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + + + + ./Tests/ + + + + + + ./ + + + ./Tests + ./vendor + + + diff --git a/src/JsonLd/composer.json b/src/JsonLd/composer.json index aaff7f1ae26..025468d5aeb 100644 --- a/src/JsonLd/composer.json +++ b/src/JsonLd/composer.json @@ -28,9 +28,9 @@ ], "require": { "php": ">=8.1", - "api-platform/state": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/serializer": "*@dev || ^3.1" + "api-platform/state": "^3.1", + "api-platform/metadata": "^3.1", + "api-platform/serializer": "^3.1" }, "autoload": { "psr-4": { @@ -62,4 +62,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/JsonSchema/composer.json b/src/JsonSchema/composer.json index ac440fa00e7..6a61f9344df 100644 --- a/src/JsonSchema/composer.json +++ b/src/JsonSchema/composer.json @@ -25,7 +25,7 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", "symfony/console": "^6.4 || ^7.0", "symfony/property-info": "^6.4 || ^7.1", "symfony/serializer": "^6.4 || ^7.1", @@ -66,4 +66,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/tests/Util/ClassInfoTraitTest.php b/src/Metadata/Tests/Util/ClassInfoTraitTest.php similarity index 97% rename from tests/Util/ClassInfoTraitTest.php rename to src/Metadata/Tests/Util/ClassInfoTraitTest.php index 355c7e4014d..541f1e578ff 100644 --- a/tests/Util/ClassInfoTraitTest.php +++ b/src/Metadata/Tests/Util/ClassInfoTraitTest.php @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Util; +namespace ApiPlatform\Metadata\Tests\Util; use ApiPlatform\Metadata\Util\ClassInfoTrait; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; diff --git a/tests/Util/CloneTraitTest.php b/src/Metadata/Tests/Util/CloneTraitTest.php similarity index 91% rename from tests/Util/CloneTraitTest.php rename to src/Metadata/Tests/Util/CloneTraitTest.php index a2b94492f9d..b482679adc0 100644 --- a/tests/Util/CloneTraitTest.php +++ b/src/Metadata/Tests/Util/CloneTraitTest.php @@ -11,9 +11,9 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Util; +namespace ApiPlatform\Metadata\Tests\Util; -use ApiPlatform\Util\CloneTrait; +use ApiPlatform\Metadata\Util\CloneTrait; use PHPUnit\Framework\TestCase; /** diff --git a/tests/Util/IriHelperTest.php b/src/Metadata/Tests/Util/IriHelperTest.php similarity index 92% rename from tests/Util/IriHelperTest.php rename to src/Metadata/Tests/Util/IriHelperTest.php index dea52781b6d..a923233d9c8 100644 --- a/tests/Util/IriHelperTest.php +++ b/src/Metadata/Tests/Util/IriHelperTest.php @@ -11,11 +11,11 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Util; +namespace ApiPlatform\Metadata\Tests\Util; -use ApiPlatform\Api\UrlGeneratorInterface; -use ApiPlatform\Exception\InvalidArgumentException; -use ApiPlatform\Util\IriHelper; +use ApiPlatform\Metadata\Exception\InvalidArgumentException; +use ApiPlatform\Metadata\UrlGeneratorInterface; +use ApiPlatform\Metadata\Util\IriHelper; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; diff --git a/tests/Util/ReflectionTest.php b/src/Metadata/Tests/Util/ReflectionTest.php similarity index 91% rename from tests/Util/ReflectionTest.php rename to src/Metadata/Tests/Util/ReflectionTest.php index cae7a2aa172..31c25f56b1d 100644 --- a/tests/Util/ReflectionTest.php +++ b/src/Metadata/Tests/Util/ReflectionTest.php @@ -11,9 +11,9 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Util; +namespace ApiPlatform\Metadata\Tests\Util; -use ApiPlatform\Util\Reflection; +use ApiPlatform\Metadata\Util\Reflection; use PHPUnit\Framework\TestCase; /** diff --git a/tests/Util/SortTraitTest.php b/src/Metadata/Tests/Util/SortTraitTest.php similarity index 92% rename from tests/Util/SortTraitTest.php rename to src/Metadata/Tests/Util/SortTraitTest.php index f1fbc7eeea4..b20265d9bfb 100644 --- a/tests/Util/SortTraitTest.php +++ b/src/Metadata/Tests/Util/SortTraitTest.php @@ -11,9 +11,9 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Util; +namespace ApiPlatform\Metadata\Tests\Util; -use ApiPlatform\Util\SortTrait; +use ApiPlatform\Metadata\Util\SortTrait; use PHPUnit\Framework\TestCase; /** diff --git a/src/Metadata/UriVariableTransformer/DateTimeUriVariableTransformer.php b/src/Metadata/UriVariableTransformer/DateTimeUriVariableTransformer.php new file mode 100644 index 00000000000..591badd693a --- /dev/null +++ b/src/Metadata/UriVariableTransformer/DateTimeUriVariableTransformer.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Metadata\UriVariableTransformer; + +use ApiPlatform\Metadata\Exception\InvalidUriVariableException; +use ApiPlatform\Metadata\UriVariableTransformerInterface; +use Symfony\Component\Serializer\Exception\NotNormalizableValueException; +use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; + +final class DateTimeUriVariableTransformer implements UriVariableTransformerInterface +{ + private readonly DateTimeNormalizer $dateTimeNormalizer; + + public function __construct() + { + $this->dateTimeNormalizer = new DateTimeNormalizer(); + } + + public function transform(mixed $value, array $types, array $context = []): \DateTimeInterface + { + try { + return $this->dateTimeNormalizer->denormalize($value, $types[0], null, $context); + } catch (NotNormalizableValueException $e) { + throw new InvalidUriVariableException($e->getMessage(), $e->getCode(), $e); + } + } + + public function supportsTransformation(mixed $value, array $types, array $context = []): bool + { + return $this->dateTimeNormalizer->supportsDenormalization($value, $types[0]); + } +} diff --git a/src/Metadata/UriVariableTransformer/IntegerUriVariableTransformer.php b/src/Metadata/UriVariableTransformer/IntegerUriVariableTransformer.php new file mode 100644 index 00000000000..3821ad6b53f --- /dev/null +++ b/src/Metadata/UriVariableTransformer/IntegerUriVariableTransformer.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Metadata\UriVariableTransformer; + +use ApiPlatform\Metadata\UriVariableTransformerInterface; +use Symfony\Component\PropertyInfo\Type; + +final class IntegerUriVariableTransformer implements UriVariableTransformerInterface +{ + public function transform(mixed $value, array $types, array $context = []): int + { + return (int) $value; + } + + public function supportsTransformation(mixed $value, array $types, array $context = []): bool + { + return Type::BUILTIN_TYPE_INT === $types[0] && \is_string($value); + } +} diff --git a/src/Metadata/UriVariableTransformerInterface.php b/src/Metadata/UriVariableTransformerInterface.php index 8411cb4e8ee..16d88b291e7 100644 --- a/src/Metadata/UriVariableTransformerInterface.php +++ b/src/Metadata/UriVariableTransformerInterface.php @@ -13,40 +13,27 @@ namespace ApiPlatform\Metadata; -use ApiPlatform\Exception\InvalidUriVariableException; +use ApiPlatform\Metadata\Exception\InvalidUriVariableException; -if (class_exists(\ApiPlatform\Api\UriVariableTransformerInterface::class)) { - class_alias( - \ApiPlatform\Api\UriVariableTransformerInterface::class, - __NAMESPACE__.'\UriVariableTransformerInterface' - ); +interface UriVariableTransformerInterface +{ + /** + * Transforms the value of a URI variable (identifier) to its type. + * + * @param mixed $value The URI variable value to transform + * @param array $types The guessed type behind the URI variable + * @param array $context Options available to the transformer + * + * @throws InvalidUriVariableException Occurs when the URI variable could not be transformed + */ + public function transform(mixed $value, array $types, array $context = []); - if (false) { // @phpstan-ignore-line - interface UriVariableTransformerInterface extends \ApiPlatform\Api\UriVariableTransformerInterface - { - } - } -} else { - interface UriVariableTransformerInterface - { - /** - * Transforms the value of a URI variable (identifier) to its type. - * - * @param mixed $value The URI variable value to transform - * @param array $types The guessed type behind the URI variable - * @param array $context Options available to the transformer - * - * @throws InvalidUriVariableException Occurs when the URI variable could not be transformed - */ - public function transform(mixed $value, array $types, array $context = []); - - /** - * Checks whether the value of a URI variable can be transformed to its type by this transformer. - * - * @param mixed $value The URI variable value to transform - * @param array $types The types to which the URI variable value should be transformed - * @param array $context Options available to the transformer - */ - public function supportsTransformation(mixed $value, array $types, array $context = []): bool; - } + /** + * Checks whether the value of a URI variable can be transformed to its type by this transformer. + * + * @param mixed $value The URI variable value to transform + * @param array $types The types to which the URI variable value should be transformed + * @param array $context Options available to the transformer + */ + public function supportsTransformation(mixed $value, array $types, array $context = []): bool; } diff --git a/src/Metadata/composer.json b/src/Metadata/composer.json index f95d06c2dc5..95f2e7d2c4d 100644 --- a/src/Metadata/composer.json +++ b/src/Metadata/composer.json @@ -35,9 +35,9 @@ "symfony/string": "^6.4 || ^7.0" }, "require-dev": { - "api-platform/json-schema": "*@dev || ^3.1", - "api-platform/openapi": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/json-schema": "^3.1", + "api-platform/openapi": "^3.1", + "api-platform/state": "^3.1", "phpspec/prophecy-phpunit": "^2.0", "phpstan/phpdoc-parser": "^1.16", "sebastian/comparator": "<5.0", @@ -83,4 +83,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/OpenApi/composer.json b/src/OpenApi/composer.json index c4ea86bbfa2..ef7ebdba27d 100644 --- a/src/OpenApi/composer.json +++ b/src/OpenApi/composer.json @@ -28,9 +28,9 @@ ], "require": { "php": ">=8.1", - "api-platform/json-schema": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/json-schema": "^3.1", + "api-platform/metadata": "^3.1", + "api-platform/state": "^3.1", "symfony/console": "^6.4 || ^7.0", "symfony/property-access": "^6.4 || ^7.1", "symfony/serializer": "^6.4 || ^7.1" @@ -38,9 +38,9 @@ "require-dev": { "phpspec/prophecy-phpunit": "^2.0", "symfony/phpunit-bridge": "^6.4 || ^7.0", - "api-platform/doctrine-common": "*@dev || ^3.2", - "api-platform/doctrine-orm": "*@dev || ^3.2", - "api-platform/doctrine-odm": "*@dev || ^3.2", + "api-platform/doctrine-common": "^3.2", + "api-platform/doctrine-orm": "^3.2", + "api-platform/doctrine-odm": "^3.2", "sebastian/comparator": "<5.0" }, "autoload": { @@ -76,4 +76,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/ParameterValidator/composer.json b/src/ParameterValidator/composer.json index 2d562c3b9c9..cc8b47a0f1e 100644 --- a/src/ParameterValidator/composer.json +++ b/src/ParameterValidator/composer.json @@ -28,8 +28,8 @@ ], "require": { "php": ">=8.1", - "api-platform/state": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", + "api-platform/state": "^3.1", + "api-platform/metadata": "^3.1", "psr/container": "^1.0 || ^2.0", "symfony/deprecation-contracts": "^3.1" }, diff --git a/src/RamseyUuid/composer.json b/src/RamseyUuid/composer.json index 3e68f88856f..f8a73410e46 100644 --- a/src/RamseyUuid/composer.json +++ b/src/RamseyUuid/composer.json @@ -21,7 +21,7 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", "symfony/serializer": "^6.4 || ^7.1" }, "require-dev": { @@ -58,4 +58,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/Serializer/composer.json b/src/Serializer/composer.json index 88b8bd419c0..418f643acfb 100644 --- a/src/Serializer/composer.json +++ b/src/Serializer/composer.json @@ -21,8 +21,8 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", + "api-platform/state": "^3.1", "doctrine/collections": "^2.1", "symfony/property-access": "^6.4 || ^7.1", "symfony/property-info": "^6.4 || ^7.1", @@ -36,9 +36,9 @@ "symfony/phpunit-bridge": "^6.4 || ^7.0", "symfony/var-dumper": "^6.4 || ^7.0", "symfony/yaml": "^6.4 || ^7.0", - "api-platform/doctrine-odm": "*@dev || ^3.2", - "api-platform/doctrine-orm": "*@dev || ^3.2", - "api-platform/doctrine-common": "*@dev || ^3.2" + "api-platform/doctrine-odm": "^3.2", + "api-platform/doctrine-orm": "^3.2", + "api-platform/doctrine-common": "^3.2" }, "autoload": { "psr-4": { @@ -70,4 +70,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/tests/Util/RequestAttributesExtractorTest.php b/src/State/Tests/Util/RequestAttributesExtractorTest.php similarity index 98% rename from tests/Util/RequestAttributesExtractorTest.php rename to src/State/Tests/Util/RequestAttributesExtractorTest.php index 7d0ba781f2f..93ed96ef4b9 100644 --- a/tests/Util/RequestAttributesExtractorTest.php +++ b/src/State/Tests/Util/RequestAttributesExtractorTest.php @@ -11,9 +11,9 @@ declare(strict_types=1); -namespace ApiPlatform\Tests\Util; +namespace ApiPlatform\State\Tests\Util; -use ApiPlatform\Util\RequestAttributesExtractor; +use ApiPlatform\State\Util\RequestAttributesExtractor; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; diff --git a/src/State/composer.json b/src/State/composer.json index aa18b095189..cec364c2db0 100644 --- a/src/State/composer.json +++ b/src/State/composer.json @@ -28,7 +28,7 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", "psr/container": "^1.0 || ^2.0" }, "require-dev": { @@ -36,8 +36,8 @@ "symfony/web-link": "^6.4 || ^7.0", "symfony/http-foundation": "^6.4 || 7.0", "willdurand/negotiation": "^3.1", - "api-platform/validator": "*@dev || ^3.1", - "api-platform/serializer": "*@dev || ^3.1" + "api-platform/validator": "^3.1", + "api-platform/serializer": "^3.1" }, "autoload": { "psr-4": { @@ -76,4 +76,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/Symfony/Bundle/DataCollector/RequestDataCollector.php b/src/Symfony/Bundle/DataCollector/RequestDataCollector.php index cd347421171..ddde1871a0e 100644 --- a/src/Symfony/Bundle/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Bundle/DataCollector/RequestDataCollector.php @@ -15,7 +15,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; -use ApiPlatform\Util\RequestAttributesExtractor; +use ApiPlatform\State\Util\RequestAttributesExtractor; use PackageVersions\Versions; use Psr\Container\ContainerInterface; use Symfony\Component\HttpFoundation\Request; diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index 1d6374f9b12..6a1146abfef 100644 --- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -14,6 +14,7 @@ namespace ApiPlatform\Symfony\Bundle\DependencyInjection; use ApiPlatform\Api\FilterInterface as LegacyFilterInterface; +use ApiPlatform\Api\QueryParameterValidator\QueryParameterValidator; use ApiPlatform\Doctrine\Odm\Extension\AggregationCollectionExtensionInterface; use ApiPlatform\Doctrine\Odm\Extension\AggregationItemExtensionInterface; use ApiPlatform\Doctrine\Odm\Filter\AbstractFilter as DoctrineMongoDbOdmAbstractFilter; @@ -863,6 +864,11 @@ private function registerValidatorConfiguration(ContainerBuilder $container, arr $container->setParameter('api_platform.validator.serialize_payload_fields', $config['validator']['serialize_payload_fields']); $container->setParameter('api_platform.validator.query_parameter_validation', $config['validator']['query_parameter_validation']); + if (class_exists(QueryParameterValidator::class)) { + $loader->load('legacy/parameter_validator/parameter_validator.xml'); + $loader->load($config['use_symfony_listeners'] ? 'legacy/parameter_validator/events.xml' : 'legacy/parameter_validator/state.xml'); + } + if (!$config['validator']['query_parameter_validation']) { $container->removeDefinition('api_platform.listener.view.validate_query_parameters'); $container->removeDefinition('api_platform.validator.query_parameter_validator'); diff --git a/src/Symfony/Bundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DependencyInjection/Configuration.php index fb1bbd01176..9885769e6c9 100644 --- a/src/Symfony/Bundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/DependencyInjection/Configuration.php @@ -461,7 +461,7 @@ private function addElasticsearchSection(ArrayNodeDefinition $rootNode): void ->prototype('array') ->children() ->scalarNode('index')->defaultNull()->end() - ->scalarNode('type')->defaultValue(DocumentMetadata::DEFAULT_TYPE)->end() + ->scalarNode('type')->defaultValue(class_exists(DocumentMetadata::class) ? DocumentMetadata::DEFAULT_TYPE : '_doc')->end() ->end() ->end() ->end() diff --git a/src/Symfony/Bundle/Resources/config/api.xml b/src/Symfony/Bundle/Resources/config/api.xml index 711906794e2..6f8f94d5075 100644 --- a/src/Symfony/Bundle/Resources/config/api.xml +++ b/src/Symfony/Bundle/Resources/config/api.xml @@ -151,17 +151,17 @@ - + - + - + diff --git a/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/events.xml b/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/events.xml new file mode 100644 index 00000000000..c2cdaa128cf --- /dev/null +++ b/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/events.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/parameter_validator.xml b/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/parameter_validator.xml new file mode 100644 index 00000000000..89ea18cfabc --- /dev/null +++ b/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/parameter_validator.xml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/state.xml b/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/state.xml new file mode 100644 index 00000000000..7fd2a0249f6 --- /dev/null +++ b/src/Symfony/Bundle/Resources/config/legacy/parameter_validator/state.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/Resources/config/legacy/validator.xml b/src/Symfony/Bundle/Resources/config/legacy/validator.xml index 756bc46aa84..59146689db7 100644 --- a/src/Symfony/Bundle/Resources/config/legacy/validator.xml +++ b/src/Symfony/Bundle/Resources/config/legacy/validator.xml @@ -10,12 +10,5 @@ - - - - %api_platform.validator.query_parameter_validation% - - - diff --git a/src/Symfony/Bundle/Resources/config/validator/events.xml b/src/Symfony/Bundle/Resources/config/validator/events.xml index 88754e06529..ccb4ed59eaf 100644 --- a/src/Symfony/Bundle/Resources/config/validator/events.xml +++ b/src/Symfony/Bundle/Resources/config/validator/events.xml @@ -22,16 +22,9 @@ - - null - - - - %api_platform.validator.query_parameter_validation% - diff --git a/src/Symfony/Bundle/Resources/config/validator/state.xml b/src/Symfony/Bundle/Resources/config/validator/state.xml index 35ae7eb938b..77e5b7db1a5 100644 --- a/src/Symfony/Bundle/Resources/config/validator/state.xml +++ b/src/Symfony/Bundle/Resources/config/validator/state.xml @@ -5,11 +5,6 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - - - - - diff --git a/src/Symfony/Bundle/Resources/config/validator/validator.xml b/src/Symfony/Bundle/Resources/config/validator/validator.xml index 8946534fa5d..2c0afa30b7d 100644 --- a/src/Symfony/Bundle/Resources/config/validator/validator.xml +++ b/src/Symfony/Bundle/Resources/config/validator/validator.xml @@ -12,10 +12,6 @@ - - - - diff --git a/src/Symfony/Bundle/Test/Client.php b/src/Symfony/Bundle/Test/Client.php index 6ce270a3dff..426c80ab055 100644 --- a/src/Symfony/Bundle/Test/Client.php +++ b/src/Symfony/Bundle/Test/Client.php @@ -13,7 +13,6 @@ namespace ApiPlatform\Symfony\Bundle\Test; -use ApiPlatform\Util\ClientTrait; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/src/Symfony/Controller/MainController.php b/src/Symfony/Controller/MainController.php index b75d549b2db..e41f2c41848 100644 --- a/src/Symfony/Controller/MainController.php +++ b/src/Symfony/Controller/MainController.php @@ -13,13 +13,13 @@ namespace ApiPlatform\Symfony\Controller; -use ApiPlatform\Api\UriVariablesConverterInterface; use ApiPlatform\Exception\InvalidIdentifierException; use ApiPlatform\Exception\InvalidUriVariableException; use ApiPlatform\Metadata\Error; use ApiPlatform\Metadata\Exception\RuntimeException; use ApiPlatform\Metadata\HttpOperation; use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; +use ApiPlatform\Metadata\UriVariablesConverterInterface; use ApiPlatform\State\ProcessorInterface; use ApiPlatform\State\ProviderInterface; use ApiPlatform\State\UriVariablesResolverTrait; diff --git a/src/Symfony/EventListener/ExceptionListener.php b/src/Symfony/EventListener/ExceptionListener.php index 7aa50a5a995..d0b8b034d42 100644 --- a/src/Symfony/EventListener/ExceptionListener.php +++ b/src/Symfony/EventListener/ExceptionListener.php @@ -14,7 +14,7 @@ namespace ApiPlatform\Symfony\EventListener; use ApiPlatform\Metadata\Error; -use ApiPlatform\Util\RequestAttributesExtractor; +use ApiPlatform\State\Util\RequestAttributesExtractor; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\EventListener\ErrorListener; diff --git a/src/Symfony/EventListener/SerializeListener.php b/src/Symfony/EventListener/SerializeListener.php index af50bfd3699..7383183617c 100644 --- a/src/Symfony/EventListener/SerializeListener.php +++ b/src/Symfony/EventListener/SerializeListener.php @@ -142,7 +142,7 @@ public function onKernelView(ViewEvent $event): void return; } - if ($controllerResult instanceof ValidationException) { + if ($controllerResult instanceof ValidationException && class_exists(ErrorFormatGuesser::class)) { $format = ErrorFormatGuesser::guessErrorFormat($request, $this->errorFormats); $previousOperation = $request->attributes->get('_api_previous_operation'); if (!($previousOperation?->getExtraProperties()['rfc_7807_compliant_errors'] ?? false)) { diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index 41ba8c171c1..2df15f2b5b0 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -20,19 +20,18 @@ ], "require": { "php": ">=8.1", - "api-platform/documentation": "*@dev || ^3.1", - "api-platform/doctrine-common": "*@dev || ^3.1", - "api-platform/elasticsearch": "*@dev || ^3.1", - "api-platform/graphql": "*@dev || ^3.1", - "api-platform/http-cache": "*@dev || ^3.1", - "api-platform/json-schema": "*@dev || ^3.1", - "api-platform/jsonld": "*@dev || ^3.1", - "api-platform/hydra": "*@dev || ^3.1", - "api-platform/metadata": "*@dev || ^3.1", - "api-platform/serializer": "*@dev || ^3.1", - "api-platform/state": "*@dev || ^3.1", - "api-platform/validator": "*@dev || ^3.1", - "api-platform/openapi": "*@dev || ^3.1", + "api-platform/documentation": "^3.1", + "api-platform/doctrine-common": "^3.1", + "api-platform/graphql": "^3.1", + "api-platform/http-cache": "^3.1", + "api-platform/json-schema": "^3.1", + "api-platform/jsonld": "^3.1", + "api-platform/hydra": "^3.1", + "api-platform/metadata": "^3.1", + "api-platform/serializer": "^3.1", + "api-platform/state": "^3.1", + "api-platform/validator": "^3.1", + "api-platform/openapi": "^3.1", "symfony/property-info": "^6.4 || ^7.1", "symfony/property-access": "^6.4 || ^7.1", "symfony/serializer": "^6.4 || ^7.1", @@ -46,10 +45,30 @@ "symfony/mercure-bundle": "*", "webonyx/graphql-php": "^14.0 || ^15.0", "sebastian/comparator": "<5.0", - "api-platform/doctrine-common": "*@dev || ^3.2", - "api-platform/doctrine-orm": "*@dev || ^3.2", - "api-platform/doctrine-odm": "*@dev || ^3.2", - "api-platform/parameter-validator": "*@dev || ^3.1" + "api-platform/doctrine-common": "^3.2", + "api-platform/elasticsearch": "^3.1", + "api-platform/doctrine-orm": "^3.2", + "api-platform/doctrine-odm": "^3.2", + "api-platform/parameter-validator": "^3.1" + }, + "suggest": { + "api-platform/doctrine-orm": "To support Doctrine ORM.", + "api-platform/doctrine-odm": "To support MongoDB. Only versions 4.0 and later are supported.", + "api-platform/elasticsearch": "To support Elasticsearch.", + "ocramius/package-versions": "To display the API Platform's version in the debug bar.", + "phpstan/phpdoc-parser": "To support extracting metadata from PHPDoc.", + "psr/cache-implementation": "To use metadata caching.", + "ramsey/uuid": "To support Ramsey's UUID identifiers.", + "symfony/cache": "To have metadata caching when using Symfony integration.", + "symfony/config": "To load XML configuration files.", + "symfony/expression-language": "To use authorization features.", + "symfony/http-client": "To use the HTTP cache invalidation system.", + "symfony/security": "To use authorization features.", + "symfony/twig-bundle": "To use the Swagger UI integration.", + "symfony/uid": "To support Symfony UUID/ULID identifiers.", + "symfony/messenger": "To support messenger integration.", + "symfony/web-profiler-bundle": "To use the data collector.", + "webonyx/graphql-php": "To support GraphQL." }, "autoload": { "psr-4": { @@ -82,4 +101,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/src/Validator/composer.json b/src/Validator/composer.json index 150fbf013ba..26b9d17acf3 100644 --- a/src/Validator/composer.json +++ b/src/Validator/composer.json @@ -21,7 +21,7 @@ ], "require": { "php": ">=8.1", - "api-platform/metadata": "*@dev || ^3.1", + "api-platform/metadata": "^3.1", "symfony/web-link": "^6.4 || ^7.1" }, "require-dev": { @@ -59,4 +59,4 @@ "scripts": { "test": "./vendor/bin/phpunit" } -} \ No newline at end of file +} diff --git a/tests/.ignored-deprecations b/tests/.ignored-deprecations index 457d7266fbf..960c69a2c94 100644 --- a/tests/.ignored-deprecations +++ b/tests/.ignored-deprecations @@ -28,3 +28,4 @@ %Since api-platform/core 3.4: The "allowEmptyValue" option should be declared using an "openapi" parameter.% %Since api-platform/core 3.4: Injecting the "ApiPlatform\\JsonSchema\\TypeFactoryInterface" inside "ApiPlatform\\JsonSchema\\SchemaFactory" is deprecated and "ApiPlatform\\JsonSchema\\TypeFactoryInterface" will be removed in 4.x.% %Since api-platform/core 3.4: Injecting the "ApiPlatform\\JsonSchema\\TypeFactoryInterface" inside "ApiPlatform\\OpenApi\\Factory\\OpenApiFactory" is deprecated and "ApiPlatform\\JsonSchema\\TypeFactoryInterface" will be removed in 4.x.% +%Since api-platform/core 3.3: Use a "ApiPlatform\\State\\ProviderInterface" as first argument in "ApiPlatform\\Symfony\\EventListener\\QueryParameterValidateListener" instead of "ApiPlatform\\ParameterValidator\\ParameterValidator".% diff --git a/tests/Fixtures/TestBundle/Action/ConfigCustom.php b/tests/Fixtures/TestBundle/Action/ConfigCustom.php index d0666149a82..b028383246e 100644 --- a/tests/Fixtures/TestBundle/Action/ConfigCustom.php +++ b/tests/Fixtures/TestBundle/Action/ConfigCustom.php @@ -15,7 +15,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\State\ProviderInterface; -use ApiPlatform\Util\RequestAttributesExtractor; +use ApiPlatform\State\Util\RequestAttributesExtractor; use Symfony\Component\HttpFoundation\Request; /**