From 15e1fc94f599890e6201d6a1f4b452856711f4e1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 7 Nov 2023 01:11:00 +0100 Subject: [PATCH 1/5] Switch to PHPCSStandards/PHP_CodeSniffer The Squizlabs repo has been abandoned. The project continues in a fork in the PHPCSStandards organisation. Ref: * squizlabs/PHP_CodeSniffer 3932 --- .github/CONTRIBUTING.md | 2 +- .github/release-checklist.md | 2 +- .github/workflows/basic-qa.yml | 10 +++++----- .github/workflows/quicktest.yml | 4 ++-- .github/workflows/unit-tests.yml | 4 ++-- .phpcs.xml.dist | 4 ++-- CHANGELOG.md | 16 ++++++++-------- README.md | 6 +++--- Tests/bootstrap.php | 2 +- WordPress-Core/ruleset.xml | 2 +- WordPress-Docs/ruleset.xml | 2 +- WordPress-Extra/ruleset.xml | 2 +- .../NamingConventions/ValidVariableNameSniff.php | 2 +- .../WhiteSpace/ControlStructureSpacingSniff.php | 2 +- .../WhiteSpace/ObjectOperatorSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/OperatorSpacingSniff.php | 2 +- WordPress/ruleset.xml | 2 +- composer.json | 10 +++++----- phpcs.xml.dist.sample | 6 +++--- 19 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index eed45e0227..4200e0a275 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -14,7 +14,7 @@ Bug reports containing a minimal code sample which can be used to reproduce the Since WordPressCS employs many sniffs that are part of PHP_CodeSniffer itself or PHPCSExtra, sometimes an issue will be caused by a bug in PHPCS or PHPCSExtra and not in WordPressCS itself. If the error message in question doesn't come from a sniff whose name starts with `WordPress`, the issue is probably a bug in PHPCS or PHPCSExtra. -* Bugs for sniffs starting with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` should be [reported to PHPCS](https://github.com/squizlabs/PHP_CodeSniffer/issues). +* Bugs for sniffs starting with `Generic`, `PEAR`, `PSR1`, `PSR2`, `PSR12`, `Squiz` or `Zend` should be [reported to PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues). * Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues). # Contributing patches and new features diff --git a/.github/release-checklist.md b/.github/release-checklist.md index df5f91ed48..108bea3aa7 100644 --- a/.github/release-checklist.md +++ b/.github/release-checklist.md @@ -64,7 +64,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH - [ ] Submit for ["Month in WordPress"][month-in-wp]. - [ ] Submit for the ["Monthy Dev Roundup"][dev-roundup]. -[phpcs-releases]: https://github.com/squizlabs/PHP_CodeSniffer/releases +[phpcs-releases]: https://github.com/PHPCSStandards/PHP_CodeSniffer/releases [phpcsutils-releases]: https://github.com/PHPCSStandards/PHPCSUtils/releases [phpcsextra-releases]: https://github.com/PHPCSStandards/PHPCSExtra/releases [month-in-wp]: https://make.wordpress.org/community/month-in-wordpress-submissions/ diff --git a/.github/workflows/basic-qa.yml b/.github/workflows/basic-qa.yml index c0fc7eeee2..9e35b8fc0b 100644 --- a/.github/workflows/basic-qa.yml +++ b/.github/workflows/basic-qa.yml @@ -39,7 +39,7 @@ jobs: # Using PHPCS `master` as an early detection system for bugs upstream. - name: Set PHPCS version - run: composer require squizlabs/php_codesniffer:"dev-master" --no-update --no-scripts --no-interaction + run: composer require phpcsstandards/php_codesniffer:"dev-master" --no-update --no-scripts --no-interaction - name: Install Composer dependencies uses: ramsey/composer-install@v2 @@ -68,10 +68,10 @@ jobs: # Validate the Ruleset XML files. # @link http://xmlsoft.org/xmllint.html - name: Validate the WordPress rulesets - run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml + run: xmllint --noout --schema vendor/phpcsstandards/php_codesniffer/phpcs.xsd ./*/ruleset.xml - name: Validate the sample ruleset - run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample + run: xmllint --noout --schema vendor/phpcsstandards/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample # Validate the Documentation XML files. - name: Validate documentation against schema @@ -117,7 +117,7 @@ jobs: - name: "Set PHPCS version (master)" if: ${{ matrix.phpcs_version != 'lowest' }} - run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction + run: composer require phpcsstandards/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction - name: Install Composer dependencies uses: ramsey/composer-install@v2 @@ -128,7 +128,7 @@ jobs: - name: "Set PHPCS version (lowest)" if: ${{ matrix.phpcs_version == 'lowest' }} - run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction + run: composer update phpcsstandards/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction - name: Test the WordPress-Core ruleset run: $(pwd)/vendor/bin/phpcs -ps ./Tests/RulesetCheck/class-ruleset-test.inc --standard=WordPress-Core diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 182c24c1de..bafa089b7e 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -52,7 +52,7 @@ jobs: - name: "Set PHPCS version (master)" if: ${{ matrix.phpcs_version != 'lowest' }} - run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction + run: composer require phpcsstandards/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction - name: Install Composer dependencies (PHP < 8.0 ) if: ${{ matrix.php < 8.0 && matrix.php != 'latest' }} @@ -70,7 +70,7 @@ jobs: - name: "Set PHPCS version (lowest)" if: ${{ matrix.phpcs_version == 'lowest' }} - run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction + run: composer update phpcsstandards/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction - name: Lint PHP files against parse errors if: ${{ matrix.phpcs_version == 'dev-master' }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 3a4bde4397..7108233cce 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -84,7 +84,7 @@ jobs: - name: "Set PHPCS version (master)" if: ${{ matrix.phpcs_version != 'lowest' }} - run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction + run: composer require phpcsstandards/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction - name: Install Composer dependencies (PHP < 8.0 ) if: ${{ matrix.php < 8.0 }} @@ -102,7 +102,7 @@ jobs: - name: "Set PHPCS version (lowest)" if: ${{ matrix.phpcs_version == 'lowest' }} - run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction + run: composer update phpcsstandards/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction - name: Lint PHP files against parse errors if: ${{ matrix.phpcs_version == 'dev-master' }} diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index af658a72a5..26307bffdd 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -1,12 +1,12 @@ - + The Coding standard for the WordPress Coding Standards itself. diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bfac3e701..6aacee386f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,7 +97,7 @@ In all cases, please read the complete changelog carefully before you upgrade. - The `sanitize_url()` and `wp_kses_one_attr()` functions to the list of known "sanitizing" functions. - Metrics for blank lines at the start/end of a control structure body to the `WordPress.WhiteSpace.ControlStructureSpacing` sniff. These can be displayed using `--report=info` when the `blank_line_check` property has been set to `true`. - End-user documentation to the following new and pre-existing sniffs: `WordPress.DateTime.RestrictedFunctions`, `WordPress.NamingConventions.PrefixAllGlobals` (props [@Ipstenu]), `WordPress.PHP.StrictInArray` (props [@marconmartins]), `WordPress.PHP.YodaConditions` (props [@Ipstenu]), `WordPress.WhiteSpace.ControlStructureSpacing` (props [@ckanitz]), `WordPress.WhiteSpace.ObjectOperatorSpacing`, `WordPress.WhiteSpace.OperatorSpacing` (props [@ckanitz]), `WordPress.WP.CapitalPDangit` (props [@NielsdeBlaauw]), `WordPress.WP.Capabilities`, `WordPress.WP.ClassNameCase`, `WordPress.WP.EnqueueResourceParameters` (props [@NielsdeBlaauw]). - This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage). + This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage). Note: all sniffs which have been added from PHPCSExtra (Universal, Modernize, NormalizedArrays sniffs) are also fully documented. #### Added (internal/dev-only) @@ -454,7 +454,7 @@ The move does not affect the package name for Packagist. This remains the same: - `Sniff::get_list_variables()` utility method which will retrieve an array with the token pointers to the variables which are being assigned to in a `list()` construct. Includes support for short lists. - `Sniff::is_function_deprecated()` static utility method to determine whether a declared function has been marked as deprecated in the function DocBlock. - End-user documentation to the following existing sniffs: `WordPress.Arrays.ArrayIndentation`, `WordPress.Arrays.ArrayKeySpacingRestrictions`, `WordPress.Arrays.MultipleStatementAlignment`, `WordPress.Classes.ClassInstantiation`, `WordPress.NamingConventions.ValidHookName`, `WordPress.PHP.IniSet`, `WordPress.Security.SafeRedirect`, `WordPress.WhiteSpace.CastStructureSpacing`, `WordPress.WhiteSpace.DisallowInlineTabs`, `WordPress.WhiteSpace.PrecisionAlignment`, `WordPress.WP.CronInterval`, `WordPress.WP.DeprecatedClasses`, `WordPress.WP.DeprecatedFunctions`, `WordPress.WP.DeprecatedParameters`, `WordPress.WP.DeprecatedParameterValues`, `WordPress.WP.EnqueuedResources`, `WordPress.WP.PostsPerPage`. - This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage). + This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage). ### Changed - The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `5.0`. @@ -661,7 +661,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of - `WordPress.NamingConventions.ValidVariableName`: Added unit tests confirming support for multi-variable/property declarations. - The `get_name_suggestion()` method has been moved from the `WordPress.NamingConventions.ValidFunctionName` sniff to the base `Sniff` class, renamed to `get_snake_case_name_suggestion()` and made static. - The rulesets are now validated against the `PHP_CodeSniffer` XSD schema. -- Updated the [custom ruleset example](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to use the recommended ruleset syntax for `PHP_CodeSniffer` 3.3.1+, including using the new [array property format](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0) which is now supported. +- Updated the [custom ruleset example](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to use the recommended ruleset syntax for `PHP_CodeSniffer` 3.3.1+, including using the new [array property format](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.3.0) which is now supported. - Dev: The command to run the unit tests has changed. Please see the updated instructions in the [CONTRIBUTING.md](https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/.github/CONTRIBUTING.md) file. The `bin/pre-commit` example git hook has been updated to match. Additionally a `run-tests` script has been added to the `composer.json` file for your convenience. To facilitate this, PHPUnit has been added to `require-dev`, even though it is strictly speaking a dependency of PHPCS, not of WPCS. @@ -672,7 +672,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of ### Deprecated - The use of the [WordPressCS native whitelist comments](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors), which were introduced in WPCS 0.4.0, have been deprecated and support will be removed in WPCS 3.0.0. The WordPressCS native whitelist comments will continue to work for now, but a deprecation warning will be thrown when they are encountered. - You are encouraged to upgrade our whitelist comment to use the [PHPCS native selective ignore annotations](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.2.0) as introduced in `PHP_CodeSniffer` 3.2.0, as soon as possible. + You are encouraged to upgrade our whitelist comment to use the [PHPCS native selective ignore annotations](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.2.0) as introduced in `PHP_CodeSniffer` 3.2.0, as soon as possible. ### Removed - Support for PHP 5.3. PHP 5.4 is the minimum requirement for `PHP_CodeSniffer` 3.x. @@ -684,7 +684,7 @@ If you are a maintainer of an external standard based on WordPressCS and any of - Support for array properties set in a custom ruleset without the `type="array"` attribute. Support for this was deprecated in WPCS 1.0.0. If in doubt about how properties should be set in your custom ruleset, please refer to the [Customizable sniff properties](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) wiki page which contains XML code examples for setting each and every WPCS native sniff property. - As the minimum `PHP_CodeSniffer` version is now 3.3.1, you can now also use the [new format for setting array properties](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0), so this would be a great moment to review and update your custom ruleset. + As the minimum `PHP_CodeSniffer` version is now 3.3.1, you can now also use the [new format for setting array properties](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.3.0), so this would be a great moment to review and update your custom ruleset. Note: the ability to set select properties from the command-line as comma-delimited strings is _not_ affected by this change. - The following sniffs have been removed outright without deprecation. If you are referencing these sniffs in a ruleset XML file or in inline annotations, please update these to reference the replacement sniffs instead. @@ -985,10 +985,10 @@ If you are a maintainer of an external standard based on WPCS and any of your cu ### Fixed - Compatibility with PHP 7.3. A change in PHP 7.3 was causing the `WordPress.DB.RestrictedClasses`, `WordPress.DB.RestrictedFunctions` and the `WordPress.WP.AlternativeFunctions` sniffs to fail to correctly detect issues. -- Compatibility with the latest releases from [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). +- Compatibility with the latest releases from [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer). PHPCS 3.2.0 introduced new annotations which can be used inline to selectively disable/ignore certain sniffs. **Note**: The initial implementation of the new annotations was buggy. If you intend to start using these new style annotations, you are strongly advised to use PHPCS 3.3.0 or higher. - For more information about these annotations, please refer to the [PHPCS Wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file). + For more information about these annotations, please refer to the [PHPCS Wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file). - The [WPCS native whitelist comments](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) can now be combined with the new style PHPCS whitelist annotations in the `-- for reasons` part of the annotation. - `WordPress.Arrays.ArrayDeclarationSpacing`: the fixer will now handle the new style annotations correctly. - `WordPress.Arrays.CommaAfterArrayItem`: prevent a fixer loop when new style annotations are encountered. @@ -1221,7 +1221,7 @@ If you exclude some sniffs or error codes, you may have to update your custom ru Additionally, to make it easier for you to customize your ruleset, two new wiki pages have been published with information on the properties you can adjust from your ruleset: * [WPCS customizable sniff properties](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) -* [PHPCS customizable sniff properties](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties) +* [PHPCS customizable sniff properties](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties) For more detailed information about the changed sniff names and error codes, please refer to PR [#633](https://github.com/WordPress/WordPress-Coding-Standards/pull/633) and PR [#814](https://github.com/WordPress/WordPress-Coding-Standards/pull/814). diff --git a/README.md b/README.md index f8023bdc96..6876f5cf1a 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ ## Introduction -This project is a collection of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/). +This project is a collection of [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/). This project needs funding. [Find out how you can help](#funding). @@ -133,7 +133,7 @@ If you need to further customize the selection of sniffs for your project - you When you name this file either `.phpcs.xml`, `phpcs.xml`, `.phpcs.xml.dist` or `phpcs.xml.dist`, PHP_CodeSniffer will automatically locate it as long as it is placed in the directory from which you run the CodeSniffer or in a directory above it. If you follow these naming conventions you don't have to supply a `--standard` CLI argument. -For more info, read about [using a default configuration file](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). See also the provided WordPressCS [`phpcs.xml.dist.sample`](phpcs.xml.dist.sample) file and the [fully annotated example ruleset](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) in the PHP_CodeSniffer documentation. +For more info, read about [using a default configuration file](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file). See also the provided WordPressCS [`phpcs.xml.dist.sample`](phpcs.xml.dist.sample) file and the [fully annotated example ruleset](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml) in the PHP_CodeSniffer documentation. ### Customizing sniff behaviour @@ -143,7 +143,7 @@ You can find a complete list of all the properties you can change for the WordPr WordPressCS also uses sniffs from PHPCSExtra and from PHP_CodeSniffer itself. The [README for PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra) contains information on the properties which can be set for the sniff from PHPCSExtra. -Information on custom properties which can be set for sniffs from PHP_CodeSniffer can be found in the [PHP_CodeSniffer wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties). +Information on custom properties which can be set for sniffs from PHP_CodeSniffer can be found in the [PHP_CodeSniffer wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties). ### Recommended additional rulesets diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index fd4c952893..fabe3a9ba2 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -25,7 +25,7 @@ */ // Get the PHPCS dir from an environment variable. $phpcsDir = getenv( 'PHPCS_DIR' ); -$composerPHPCSPath = dirname( __DIR__ ) . $ds . 'vendor' . $ds . 'squizlabs' . $ds . 'php_codesniffer'; +$composerPHPCSPath = dirname( __DIR__ ) . $ds . 'vendor' . $ds . 'phpcsstandards' . $ds . 'php_codesniffer'; if ( false === $phpcsDir && is_dir( $composerPHPCSPath ) ) { // PHPCS installed via Composer. diff --git a/WordPress-Core/ruleset.xml b/WordPress-Core/ruleset.xml index 5396b02134..8671caef58 100644 --- a/WordPress-Core/ruleset.xml +++ b/WordPress-Core/ruleset.xml @@ -1,5 +1,5 @@ - + Non-controversial generally-agreed upon WordPress Coding Standards diff --git a/WordPress-Docs/ruleset.xml b/WordPress-Docs/ruleset.xml index b351118584..c8b5969a96 100644 --- a/WordPress-Docs/ruleset.xml +++ b/WordPress-Docs/ruleset.xml @@ -1,5 +1,5 @@ - + WordPress Coding Standards for Inline Documentation and Comments diff --git a/WordPress-Extra/ruleset.xml b/WordPress-Extra/ruleset.xml index 8a104c84ec..8b065c7a1f 100644 --- a/WordPress-Extra/ruleset.xml +++ b/WordPress-Extra/ruleset.xml @@ -1,5 +1,5 @@ - + Best practices beyond core WordPress Coding Standards diff --git a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php index 37171540cd..6202f2b5e3 100644 --- a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -29,7 +29,7 @@ * @since 2.0.0 Now offers name suggestions for variables in violation. * * Last synced with base class January 2022 at commit 4b49a952bf0e2c3863d0a113256bae0d7fe63d52. - * @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php */ final class ValidVariableNameSniff extends PHPCS_AbstractVariableSniff { diff --git a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 11fecd6491..995216a564 100644 --- a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -26,7 +26,7 @@ * Last synced with base class 2021-11-20 at commit 7f11ffc8222b123c06345afd3261221561c3bb29. * Note: This class has diverged quite far from the original. All the same, checking occasionally * to see if there are upstream fixes made from which this sniff can benefit, is warranted. - * @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php */ final class ControlStructureSpacingSniff extends Sniff { diff --git a/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index b54d3c421b..a832b4f2c6 100644 --- a/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -20,7 +20,7 @@ * - When the `::` operator is used in `::class`, no new line(s) before or after the object operator are allowed. * * @since 3.0.0 - * @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php */ final class ObjectOperatorSpacingSniff extends Squiz_ObjectOperatorSpacingSniff { diff --git a/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php index 7824379588..2caa937df0 100644 --- a/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -31,7 +31,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * * Last verified with base class June 2023 at commit 085b1e091b0f2e451333c0bc26dd50bba39402c4. - * @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php + * @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php */ final class OperatorSpacingSniff extends PHPCS_Squiz_OperatorSpacingSniff { diff --git a/WordPress/ruleset.xml b/WordPress/ruleset.xml index fd24ae6318..e1c7971418 100644 --- a/WordPress/ruleset.xml +++ b/WordPress/ruleset.xml @@ -1,5 +1,5 @@ - + WordPress Coding Standards diff --git a/composer.json b/composer.json index b6e8abd2f7..21d1a40c3c 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*", - "squizlabs/php_codesniffer": "^3.7.2", + "phpcsstandards/php_codesniffer": "^3.7.2", "phpcsstandards/phpcsutils": "^1.0.8", "phpcsstandards/phpcsextra": "^1.2.0" }, @@ -46,16 +46,16 @@ "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git" ], "check-cs": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs" + "@php ./vendor/phpcsstandards/php_codesniffer/bin/phpcs" ], "fix-cs": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf" + "@php ./vendor/phpcsstandards/php_codesniffer/bin/phpcbf" ], "run-tests": [ - "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/squizlabs/php_codesniffer/tests/AllTests.php --no-coverage" + "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/phpcsstandards/php_codesniffer/tests/AllTests.php --no-coverage" ], "coverage": [ - "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/squizlabs/php_codesniffer/tests/AllTests.php" + "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/phpcsstandards/php_codesniffer/tests/AllTests.php" ], "check-complete": [ "@php ./vendor/phpcsstandards/phpcsdevtools/bin/phpcs-check-feature-completeness -q ./WordPress" diff --git a/phpcs.xml.dist.sample b/phpcs.xml.dist.sample index b1ddd44803..fa456b5813 100644 --- a/phpcs.xml.dist.sample +++ b/phpcs.xml.dist.sample @@ -1,12 +1,12 @@ - + A custom set of rules to check for a WPized WordPress project @@ -141,7 +141,7 @@ legitimate exclusion. For more information on ruleset configuration optiones, check out the PHPCS wiki: - https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset + https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset --> /path/to/Tests/*Test\.php From 184db6677feb6d415d9a7f709fa382843413f5a5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 7 Dec 2023 04:00:29 +0100 Subject: [PATCH 2/5] Revert changes to the Composer package name In contrast to earlier information, arrangements are now being made to allow the package to continue under its original name on Packagist. The commit (in the new repo) to rename the package [has been reverted](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/135). --- .github/workflows/basic-qa.yml | 10 +++++----- .github/workflows/quicktest.yml | 4 ++-- .github/workflows/unit-tests.yml | 4 ++-- Tests/bootstrap.php | 2 +- composer.json | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/basic-qa.yml b/.github/workflows/basic-qa.yml index 9e35b8fc0b..c0fc7eeee2 100644 --- a/.github/workflows/basic-qa.yml +++ b/.github/workflows/basic-qa.yml @@ -39,7 +39,7 @@ jobs: # Using PHPCS `master` as an early detection system for bugs upstream. - name: Set PHPCS version - run: composer require phpcsstandards/php_codesniffer:"dev-master" --no-update --no-scripts --no-interaction + run: composer require squizlabs/php_codesniffer:"dev-master" --no-update --no-scripts --no-interaction - name: Install Composer dependencies uses: ramsey/composer-install@v2 @@ -68,10 +68,10 @@ jobs: # Validate the Ruleset XML files. # @link http://xmlsoft.org/xmllint.html - name: Validate the WordPress rulesets - run: xmllint --noout --schema vendor/phpcsstandards/php_codesniffer/phpcs.xsd ./*/ruleset.xml + run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml - name: Validate the sample ruleset - run: xmllint --noout --schema vendor/phpcsstandards/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample + run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample # Validate the Documentation XML files. - name: Validate documentation against schema @@ -117,7 +117,7 @@ jobs: - name: "Set PHPCS version (master)" if: ${{ matrix.phpcs_version != 'lowest' }} - run: composer require phpcsstandards/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction + run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction - name: Install Composer dependencies uses: ramsey/composer-install@v2 @@ -128,7 +128,7 @@ jobs: - name: "Set PHPCS version (lowest)" if: ${{ matrix.phpcs_version == 'lowest' }} - run: composer update phpcsstandards/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction + run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction - name: Test the WordPress-Core ruleset run: $(pwd)/vendor/bin/phpcs -ps ./Tests/RulesetCheck/class-ruleset-test.inc --standard=WordPress-Core diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index bafa089b7e..182c24c1de 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -52,7 +52,7 @@ jobs: - name: "Set PHPCS version (master)" if: ${{ matrix.phpcs_version != 'lowest' }} - run: composer require phpcsstandards/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction + run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction - name: Install Composer dependencies (PHP < 8.0 ) if: ${{ matrix.php < 8.0 && matrix.php != 'latest' }} @@ -70,7 +70,7 @@ jobs: - name: "Set PHPCS version (lowest)" if: ${{ matrix.phpcs_version == 'lowest' }} - run: composer update phpcsstandards/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction + run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction - name: Lint PHP files against parse errors if: ${{ matrix.phpcs_version == 'dev-master' }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7108233cce..3a4bde4397 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -84,7 +84,7 @@ jobs: - name: "Set PHPCS version (master)" if: ${{ matrix.phpcs_version != 'lowest' }} - run: composer require phpcsstandards/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction + run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction - name: Install Composer dependencies (PHP < 8.0 ) if: ${{ matrix.php < 8.0 }} @@ -102,7 +102,7 @@ jobs: - name: "Set PHPCS version (lowest)" if: ${{ matrix.phpcs_version == 'lowest' }} - run: composer update phpcsstandards/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction + run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction - name: Lint PHP files against parse errors if: ${{ matrix.phpcs_version == 'dev-master' }} diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index fabe3a9ba2..fd4c952893 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -25,7 +25,7 @@ */ // Get the PHPCS dir from an environment variable. $phpcsDir = getenv( 'PHPCS_DIR' ); -$composerPHPCSPath = dirname( __DIR__ ) . $ds . 'vendor' . $ds . 'phpcsstandards' . $ds . 'php_codesniffer'; +$composerPHPCSPath = dirname( __DIR__ ) . $ds . 'vendor' . $ds . 'squizlabs' . $ds . 'php_codesniffer'; if ( false === $phpcsDir && is_dir( $composerPHPCSPath ) ) { // PHPCS installed via Composer. diff --git a/composer.json b/composer.json index 21d1a40c3c..b6e8abd2f7 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*", - "phpcsstandards/php_codesniffer": "^3.7.2", + "squizlabs/php_codesniffer": "^3.7.2", "phpcsstandards/phpcsutils": "^1.0.8", "phpcsstandards/phpcsextra": "^1.2.0" }, @@ -46,16 +46,16 @@ "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git" ], "check-cs": [ - "@php ./vendor/phpcsstandards/php_codesniffer/bin/phpcs" + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs" ], "fix-cs": [ - "@php ./vendor/phpcsstandards/php_codesniffer/bin/phpcbf" + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf" ], "run-tests": [ - "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/phpcsstandards/php_codesniffer/tests/AllTests.php --no-coverage" + "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/squizlabs/php_codesniffer/tests/AllTests.php --no-coverage" ], "coverage": [ - "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/phpcsstandards/php_codesniffer/tests/AllTests.php" + "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/squizlabs/php_codesniffer/tests/AllTests.php" ], "check-complete": [ "@php ./vendor/phpcsstandards/phpcsdevtools/bin/phpcs-check-feature-completeness -q ./WordPress" From 7b03ef5a76e228720e13e140b50d1900dc15eb69 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 14 Nov 2023 02:41:53 +0100 Subject: [PATCH 3/5] Composer: raise the minimum supported PHPCS version to 3.8.0 ... for improved PHP 8.2 support. --- .github/CONTRIBUTING.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4200e0a275..dedbdbb9e0 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -39,7 +39,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class ## Pre-requisites * WordPress-Coding-Standards -* PHP_CodeSniffer 3.7.2 or higher +* PHP_CodeSniffer 3.8.0 or higher * PHPCSUtils 1.0.8 or higher * PHPCSExtra 1.2.0 or higher * PHPUnit 4.x, 5.x, 6.x or 7.x diff --git a/composer.json b/composer.json index b6e8abd2f7..fbc394e69b 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "ext-libxml": "*", "ext-tokenizer": "*", "ext-xmlreader": "*", - "squizlabs/php_codesniffer": "^3.7.2", + "squizlabs/php_codesniffer": "^3.8.0", "phpcsstandards/phpcsutils": "^1.0.8", "phpcsstandards/phpcsextra": "^1.2.0" }, From bf168c6cadf84f7744fd79394c4030c7d57e970e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 14 Nov 2023 02:43:27 +0100 Subject: [PATCH 4/5] Composer: update various version constraints ... after the tooling has also updated to the PHPCSStandards version of PHPCS. Refs: * https://github.com/PHPCSStandards/PHPCSUtils/releases * https://github.com/PHPCSStandards/PHPCSExtra/releases --- .github/CONTRIBUTING.md | 4 ++-- composer.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index dedbdbb9e0..2eb61e5b9c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -40,8 +40,8 @@ When you introduce new `public` sniff properties, or your sniff extends a class ## Pre-requisites * WordPress-Coding-Standards * PHP_CodeSniffer 3.8.0 or higher -* PHPCSUtils 1.0.8 or higher -* PHPCSExtra 1.2.0 or higher +* PHPCSUtils 1.0.9 or higher +* PHPCSExtra 1.2.1 or higher * PHPUnit 4.x, 5.x, 6.x or 7.x The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test framework for unit testing the sniffs. diff --git a/composer.json b/composer.json index fbc394e69b..ef3e469b59 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "ext-tokenizer": "*", "ext-xmlreader": "*", "squizlabs/php_codesniffer": "^3.8.0", - "phpcsstandards/phpcsutils": "^1.0.8", - "phpcsstandards/phpcsextra": "^1.2.0" + "phpcsstandards/phpcsutils": "^1.0.9", + "phpcsstandards/phpcsextra": "^1.2.1" }, "require-dev": { "phpcompatibility/php-compatibility": "^9.0", From 105a10cafc6b5c6e37d326b336daec06a7d2cc90 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 8 Dec 2023 19:29:17 +0100 Subject: [PATCH 5/5] DeprecatedFunctionsUnitTest: remove work-around for PHPCS bug ... as the bug is now fixed. --- WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php index f12b805780..b3e66f34b0 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php @@ -76,11 +76,6 @@ public function getErrorList() { $errors[361] ); - // Temporarily until PHPCS supports PHP 8.2. - if ( \PHP_VERSION_ID >= 80200 ) { - unset( $errors[360] ); // Function call to readonly. - } - return $errors; }