Closed
Description
As proposed in this comment #718 (comment), PHPCS 2.x should be dropped by August 31, 2018 at the latest.
That gives other external standards which build onto WPCS a year's time to upgrade their standards.
This issue is intended to document what needs to be done to drop PHPCS 2.x support, based on the PHPCS cross-version implementation as pulled in #1047.
Prerequisite: The minimum supported PHPCS version for WPCS will need to be 3.1.0
or higher.
Sniff files:
- Change namespace from
namespace WordPress...
tonamespace WordPressCS\WordPress
. - Change the
use
statements which refer to PHPCS classes to use the PHPCS 3.x names:// Current: use PHP_CodeSniffer_Sniff as PHPCS_Sniff; use PHP_CodeSniffer_File as File; use PHP_CodeSniffer_Tokens as Tokens; // Should become: use PHP_CodeSniffer\Sniffs\Sniff as PHPCS_Sniff; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Util\Tokens;
Rulesets:
- All: remove the
<autoload>./PHPCSAliases.php</autoload>
statement. -
./WordPress/ruleset.xml
: adjust<ruleset name="WordPress" namespace="WordPress">
to<ruleset name="WordPress" namespace="WordPressCS\WordPress">
- Review which customizations currently done per error code can now be done for the complete sniff in one go. Related Ruleset: maintain compatibility with PHPCS 2.x #1144
- Review other notes in the ruleset about additional customizations / sniff replacements which can be done once the minimum requirement has gone up & action them
Cleanup:
- Remove the
./WordPress/PHPCSAliases.php
file. -
Remove the./phpunit.xml.dist
file. - Remove the
./Test
subdirectory and all the files therein. The bootstraps and the PHPCS 2.x test suite files are no longer needed as long as the minimum PHPCS version goes up to 3.1.0. - Decide whether to keep or remove the
./WordPress/PHPCSHelper.php
file. It might be useful to leave it in place to be used for future PHPCS cross-version compatibility issues. The PHPCS 2.x specific code in the file can be removed.
Build script and config files:
-
.travis.yml
: Remove the PHPCS 2.x specific PHPUnit commands. -
.travis.yml
: Stop testing against PHP 5.3 (not supported by PHPCS 3.x). -
.travis.yml
: Stop testing against PHPCS 2.x branches. -
.travis.yml
: Remove the toggle for thePHPCS_BIN
location. -
.travis.yml
: Limit the downloading of a custom PHPUnit version to HHVM, PHPCS supports PHPUnit 6.x since PHPCS 3.1.0. See Fix travis build: load PHPCS native bootstrap if available and test against PHP 7.2 #1130 -
.travis,yml
: If needed: add the PHPCS native bootstrap to the PHPUnit command and/or thephpunit.xml.dist
file. See Make the unit test suite compatible with PHPUnit v6 squizlabs/PHP_CodeSniffer#1384 - Update the minimum required PHPCS version in the
composer.json
file.
Documentation:
- Readme: update minimum requirements & remove references to PHPCS 2.x.
- Contributing: update the unit test instructions.
- Remove the PHPCS 3 and testing individual sniffs wiki page as it should no longer apply.
Dropping PHP 5.3 support:
- Remove code related to the
short_open_tag
ini setting from theXSS.EscapeOutput
sniff. - Remove the short_open_tag related line from
.travis.yml
. - Remove unit tests work-around for
short_open_tag
ini setting icw PHP 5.3 in theCodeAnalysis.EmptyStatement
,Files.FileName
,WhiteSpace.PrecisionAlignment
sniffs. See PrecisionAlignment: fix various bugs #1273, Improve handling short echo open tag #1274