Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for new releases PHPCompatibility and WPCS #81

Merged
merged 4 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor/
composer.lock
45 changes: 26 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ language:
dist: trusty

cache:
apt: true
apt: true
directories:
# Cache directory for older Composer versions.
- $HOME/.composer/cache/files
# Cache directory for more recent Composer versions.
- $HOME/.cache/composer/files

php:
- 5.4
Expand All @@ -19,16 +24,16 @@ php:

env:
# Test against the highest supported PHPCS version.
- PHPCS_BRANCH=master PHPLINT=1
- PHPCS_BRANCH="dev-master" PHPLINT=1
# Test against the lowest supported PHPCS version.
- PHPCS_BRANCH=3.3.0
- PHPCS_BRANCH="3.3.0"

matrix:
fast_finish: true
include:
# Extra build to check for XML codestyle.
- php: 7.1
env: PHPCS_BRANCH=master SNIFF=1
env: PHPCS_BRANCH="dev-master" SNIFF=1
addons:
apt:
packages:
Expand All @@ -44,23 +49,25 @@ before_install:
# https://twitter.com/kelunik/status/954242454676475904
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
- export XMLLINT_INDENT=" "
- export PHPCS_DIR=/tmp/phpcs
- export PHPCS_BIN=$PHPCS_DIR/bin/phpcs
- export WPCS_DIR=/tmp/wpcs
- export PHPCOMPAT_DIR=/tmp/phpcompatibility
- 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)
# Install WordPress Coding Standards.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $WPCS_DIR; fi
# Install PHP Compatibility sniffs.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $PHPCOMPAT_DIR; fi
# Set install path for PHPCS sniffs.
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_BIN --config-set installed_paths $(pwd),$WPCS_DIR,$PHPCOMPAT_DIR; fi
# After CodeSniffer install you should refresh your path.
- phpenv rehash
- export PHPCS_DIR=$(pwd)/vendor/squizlabs/php_codesniffer
- export PHPCS_BIN=$(pwd)/vendor/bin/phpcs
# Set the PHPCS version to test against.
- composer require squizlabs/php_codesniffer:${PHPCS_BRANCH} --no-update --no-suggest --no-scripts
- |
if [[ "$SNIFF" == "1" ]]; then
composer install --dev --no-suggest
# The post-install-cmd script takes care of the installed_paths.
else
# For testing the YoastCS native sniffs, the rest of the packages aren't needed.
composer remove wp-coding-standards/wpcs phpcompatibility/phpcompatibility-wp phpmd/phpmd --no-update
# This will now only install the version of PHPCS to test against.
composer install --no-dev --no-suggest --no-scripts
# Set the installed_paths for the test environment.
$PHPCS_BIN --config-set installed_paths $(pwd)
fi

script:
- if [[ "$PHPLINT" == "1" ]]; then if find . -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
- if [[ "$PHPLINT" == "1" ]]; then if find . -path ./vendor -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
- phpunit --filter Yoast --bootstrap="$PHPCS_DIR/tests/bootstrap.php" $PHPCS_DIR/tests/AllTests.php
# Check the codestyle of the files within YoastCS.
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_BIN --runtime-set ignore_warnings_on_exit 1; fi
Expand Down
35 changes: 2 additions & 33 deletions Yoast/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,10 @@
<!--
#############################################################################
SNIFF FOR PHP CROSS-VERSION COMPATIBILITY
Exclude a few select errorcodes for things back-filled by WP Core.
#############################################################################
-->
<config name="testVersion" value="5.2-99.0"/>
<rule ref="PHPCompatibility">
<!-- Whitelist PHP native classes, interfaces, functions and constants which
are back-filled by WP.

Based on:
* /wp-includes/compat.php
* /wp-includes/random_compat/random.php
-->
<exclude name="PHPCompatibility.PHP.NewClasses.errorFound"/>
<exclude name="PHPCompatibility.PHP.NewClasses.typeerrorFound"/>

<exclude name="PHPCompatibility.PHP.NewConstants.json_pretty_printFound"/>
<exclude name="PHPCompatibility.PHP.NewConstants.php_version_idFound"/>

<exclude name="PHPCompatibility.PHP.NewFunctions.hash_equalsFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.json_last_error_msgFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.random_intFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.random_bytesFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound"/>

<exclude name="PHPCompatibility.PHP.NewInterfaces.jsonserializableFound"/>
</rule>

<!-- Whitelist the WP Core mysql_to_rfc3339() function. -->
<rule ref="PHPCompatibility.PHP.RemovedExtensions">
<properties>
<property name="functionWhitelist" type="array">
<element value="mysql_to_rfc3339"/>
</property>
</properties>
</rule>
<config name="testVersion" value="5.2-"/>
<rule ref="PHPCompatibilityWP"/>


<!--
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@
"require": {
"php": ">=5.4",
"squizlabs/php_codesniffer": "^3.3.0",
"wp-coding-standards/wpcs": "~0.14.0",
"wimg/php-compatibility": "^8.1.0",
"wp-coding-standards/wpcs": "^1.0.0",
"phpcompatibility/phpcompatibility-wp": "^1.0.0",
"phpmd/phpmd": "^2.2.3"
},
"require-dev": {
"phpcompatibility/php-compatibility": "^8.2.0"
},
"suggest" : {
"dealerdirect/phpcodesniffer-composer-installer": "This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
},
"scripts": {
"config-set" : [
"\"vendor/bin/phpcs\" --config-set installed_paths ../../..,../../../vendor/wp-coding-standards/wpcs,../../../vendor/wimg/php-compatibility",
"\"vendor/bin/phpcs\" --config-set installed_paths ../../..,../../../vendor/wp-coding-standards/wpcs,../../../vendor/phpcompatibility/php-compatibility,../../../vendor/phpcompatibility/phpcompatibility-wp",
"\"vendor/bin/phpcs\" --config-set default_standard Yoast"
],
"post-install-cmd": "composer config-set",
Expand Down
Loading