From 3dcae20f2a3869e2fb82bbae3e87f92c51025766 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 1 Mar 2018 07:44:16 +0100 Subject: [PATCH 1/4] Build: move WPCS's own ruleset to the root directory This file was initially placed in the `bin` directory so as not to confuse users looking for the example custom ruleset. By renaming the file to `.phpcs.xml.dist` - take note of the `.` -, which is possible since PHPCS 3.1, the file is no longer listed directly next to the example ruleset, so it should be fine to move it to the repo root directory. --- .gitattributes | 1 + .github/CONTRIBUTING.md | 2 +- .gitignore | 2 ++ bin/phpcs.xml => .phpcs.xml.dist | 0 4 files changed, 4 insertions(+), 1 deletion(-) rename bin/phpcs.xml => .phpcs.xml.dist (100%) diff --git a/.gitattributes b/.gitattributes index 3fb449f721..5e6e2b7903 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,7 @@ # https://blog.madewithlove.be/post/gitattributes/ # /.travis.yml export-ignore +/.phpcs.xml.dist export-ignore /phpunit.xml.dist export-ignore /.github export-ignore /bin export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 21ad809e3d..487b82da02 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -207,4 +207,4 @@ The `--sniffs=...` directive limits the output to the sniff you are testing. ## Code Standards for this project -The sniffs and test files - not test _case_ files! - for WPCS should be written such that they pass the `WordPress-Extra` and the `WordPress-Docs` code standards using the custom ruleset as found in `/bin/phpcs.xml`. +The sniffs and test files - not test _case_ files! - for WPCS should be written such that they pass the `WordPress-Extra` and the `WordPress-Docs` code standards using the custom ruleset as found in `/.phpcs.xml.dist`. diff --git a/.gitignore b/.gitignore index 1950124e77..0bf0382966 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ vendor composer.lock phpunit.xml +phpcs.xml +.phpcs.xml diff --git a/bin/phpcs.xml b/.phpcs.xml.dist similarity index 100% rename from bin/phpcs.xml rename to .phpcs.xml.dist From 04db118741e6312f6983aa25518801b2124ffeed Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 1 Mar 2018 07:46:40 +0100 Subject: [PATCH 2/4] Build/PHPCS: add the `` directive As the WPCS own ruleset is now in the root directory, we can add the `` directive. This allows: - devs to run the CS check locally without command-line arguments - Travis to run with less command-line arguments. --- .phpcs.xml.dist | 2 ++ .travis.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 89152ebfee..256d8a4221 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -2,6 +2,8 @@ The Coding standard for the WordPress Coding Standards itself. + . + diff --git a/.travis.yml b/.travis.yml index b17ee9e0f6..f9802535b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,7 +90,7 @@ script: # WordPress Coding Standards. # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards # @link http://pear.php.net/package/PHP_CodeSniffer/ - - if [[ "$SNIFF" == "1" ]]; then $PHPCS_BIN . --standard=./bin/phpcs.xml --runtime-set ignore_warnings_on_exit 1; fi + - if [[ "$SNIFF" == "1" ]]; then $PHPCS_BIN --runtime-set ignore_warnings_on_exit 1; fi # Validate the xml files. # @link http://xmlsoft.org/xmllint.html - if [[ "$SNIFF" == "1" ]]; then xmllint --noout ./*/ruleset.xml; fi From 7546c988104b964d10d36a607e1326587aa1e0a8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 1 Mar 2018 07:47:32 +0100 Subject: [PATCH 3/4] Build/PHPCS: run PHPCS against the highest stable PHP version ... for optimal results from the tokenizer. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9802535b6..423f0a96fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,8 @@ env: matrix: fast_finish: true include: - # Run PHPCS against WPCS. I just picked to run it against 7.0. - - php: 7.0 + # Run PHPCS against WPCS. I just picked to run it against 7.2. + - php: 7.2 env: PHPCS_BRANCH=master SNIFF=1 addons: apt: From 760bbbbd9d9487d1601524928cced756affcb315 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 1 Mar 2018 07:47:57 +0100 Subject: [PATCH 4/4] Build/Travis: drop support for HHVM --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 423f0a96fd..a30b3ec6b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,13 +34,6 @@ matrix: packages: - libxml2-utils - # Run against HHVM. - - php: hhvm - sudo: required - dist: trusty - group: edge - env: PHPCS_BRANCH=master LINT=1 - # Test PHP 5.3 only against PHPCS 2.x as PHPCS 3.x has a minimum requirement of PHP 5.4. - php: 5.3 env: PHPCS_BRANCH=2.9 LINT=1 @@ -53,7 +46,6 @@ matrix: allow_failures: # Allow failures for unstable builds. - php: nightly - - php: hhvm before_install: # Speed up build time by disabling Xdebug. @@ -66,9 +58,9 @@ before_install: - export PHPCS_BIN=$(if [[ $PHPCS_BRANCH == master ]]; then echo $PHPCS_DIR/bin/phpcs; else echo $PHPCS_DIR/scripts/phpcs; fi) - mkdir -p $PHPCS_DIR && git clone --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git -b $PHPCS_BRANCH $PHPCS_DIR - $PHPCS_BIN --config-set installed_paths $(pwd) - # Download PHPUnit 5.x for builds on PHP 7, nightly and HHVM as the PHPCS + # Download PHPUnit 5.x for builds on PHP 7 and nightly as the PHPCS # test suite is currently not compatible with PHPUnit 6.x. - # Fixed at a very specific PHPUnit version which is also compatible with HHVM. + # Fixed at a very specific PHPUnit version. - if [[ ${TRAVIS_PHP_VERSION:0:2} != "5." ]]; then wget -P $PHPUNIT_DIR https://phar.phpunit.de/phpunit-5.7.17.phar && chmod +x $PHPUNIT_DIR/phpunit-5.7.17.phar; fi # Selectively adjust the ini values for the build image to test ini value dependent sniff features. - if [[ "$SHORT_OPEN_TAGS" == "true" ]]; then echo "short_open_tag = On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi