Skip to content

Commit 44f3abb

Browse files
authored
Merge pull request #2408 from WordPress/feature/switch-to-fork-of-phpcs
Switch to PHPCSStandards/PHP_CodeSniffer & raise minimum supported version
2 parents a521f60 + 105a10c commit 44f3abb

16 files changed

+32
-37
lines changed

.github/CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Bug reports containing a minimal code sample which can be used to reproduce the
1414
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.
1515
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.
1616

17-
* 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).
17+
* 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).
1818
* Bugs for sniffs starting with `Modernize`, `NormalizedArrays` or `Universal` should be [reported to PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues).
1919

2020
# Contributing patches and new features
@@ -39,9 +39,9 @@ When you introduce new `public` sniff properties, or your sniff extends a class
3939

4040
## Pre-requisites
4141
* WordPress-Coding-Standards
42-
* PHP_CodeSniffer 3.7.2 or higher
43-
* PHPCSUtils 1.0.8 or higher
44-
* PHPCSExtra 1.2.0 or higher
42+
* PHP_CodeSniffer 3.8.0 or higher
43+
* PHPCSUtils 1.0.9 or higher
44+
* PHPCSExtra 1.2.1 or higher
4545
* PHPUnit 4.x, 5.x, 6.x or 7.x
4646

4747
The WordPress Coding Standards use the `PHP_CodeSniffer` native unit test framework for unit testing the sniffs.

.github/release-checklist.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PR for tracking changes for the x.x.x release. Target release date: **DOW MONTH
6464
- [ ] Submit for ["Month in WordPress"][month-in-wp].
6565
- [ ] Submit for the ["Monthy Dev Roundup"][dev-roundup].
6666

67-
[phpcs-releases]: https://github.com/squizlabs/PHP_CodeSniffer/releases
67+
[phpcs-releases]: https://github.com/PHPCSStandards/PHP_CodeSniffer/releases
6868
[phpcsutils-releases]: https://github.com/PHPCSStandards/PHPCSUtils/releases
6969
[phpcsextra-releases]: https://github.com/PHPCSStandards/PHPCSExtra/releases
7070
[month-in-wp]: https://make.wordpress.org/community/month-in-wordpress-submissions/

.phpcs.xml.dist

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
33

44
<description>The Coding standard for the WordPress Coding Standards itself.</description>
55

66
<!--
77
#############################################################################
88
COMMAND LINE ARGUMENTS
9-
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
9+
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
1010
#############################################################################
1111
-->
1212

CHANGELOG.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ In all cases, please read the complete changelog carefully before you upgrade.
9797
- The `sanitize_url()` and `wp_kses_one_attr()` functions to the list of known "sanitizing" functions.
9898
- 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`.
9999
- 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]).
100-
This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage).
100+
This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage).
101101
Note: all sniffs which have been added from PHPCSExtra (Universal, Modernize, NormalizedArrays sniffs) are also fully documented.
102102

103103
#### Added (internal/dev-only)
@@ -454,7 +454,7 @@ The move does not affect the package name for Packagist. This remains the same:
454454
- `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.
455455
- `Sniff::is_function_deprecated()` static utility method to determine whether a declared function has been marked as deprecated in the function DocBlock.
456456
- 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`.
457-
This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage).
457+
This documentation can be exposed via the [`PHP_CodeSniffer` `--generator=...` command-line argument](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage).
458458

459459
### Changed
460460
- 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
661661
- `WordPress.NamingConventions.ValidVariableName`: Added unit tests confirming support for multi-variable/property declarations.
662662
- 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.
663663
- The rulesets are now validated against the `PHP_CodeSniffer` XSD schema.
664-
- 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.
664+
- 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.
665665
- 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.
666666
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.
667667
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
672672
### Deprecated
673673
- 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.
674674
The WordPressCS native whitelist comments will continue to work for now, but a deprecation warning will be thrown when they are encountered.
675-
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.
675+
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.
676676

677677
### Removed
678678
- 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
684684
- Support for array properties set in a custom ruleset without the `type="array"` attribute.
685685
Support for this was deprecated in WPCS 1.0.0.
686686
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.
687-
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.
687+
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.
688688
Note: the ability to set select properties from the command-line as comma-delimited strings is _not_ affected by this change.
689689
- The following sniffs have been removed outright without deprecation.
690690
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
985985

986986
### Fixed
987987
- 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.
988-
- Compatibility with the latest releases from [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
988+
- Compatibility with the latest releases from [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer).
989989
PHPCS 3.2.0 introduced new annotations which can be used inline to selectively disable/ignore certain sniffs.
990990
**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.
991-
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).
991+
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).
992992
- 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.
993993
- `WordPress.Arrays.ArrayDeclarationSpacing`: the fixer will now handle the new style annotations correctly.
994994
- `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
12211221

