From bade88c80f53b834e995495c4051db7ca462e569 Mon Sep 17 00:00:00 2001 From: Vincent <407859+vincentchalamon@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:01:22 +0200 Subject: [PATCH] fix: fix CS (#144) --- .github/workflows/ci.yml | 53 +++++++++++--------- composer.json | 2 +- features/bootstrap/FeatureContext.php | 2 - src/Exception/MissingFieldHttpException.php | 2 +- src/Exception/UnauthorizedFieldException.php | 2 +- src/Provider/ProviderChain.php | 2 +- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c64c47..4caabce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ concurrency: jobs: tests: - name: Tests PHP ${{ matrix.php }} (Symfony ${{ matrix.symfony }}) + name: Tests PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }} / API Platform ${{ matrix.api-platform }} runs-on: ubuntu-latest strategy: matrix: @@ -30,23 +30,26 @@ jobs: - '8.3' symfony: # Only Symfony supported versions: https://symfony.com/releases - # API Platform 3.* only supports Symfony >= 6.1 - '6.4.*' - - '7.0.*' + - '7.1.*' + api-platform: + - '^3.4' + - '^4.0' include: - # Ensure the bundle is bootable - php: '8.3' - symfony: '6.4.*' - bootable: true - quality: true - - php: '8.3' - symfony: '7.0.*' + symfony: '7.1.*' + api-platform: '^4.0' bootable: true quality: true exclude: - # Symfony 7 requires php 8.2 + # Symfony 7 requires PHP 8.2 + - php: '8.1' + symfony: '7.1.*' + - php: '8.2' + symfony: '7.1.*' + # API Platform 4 requires PHP 8.2 - php: '8.1' - symfony: '7.0.*' + api-platform: '^4.0' fail-fast: false steps: - name: Checkout @@ -67,21 +70,10 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Configure Symfony run: composer config extra.symfony.require "${{ matrix.symfony }}" + - name: Configure API Platform + run: composer require --dev "api-platform/core:${{ matrix.api-platform }}" - name: Update project dependencies run: composer update --no-progress --ansi --prefer-stable --prefer-dist --no-scripts - - name: Bundle is bootable - if: ${{ matrix.bootable && github.event_name == 'push' && github.ref_name == 'main' }} - run: | - composer create-project "symfony/skeleton:${{ matrix.symfony }}" flex - cd flex - composer config extra.symfony.allow-contrib true - composer req --ignore-platform-reqs tilleuls/forgot-password-bundle:dev-${{ github.ref_name }} - - name: Run php-cs-fixer tests - if: matrix.quality - env: - # PHP CS Fixer does not support PHP 8.3 yet - PHP_CS_FIXER_IGNORE_ENV: 1 - run: php-cs-fixer fix --diff --dry-run - name: Run PHPUnit tests run: vendor/bin/simple-phpunit --colors=always --testdox - name: Run Behat tests @@ -92,3 +84,16 @@ jobs: run: | mkdir -p features/app/cache/jmsserializer/doctrine/orm/Proxies features/app/logs vendor/bin/behat -p jmsserializer + - name: Run php-cs-fixer tests + if: matrix.quality + env: + # PHP CS Fixer does not support PHP 8.3 yet + PHP_CS_FIXER_IGNORE_ENV: 1 + run: php-cs-fixer fix --diff --dry-run + - name: Bundle is bootable + if: ${{ matrix.bootable && github.event_name == 'push' && github.ref_name == 'main' }} + run: | + composer create-project "symfony/skeleton:${{ matrix.symfony }}" flex + cd flex + composer config extra.symfony.allow-contrib true + composer req --ignore-platform-reqs tilleuls/forgot-password-bundle:dev-${{ github.ref_name }} diff --git a/composer.json b/composer.json index b610a4b..e2206f1 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ }, "require-dev": { "ext-json": "*", - "api-platform/core": "^3.0", + "api-platform/core": "^3.0 || ^4.0", "behat/behat": "^3.1", "dg/bypass-finals": "^1.1", "doctrine/data-fixtures": "^1.2", diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 6f376e0..6348eb6 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -499,7 +499,6 @@ private function getOpenApiPaths(): array 'required' => true, ], ], - 'parameters' => [], ], '/api/forgot-password/{tokenValue}' => [ 'ref' => 'ForgotPassword', @@ -586,7 +585,6 @@ private function getOpenApiPaths(): array 'required' => true, ], ], - 'parameters' => [], ], ]; diff --git a/src/Exception/MissingFieldHttpException.php b/src/Exception/MissingFieldHttpException.php index fd7d13b..8e37987 100644 --- a/src/Exception/MissingFieldHttpException.php +++ b/src/Exception/MissingFieldHttpException.php @@ -23,6 +23,6 @@ final class MissingFieldHttpException extends HttpException implements JsonHttpE public function __construct($fieldName) { trigger_deprecation('tilleuls/forgot-password-bundle', '1.5', 'Status code will change to "%s" in 2.0.', 422); - parent::__construct(400, sprintf('Parameter "%s" is missing.', $fieldName)); + parent::__construct(400, \sprintf('Parameter "%s" is missing.', $fieldName)); } } diff --git a/src/Exception/UnauthorizedFieldException.php b/src/Exception/UnauthorizedFieldException.php index e4a2895..b582ecf 100644 --- a/src/Exception/UnauthorizedFieldException.php +++ b/src/Exception/UnauthorizedFieldException.php @@ -19,6 +19,6 @@ final class UnauthorizedFieldException extends HttpException implements JsonHttp { public function __construct($propertyName) { - parent::__construct(400, sprintf('The parameter "%s" is not authorized in your configuration.', $propertyName)); + parent::__construct(400, \sprintf('The parameter "%s" is not authorized in your configuration.', $propertyName)); } } diff --git a/src/Provider/ProviderChain.php b/src/Provider/ProviderChain.php index 3a11d61..74d0428 100644 --- a/src/Provider/ProviderChain.php +++ b/src/Provider/ProviderChain.php @@ -37,7 +37,7 @@ public function get(?string $name = null): ProviderInterface } if (!isset($this->providers[$name])) { - throw new UndefinedProviderException(sprintf('The provider "%s" is not defined.', $name)); + throw new UndefinedProviderException(\sprintf('The provider "%s" is not defined.', $name)); } return $this->providers[$name];