From 2c9e0564363ecc8424b97dea1d160289d9614a54 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 14 Dec 2023 23:39:44 +0100 Subject: [PATCH] Composer/PHPCS: update to YoastCS 3.0.0 YoastCS 3.0.0 has been released and is based on WordPressCS 3.0.0. This commit makes the necessary updates for that: * Composer: update the requirements. * PHPCS ruleset: - Exclude new (and more) WP specific rules which don't apply to this package. - Exclude code modernization sniffs which can't be applied to this package yet. - Enforce strict PSR-4 for both src and tests. - Update a few property names for new names in WordPressCS 3.0. - Remove a few exclusions which are no longer needed. - Add a few selective exclusions for specific situations. * GHA CS workflow: run the CS check on the latest PHP version. No need to run on PHP 7.4 any more as the deprecations previously encountered were all fixed. While YoastCS 3.0.0 contains lots of goodies, it also has a downside: a minimum PHP requirement of PHP 7.2, which conflicts with the minimum supported PHP version of this package. This causes two issues: 1. A plain `composer install` will no longer work on PHP < 7.2. This means the YoastCS package will need to be removed for the CI test workfows. 2. As the (Parallel) linting packages are "inherited" from YoastCS, removing YoastCS would break the linting command in CI, so we need to `require-dev` the Parallel Lint packages in PHPUnit Polyfills itself to allow the workflow to continue to work. With those two work-arounds in place, everything should work again. Refs: * https://github.com/Yoast/yoastcs/releases/tag/3.0.0 * https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0 --- .github/workflows/cs.yml | 2 +- .github/workflows/test.yml | 4 ++ .phpcs.xml.dist | 91 +++++++++++++++++++++++--------------- composer.json | 4 +- 4 files changed, 63 insertions(+), 38 deletions(-) diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index c2dcbed..0d5cc48 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -19,7 +19,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: 'latest' coverage: none tools: cs2pr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c420829..1550827 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,10 @@ jobs: ini-values: error_reporting=E_ALL, display_errors=On coverage: ${{ matrix.coverage == true && 'xdebug' || 'none' }} + # YoastCS 3.0 has a PHP 7.2 minimum which conflicts with the requirements of this package. + - name: 'Composer: remove YoastCS' + run: composer remove --dev yoast/yoastcs --no-update --no-interaction + # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies - normal diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index ff1e0a9..018a9a8 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -1,27 +1,27 @@ - Check the code of WP Test Utils. + Check the code of WP Test Utils. - + - . + . - - + + - - + + - - + + - - + + @@ -41,16 +41,25 @@ - - - - - - + + + + + + + + + + + - + + + *\.php + - + - - + + - - + + + /tests/*\.php + + + + + + + @@ -78,7 +95,7 @@ - + @@ -92,11 +109,6 @@ ############################################################################# --> - - - /src/*/bootstrap*\.php$ - - /src/BrainMonkey/bootstrap\.php$ @@ -116,9 +128,16 @@ /src/Helpers/*\.php$ - + + + + + /tests/*/Fixtures/*\.php$ + + + - /tests/*\.php$ + /tests/*/Fixtures/*\.php$ diff --git a/composer.json b/composer.json index 61b7462..bb2c1ca 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,9 @@ "yoast/phpunit-polyfills": "^1.1.0" }, "require-dev": { - "yoast/yoastcs": "^2.3.1" + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "yoast/yoastcs": "^3.0" }, "minimum-stability": "dev", "prefer-stable": true,