12221222
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:
12231223
* [WPCS customizable sniff properties](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties)
1224-
* [PHPCS customizable sniff properties](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties)
1224+
* [PHPCS customizable sniff properties](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties)
12251225

12261226
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).
12271227

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
## Introduction
4848

49-
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/).
49+
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/).
5050

5151
This project needs funding. [Find out how you can help](#funding).
5252

@@ -133,7 +133,7 @@ If you need to further customize the selection of sniffs for your project - you
133133

134134
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.
135135

136-
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.
136+
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.
137137

138138
### Customizing sniff behaviour
139139

@@ -143,7 +143,7 @@ You can find a complete list of all the properties you can change for the WordPr
143143

144144
WordPressCS also uses sniffs from PHPCSExtra and from PHP_CodeSniffer itself.
145145
The [README for PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra) contains information on the properties which can be set for the sniff from PHPCSExtra.
146-
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).
146+
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).
147147

148148

149149
### Recommended additional rulesets

WordPress-Core/ruleset.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Core" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Core" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
33

44
<description>Non-controversial generally-agreed upon WordPress Coding Standards</description>
55

WordPress-Docs/ruleset.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Docs" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Docs" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
33

44
<description>WordPress Coding Standards for Inline Documentation and Comments</description>
55

WordPress-Extra/ruleset.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Extra" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Extra" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
33

44
<description>Best practices beyond core WordPress Coding Standards</description>
55

WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @since 2.0.0 Now offers name suggestions for variables in violation.
3030
*
3131
* Last synced with base class January 2022 at commit 4b49a952bf0e2c3863d0a113256bae0d7fe63d52.
32-
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php
32+
* @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php
3333
*/
3434
final class ValidVariableNameSniff extends PHPCS_AbstractVariableSniff {
3535

WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Last synced with base class 2021-11-20 at commit 7f11ffc8222b123c06345afd3261221561c3bb29.
2727
* Note: This class has diverged quite far from the original. All the same, checking occasionally
2828
* to see if there are upstream fixes made from which this sniff can benefit, is warranted.
29-
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
29+
* @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php
3030
*/
3131
final class ControlStructureSpacingSniff extends Sniff {
3232

WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* - When the `::` operator is used in `::class`, no new line(s) before or after the object operator are allowed.
2121
*
2222
* @since 3.0.0
23-
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php
23+
* @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php
2424
*/
2525
final class ObjectOperatorSpacingSniff extends Squiz_ObjectOperatorSpacingSniff {
2626

WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @since 0.13.0 Class name changed: this class is now namespaced.
3232
*
3333
* Last verified with base class June 2023 at commit 085b1e091b0f2e451333c0bc26dd50bba39402c4.
34-
* @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
34+
* @link https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
3535
*/
3636
final class OperatorSpacingSniff extends PHPCS_Squiz_OperatorSpacingSniff {
3737

WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ public function getErrorList() {
7676
$errors[361]
7777
);
7878

79-
// Temporarily until PHPCS supports PHP 8.2.
80-
if ( \PHP_VERSION_ID >= 80200 ) {
81-
unset( $errors[360] ); // Function call to readonly.
82-
}
83-
8479
return $errors;
8580
}
8681

0 commit comments

Comments
 (0)