From cd7e371a857ba0bc3d33165f681e9886e57a8aa7 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Mon, 19 Dec 2022 17:57:21 +0000 Subject: [PATCH 1/7] Composer: up the minimum PHPCS version to 3.7.1 Add support for PHP 8.1 features, including fixing a retokenization of reserved keywords bug in PHPCS 3.7.0. --- .github/workflows/quicktest.yml | 6 +----- .github/workflows/test.yml | 2 +- README.md | 2 +- composer.json | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 3de35f83..38336154 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -30,16 +30,12 @@ jobs: phpcs_version: 'dev-master' wpcs_version: '2.3.*' - php: '5.4' - phpcs_version: '3.5.5' + phpcs_version: '3.7.1' wpcs_version: '2.3.*' - php: 'latest' phpcs_version: 'dev-master' wpcs_version: '2.3.*' - - php: 'latest' - # PHPCS 3.6.1 is the lowest version of PHPCS which supports PHP 8.1. - phpcs_version: '3.6.1' - wpcs_version: '2.3.*' name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e4cb6cf..4ac024be 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,7 +71,7 @@ jobs: # - experimental: Whether the build is "allowed to fail". matrix: php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] - phpcs_version: ['3.5.5', 'dev-master'] + phpcs_version: ['3.7.1', 'dev-master'] wpcs_version: ['2.3.*'] experimental: [false] diff --git a/README.md b/README.md index a52db246..f2049fbd 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Go to https://docs.wpvip.com/technical-references/code-review/phpcs-report/ to l ## Minimal requirements * PHP 5.4+ -* [PHPCS 3.5.5+](https://github.com/squizlabs/PHP_CodeSniffer/releases) +* [PHPCS 3.7.1+](https://github.com/squizlabs/PHP_CodeSniffer/releases) * [WPCS 2.3.0+](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases) * [VariableAnalysis 2.11.1+](https://github.com/sirbrillig/phpcs-variable-analysis/releases) diff --git a/composer.json b/composer.json index bab249fe..e3ada30f 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.4", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", "sirbrillig/phpcs-variable-analysis": "^2.11.1", - "squizlabs/php_codesniffer": "^3.5.5", + "squizlabs/php_codesniffer": "^3.7.1", "wp-coding-standards/wpcs": "^2.3" }, "require-dev": { From a3acf351287c009ebdeac58b4a731d5a4b6d09aa Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 20 Dec 2022 00:47:53 +0000 Subject: [PATCH 2/7] Composer: rename scripts Brings them more into line with the Composer scripts in WPCS. --- composer.json | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index e3ada30f..c121771a 100644 --- a/composer.json +++ b/composer.json @@ -35,25 +35,27 @@ } }, "scripts": { - "install-codestandards": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run", - "ruleset": "bin/ruleset-tests", - "lint": [ - "bin/php-lint", - "bin/xml-lint" + "check-all": [ + "@lint", + "@check-cs", + "@run-tests", + "@check-complete-strict", + "@ruleset" ], - "phpcs": "bin/phpcs", - "phpunit": "bin/unit-tests", - "coverage": "bin/unit-tests-coverage", "check-complete": [ "@php ./vendor/phpcsstandards/phpcsdevtools/bin/phpcs-check-feature-completeness -q ./WordPressVIPMinimum" ], - "test": [ - "@lint", - "@ruleset", - "@phpunit", - "@phpcs", - "@check-complete" - ] + "check-complete-strict": [ + "@php ./vendor/phpcsstandards/phpcsdevtools/bin/phpcs-check-feature-completeness ./WordPressVIPMinimum" + ], + "check-cs": "bin/phpcs", + "lint": [ + "bin/php-lint", + "bin/xml-lint" + ], + "ruleset": "bin/ruleset-tests", + "run-tests": "bin/unit-tests", + "run-tests-coverage": "bin/unit-tests-coverage" }, "support": { "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", From b4aa62850f8d2afe9f746b1ba88ec4ca9d7ead32 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 20 Dec 2022 00:49:47 +0000 Subject: [PATCH 3/7] Composer: add script descriptions --- composer.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/composer.json b/composer.json index c121771a..a464c796 100644 --- a/composer.json +++ b/composer.json @@ -57,6 +57,14 @@ "run-tests": "bin/unit-tests", "run-tests-coverage": "bin/unit-tests-coverage" }, + "scripts-descriptions": { + "check-all": "Run all checks (lint, phpcs, feature completeness) and tests.", + "check-complete": "Check if all the sniffs have tests.", + "check-complete-strict": "Check if all the sniffs have unit tests and XML documentation.", + "check-cs": "Run the PHPCS script against the entire codebase.", + "lint": "Lint PHP files against parse errors.", + "run-tests": "Run all the unit tests for the VIP Coding Standards sniffs." + }, "support": { "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki", From 8fb88055a2d844c299a3e8d9a988a5281157e44f Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 20 Dec 2022 00:53:02 +0000 Subject: [PATCH 4/7] Composer: use develop branch of WPCS VIPCS needs to be compatible with WordPress Coding Standards 3.0.0, which is currently in development on its `develop` branch. WPCS now uses some extra dependencies, which are also in development, so we need to allow for a minimum-stability of dev. Run `composer update -W` to pull those extra dependencies in. --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a464c796..ebce3726 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", "sirbrillig/phpcs-variable-analysis": "^2.11.1", "squizlabs/php_codesniffer": "^3.7.1", - "wp-coding-standards/wpcs": "^2.3" + "wp-coding-standards/wpcs": "dev-develop" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.3.2", @@ -29,6 +29,8 @@ "phpcsstandards/phpcsdevtools": "^1.0", "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" }, + "minimum-stability": "dev", + "prefer-stable": true, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true From 5a82c31b6077292b071f5ed8763cc1d1eb3a0186 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 20 Dec 2022 00:54:48 +0000 Subject: [PATCH 5/7] Composer: Normalize the order Uses the composer-normalize plugin to keep a consistent order. --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index ebce3726..913a301d 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,25 @@ { "name": "automattic/vipwpcs", - "type": "phpcodesniffer-standard", "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", + "license": "MIT", + "type": "phpcodesniffer-standard", "keywords": [ "phpcs", "static analysis", "standards", "WordPress" ], - "license": "MIT", "authors": [ { "name": "Contributors", "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" } ], + "support": { + "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", + "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki", + "source": "https://github.com/Automattic/VIP-Coding-Standards" + }, "require": { "php": ">=5.4", "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", @@ -23,8 +28,8 @@ "wp-coding-standards/wpcs": "dev-develop" }, "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.3.2", "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9", "phpcsstandards/phpcsdevtools": "^1.0", "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" @@ -66,10 +71,5 @@ "check-cs": "Run the PHPCS script against the entire codebase.", "lint": "Lint PHP files against parse errors.", "run-tests": "Run all the unit tests for the VIP Coding Standards sniffs." - }, - "support": { - "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", - "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki", - "source": "https://github.com/Automattic/VIP-Coding-Standards" } } From bdb63b7cbeddb36440448b90dcc6dd6fb987d932 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 30 Dec 2022 10:06:32 +0000 Subject: [PATCH 6/7] Update composer.json Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 913a301d..108fea85 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ }, "scripts-descriptions": { "check-all": "Run all checks (lint, phpcs, feature completeness) and tests.", - "check-complete": "Check if all the sniffs have tests.", + "check-complete": "Check if all the sniffs have unit tests.", "check-complete-strict": "Check if all the sniffs have unit tests and XML documentation.", "check-cs": "Run the PHPCS script against the entire codebase.", "lint": "Lint PHP files against parse errors.", From d80b2456f4dceadec4dd79b44756f727d91ac833 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 30 Dec 2022 10:07:22 +0000 Subject: [PATCH 7/7] Update composer.json Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 108fea85..c7a2810c 100644 --- a/composer.json +++ b/composer.json @@ -68,7 +68,7 @@ "check-all": "Run all checks (lint, phpcs, feature completeness) and tests.", "check-complete": "Check if all the sniffs have unit tests.", "check-complete-strict": "Check if all the sniffs have unit tests and XML documentation.", - "check-cs": "Run the PHPCS script against the entire codebase.", + "check-cs": "Check the code style and code quality of the codebase via PHPCS.", "lint": "Lint PHP files against parse errors.", "run-tests": "Run all the unit tests for the VIP Coding Standards sniffs." }