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

Release version 2.2.0 #1828

Merged
merged 122 commits into from Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
0c7aff0
Travis: run the code style related and ruleset checks in separate stages
jrfnl May 22, 2019
fc44f79
Update .travis.yml
ntwb May 22, 2019
3b57ee0
Travis: run the code style related and ruleset checks in separate sta…
GaryJones May 22, 2019
c6cb5c8
ValidHookName: bug fix / skip over array keys
jrfnl May 22, 2019
ea20e20
Sniff::$sanitizingFunctions: Add wp_sanitize_redirect (#1716)
losnappas Jun 1, 2019
744b379
Merge pull request #1712 from WordPress-Coding-Standards/feature/vali…
GaryJones Jun 3, 2019
1418e16
Add RECOVERY_MODE_COOKIE to whitelisted core constants
ocean90 Jun 4, 2019
d202e46
Merge pull request #1718 from ocean90/patch-1
jrfnl Jun 5, 2019
dd25d8a
Composer: Update repo URL references
GaryJones Jun 26, 2019
7f2f7fe
Composer: Update repo URL references (#1751)
ntwb Jun 27, 2019
c3bdb1d
Travis: add "quicktest" stage for non-PR/merge builds
jrfnl Jun 27, 2019
da20950
Merge pull request #1753 from WordPress/feature/travis-add-quick-buil…
jrfnl Jun 27, 2019
d0b9d93
RestrictedPHPFunctions: add error for use of date()
jrfnl May 28, 2019
20c735a
Merge pull request #1714 from WordPress/feature/1713-restrictedphpfun…
GaryJones Jun 27, 2019
ce7e4a7
Add `$plugin` to the list of global variables that shouldn't be overr…
johnbillion Jun 27, 2019
d50ee58
New error handling Deprecated Classes, Functions, Parameters and Para…
fkeijzer Jun 20, 2019
fab1ed5
Documentation: Update all links to the repository (#1748)
dingo-d Jul 1, 2019
6994433
Merge pull request #1754 from johnbillion/fix/global-plugin
jrfnl Jul 1, 2019
0af5b18
Added remaining plugin load globals
Rarst Jul 2, 2019
9784d0d
Merge pull request #1755 from Rarst/patch-1
jrfnl Jul 2, 2019
8d861ab
WordPress ruleset: efficiency fix
jrfnl Jul 4, 2019
173fdd6
Merge pull request #1758 from WordPress/feature/wp-ruleset-efficiency…
dingo-d Jul 5, 2019
bf3ef48
Docs/WordPress.WhiteSpace.CastStructureSpacing (#1738)
ckanitz Jul 5, 2019
d00b44b
Docs/WordPress.WhiteSpace.PrecisionAlignment (#1725)
ckanitz Jul 5, 2019
d8baf91
Fixes #1733 - Error on short prefixes
NielsdeBlaauw Jul 16, 2019
c8c576e
Adds fallback for sniff when iconv is not available
NielsdeBlaauw Jul 16, 2019
13a8bc1
Docs/WordPress.WhiteSpace.DisallowInlineTabs (#1735)
ckanitz Jul 18, 2019
42332cc
CastStructureSpacing: allow for no whitespace before a cast when used…
jrfnl Jul 20, 2019
acbeee6
:sparkles: New DisallowShortTernary sniff
jrfnl Jul 20, 2019
fd0a1a2
Core: Add upstream Generic.Arrays.DisallowShortArraySyntax sniff
jrfnl Jul 20, 2019
80e82a2
Merge pull request #1770 from WordPress/feature/add-disallow-short-ar…
dingo-d Jul 21, 2019
4011319
Merge pull request #1768 from WordPress/feature/new-disallow-short-te…
dingo-d Jul 21, 2019
5fe9561
PHP 7.4 compatibility / defensive coding
jrfnl Jul 21, 2019
096f0cd
GlobalVariablesOverride/PrefixAllGlobals: handle WP variables intende…
jrfnl Jul 23, 2019
47eddc7
EscapeOutput: improve the error message for non-escaped variables
jrfnl Jul 23, 2019
e65086e
Merge pull request #1776 from WordPress/feature/escape-output-improve…
dingo-d Jul 23, 2019
89c2154
Merge pull request #1773 from WordPress/feature/globalvars-prefixallg…
dingo-d Jul 23, 2019
620adf2
:sparkles: New CodeAnalysis/EscapedNotTranslated sniff
jrfnl Jul 24, 2019
6aab357
Merge pull request #1772 from WordPress/feature/php-7.4-compatibility
dingo-d Jul 25, 2019
d3586ff
Merge pull request #1777 from WordPress/feature/new-codeanalysis-esca…
dingo-d Jul 25, 2019
6004e4b
ArrayKeySpacingRestrictions: check the size of the space on the insid…
jrfnl Jul 27, 2019
23a17dc
ArrayKeySpacingRestrictions: fix whitespace violations in one go
jrfnl Jul 27, 2019
d171c8d
CastStructureSpacing: allow for spread operator (#1767)
GaryJones Jul 27, 2019
3503cfc
ArrayKeySpacingRestrictions: add space size check & fix errors… (#1779)
GaryJones Jul 27, 2019
c21ccff
Travis: ignore PHP deprecation notices for stable PHPCS releases
jrfnl Jul 21, 2019
bc24df5
Sniff: Add new `is_short_list()` utility method
jrfnl Jul 27, 2019
ab53976
Array sniffs: ignore short lists
jrfnl Jul 27, 2019
d6050e8
Merge pull request #1780 from WordPress/feature/1692-array-sniffs-sho…
dingo-d Jul 28, 2019
727fce4
Merge pull request #1781 from WordPress/feature/travis-ignore-depreca…
dingo-d Jul 28, 2019
a699e0d
Sniff: add new `find_list_open_close()` utility method
jrfnl Jul 27, 2019
f30b102
Sniff::find_array_open_close(): minor tweak
jrfnl Jul 27, 2019
c2bae67
Sniff: add new `get_list_variables()` utility method
jrfnl Jul 27, 2019
bd16416
PrefixAllGlobals: detect non-prefixed variables in list assignments
jrfnl Jul 27, 2019
f47cf7b
GlobalVariablesOverride: detect global variable overrides in list ass…
jrfnl Jul 27, 2019
5853302
Various minor doc fixes
jrfnl May 18, 2019
d2ef2b5
Various minor doc fixes (#1784)
ntwb Jul 29, 2019
b56232b
Merge pull request #1783 from WordPress/feature/1774-globalvarsoverri…
dingo-d Jul 30, 2019
605d2f7
Deletes duplicate code and removes incorrect second parameter strlen
NielsdeBlaauw Jul 31, 2019
e22e842
Merge pull request #1741 from NielsdeBlaauw/1733-short-prefixes-error
jrfnl Jul 31, 2019
d17d268
PrefixAllGlobals: add "php" to the list of blacklisted prefixes
jrfnl Jul 31, 2019
45ecdf0
Merge pull request #1785 from WordPress/feature/1728-prefixallglobals…
dingo-d Aug 1, 2019
2f8089f
EscapeOutput: add highlight_string() to escaping functions
jrfnl Aug 1, 2019
a8ad671
EscapeOutput: add sanitize_key() to escaping functions
jrfnl Aug 1, 2019
30aef1d
EscapeOutput: add sanitize_key() to escaping functions (#1786)
GaryJones Aug 1, 2019
3d80421
EscapeOutput: use Sniff::$safe_casts
jrfnl Aug 4, 2019
05c0ee4
Merge pull request #1788 from WordPress/feature/escapeoutput-minor-cl…
dingo-d Aug 5, 2019
06966b2
EscapeOutput: add highlight_string() to escaping functions (#1787)
GaryJones Aug 6, 2019
10d727a
Fixed minor grammar issue
dingo-d Sep 8, 2019
ecb633d
Merge pull request #1793 from WordPress/feature/minor-comment-fix
jrfnl Sep 9, 2019
75993cc
AlternativeFunctions: add extra unit test
jrfnl Sep 11, 2019
9c506d6
AlternativeFunctions: add extra unit test (#1795)
GaryJones Sep 12, 2019
9a89756
YodaConditions: minor efficiency fix
jrfnl Sep 19, 2019
2f396d1
Merge pull request #1799 from WordPress/feature/yodaconditions-minor-…
dingo-d Sep 20, 2019
dda05c1
Docs/Deprecated WP: various minor fixes to the XML docs
jrfnl Sep 20, 2019
54f1017
DisallowShortTernary: improve docs
jrfnl Sep 20, 2019
6aec321
Documentation Class Instantiation
Sep 20, 2019
81a7fb2
New error handling Deprecated Classes and Functions (#1729)
GaryJones Sep 22, 2019
484335b
DisallowShortTernary: improve docs (#1800)
GaryJones Sep 22, 2019
aecdaa7
Proccessed feedback from jrfnl
Sep 27, 2019
0d2f984
Merge pull request #1801 from FORTE-WP/temp1
jrfnl Sep 28, 2019
85f3016
CapitalPDangit: minor tweak
jrfnl Oct 3, 2019
1ec0770
Merge pull request #1804 from WordPress/feature/capitalpdangit-minor-…
dingo-d Oct 3, 2019
28bc144
Sniff: add new `is_function_deprecated()` utility function
jrfnl Oct 4, 2019
6226cdc
ValidFunctionName: ignore deprecated functions
jrfnl Oct 4, 2019
d5640f8
PrefixAllGlobals: ignore deprecated functions
jrfnl Oct 4, 2019
e7bfc16
Merge pull request #1806 from WordPress/feature/1797-ignore-deprecate…
dingo-d Oct 4, 2019
b5f989d
DeprecatedClasses: update the sniff
jrfnl Oct 7, 2019
313ddea
Merge pull request #1809 from WordPress/feature/deprecatedclasses-upd…
dingo-d Oct 7, 2019
e38cee8
Docs/WordPress.Arrays.ArrayIndentation (#1744)
Mike-Hermans Oct 13, 2019
058be1b
Docs/ArrayKeySpacingRestrictions and Array.MultipleStatementAlignment…
Mike-Hermans Oct 13, 2019
5c82777
DeprecatedFunctions: update function list
jrfnl Oct 14, 2019
0e88b83
ValidHookName: minor efficiency tweaks
jrfnl Oct 22, 2019
62d9924
ValidHookName: add documentation
jrfnl Oct 23, 2019
7947bce
New "DateTime.RestrictedFunctions" sniff
jrfnl Oct 5, 2019
d803011
Merge pull request #1810 from WordPress/feature/update-deprecated-fun…
dingo-d Oct 24, 2019
864e4fd
EscapeOutput: allow for typical pattern with `_deprecated_file()`
jrfnl Oct 24, 2019
1563450
ValidHookName: minor efficiency tweaks (#1815)
GaryJones Oct 27, 2019
fcaf02b
ValidHookName: add documentation (#1817)
GaryJones Oct 27, 2019
619ced0
New "DateTime.RestrictedFunctions" sniff (#1807)
GaryJones Oct 27, 2019
3b204a6
Merge pull request #1818 from WordPress/feature/escapeoutput-toleranc…
dingo-d Oct 27, 2019
e4f838c
:sparkles: New DateTime.CurrentTimeTimestamp sniff
jrfnl Oct 5, 2019
52de928
ValidHookName: improve error messages
jrfnl Oct 28, 2019
ef7f86e
PrefixAllGlobals: minor efficiency tweak
jrfnl Oct 28, 2019
ce79334
Merge pull request #1820 from WordPress/feature/validhookname-improve…
dingo-d Oct 29, 2019
b922e44
Merge pull request #1808 from WordPress/feature/new-currenttime-times…
dingo-d Oct 30, 2019
981b7d4
PrefixAllGlobals: minor efficiency tweak (#1822)
GaryJones Oct 30, 2019
c65d63b
Update default minimum supported WP version
jrfnl Nov 1, 2019
86d7dbc
Adds documentation for WordPress.WP.CronInterval
NielsdeBlaauw Oct 31, 2019
ae449aa
:sparkles: New NamingConventions.ValidPostTypeSlug sniff
NielsdeBlaauw Nov 2, 2019
7a626f3
Merge pull request #1829 from WordPress/feature/update-minimum-wp-ver…
dingo-d Nov 2, 2019
9eeeb6c
Docs: Add PostsPerPage XML doc
GaryJones Nov 4, 2019
5cc744f
Adds documentation for WordPress.WP.CronInterval (#1823)
GaryJones Nov 4, 2019
093a725
Adds WP.Security.SafeRedirect documentation.
NielsdeBlaauw Oct 31, 2019
ed52f7d
Merge pull request #1732 from WordPress/docs/posts-per-page
jrfnl Nov 6, 2019
e7560d1
Ini_set: add documentation (#1730)
NielsdeBlaauw Nov 6, 2019
a2a32d1
Various minor documentation fixes
jrfnl Sep 11, 2019
9bd5f9c
Adds documentation for WordPress.WP.EnqueuedResources.
NielsdeBlaauw Oct 31, 2019
31b8d9b
Various minor documentation fixes (#1831)
GaryJones Nov 7, 2019
e105835
Merge pull request #1824 from NielsdeBlaauw/1722-WordPress.WP.Enqueue…
GaryJones Nov 7, 2019
84033ee
Adds WP.Security.SafeRedirect documentation. (#1826)
GaryJones Nov 7, 2019
e004a3e
Changelog for WPCS 2.2.0
jrfnl Oct 14, 2019
d45f5e5
Merge pull request #1833 from WordPress/feature/changelog-2.2.0
jrfnl Nov 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Expand Up @@ -30,7 +30,7 @@ Once a commit is made to `develop`, a PR should be opened from `develop` into `m
When writing sniffs, always remember that any `public` sniff property can be overruled via a custom ruleset by the end-user.
Only make a property `public` if that is the intended behaviour.

When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch.
When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch.

## Whitelist comments

Expand All @@ -51,7 +51,7 @@ When you introduce new `public` sniff properties, or your sniff extends a class

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

Presuming you have installed `PHP_CodeSniffer` and the WordPress-Coding-Standards as [noted in the README](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#how-to-use-this), all you need now is `PHPUnit`.
Presuming you have installed `PHP_CodeSniffer` and the WordPress-Coding-Standards as [noted in the README](https://github.com/WordPress/WordPress-Coding-Standards#how-to-use-this), all you need now is `PHPUnit`.

> N.B.: If you installed WPCS using Composer, make sure you used `--prefer-source` or run `composer install --prefer-source` now to make sure the unit tests are available.
> Other than that, you're all set already as Composer will have installed PHPUnit for you.
Expand Down
145 changes: 101 additions & 44 deletions .travis.yml
Expand Up @@ -27,16 +27,90 @@ env:
# Lowest supported release in the 3.x series with which WPCS is compatible.
- PHPCS_BRANCH="3.3.1"

matrix:
# Define the stages used.
# For non-PRs, only the sniff, ruleset and quicktest stages are run.
# For pull requests and merges, the full script is run (skipping quicktest).
# Note: for pull requests, "develop" should be the base branch name.
# See: https://docs.travis-ci.com/user/conditions-v1
stages:
- name: sniff
- name: rulesets
- name: quicktest
if: type = push AND branch NOT IN (master, develop)
- name: test
if: branch IN (master, develop)

jobs:
fast_finish: true
include:
# Run PHPCS against WPCS. I just picked to run it against 7.2.
- php: 7.2
env: PHPCS_BRANCH="dev-master" SNIFF=1
#### SNIFF STAGE ####
- stage: sniff
php: 7.3
env: PHPCS_BRANCH="dev-master"
addons:
apt:
packages:
- libxml2-utils
script:
# WordPress Coding Standards.
# @link https://github.com/WordPress/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
- $(pwd)/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1

# Validate the xml files.
# @link http://xmlsoft.org/xmllint.html
# For the build to properly error when validating against a scheme, these each have to be in their own condition.
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample

# Check the code-style consistency of the xml files.
- diff -B --tabsize=4 ./WordPress/ruleset.xml <(xmllint --format "./WordPress/ruleset.xml")
- diff -B --tabsize=4 ./WordPress-Core/ruleset.xml <(xmllint --format "./WordPress-Core/ruleset.xml")
- diff -B --tabsize=4 ./WordPress-Docs/ruleset.xml <(xmllint --format "./WordPress-Docs/ruleset.xml")
- diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml")
- diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample")

#### RULESET STAGE ####
# Make sure the rulesets don't throw unexpected errors or warnings.
# This check needs to be run against a high PHP version to prevent triggering the syntax error check.
# It also needs to be run against all PHPCS versions WPCS is tested against.
- stage: rulesets
php: 7.3
env: PHPCS_BRANCH="dev-master"
script:
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Core
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Docs
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Extra
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress

# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
# For the first run, the exit code will be 1 (= all fixable errors fixed).
# `travis_retry` should then kick in to run the fixer again which should now return 0 (= no fixable errors found).
# All error codes for the PHPCBF: https://github.com/squizlabs/PHP_CodeSniffer/issues/1270#issuecomment-272768413
- travis_retry $(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary

- stage: rulesets
php: 7.3
env: PHPCS_BRANCH="3.3.1"
script:
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Core
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Docs
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress-Extra
- $(pwd)/vendor/bin/phpcs -ps ./bin/class-ruleset-test.php --standard=WordPress

#### QUICK TEST STAGE ####
# This is a much quicker test which only runs the unit tests and linting against the low/high
# supported PHP/PHPCS combinations.
- stage: quicktest
php: 7.3
env: PHPCS_BRANCH="dev-master" LINT=1
- php: 7.3
env: PHPCS_BRANCH="3.3.1"
- php: 5.4
env: PHPCS_BRANCH="dev-master" LINT=1
- php: 5.4
env: PHPCS_BRANCH="3.3.1"

allow_failures:
# Allow failures for unstable builds.
Expand All @@ -47,11 +121,19 @@ before_install:
# https://johnblackbourn.com/reducing-travis-ci-build-times-for-wordpress-projects/
# https://twitter.com/kelunik/status/954242454676475904
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_BRANCH != "dev-master" ]]; then
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi

- export XMLLINT_INDENT=" "
- export PHPUNIT_DIR=/tmp/phpunit
- composer require squizlabs/php_codesniffer:${PHPCS_BRANCH} --update-no-dev --no-suggest --no-scripts
- |
if [[ "$SNIFF" == "1" ]]; then
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Sniff" ]]; then
composer install --dev --no-suggest
# The `dev` required DealerDirect Composer plugin takes care of the installed_paths.
else
Expand All @@ -63,42 +145,17 @@ before_install:
- if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then wget -P $PHPUNIT_DIR https://phar.phpunit.de/phpunit-7.phar && chmod +x $PHPUNIT_DIR/phpunit-7.phar; fi

script:
# Lint the PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -path ./bin -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi
# Run the unit tests.
- |
if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then
php $PHPUNIT_DIR/phpunit-7.phar --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
else
phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
fi
# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
# For the first run, the exit code will be 1 (= all fixable errors fixed).
# `travis_retry` should then kick in to run the fixer again which should now return 0 (= no fixable errors found).
# All error codes for the PHPCBF: https://github.com/squizlabs/PHP_CodeSniffer/issues/1270#issuecomment-272768413
- if [[ "$SNIFF" == "1" ]]; then travis_retry $(pwd)/vendor/bin/phpcbf -p ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary; fi
# Make sure the rulesets don't thrown unexpected errors or warnings.
# This check needs to be run against a high PHP version to prevent triggering the syntax error check.
# It also needs to be run against all PHPCS versions WPCS is tested against.
- if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress-Core; fi
- if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress-Docs; fi
- if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress-Extra; fi
- if [[ $TRAVIS_PHP_VERSION == "7.1" ]]; then $(pwd)/vendor/bin/phpcs -s ./bin/class-ruleset-test.php --standard=WordPress; fi
# 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 $(pwd)/vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1; fi
# Validate the xml files.
# @link http://xmlsoft.org/xmllint.html
- if [[ "$SNIFF" == "1" ]]; then xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml; fi
- if [[ "$SNIFF" == "1" ]]; then xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./phpcs.xml.dist.sample; fi
# Check the code-style consistency of the xml files.
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress/ruleset.xml <(xmllint --format "./WordPress/ruleset.xml"); fi
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Core/ruleset.xml <(xmllint --format "./WordPress-Core/ruleset.xml"); fi
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Docs/ruleset.xml <(xmllint --format "./WordPress-Docs/ruleset.xml"); fi
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./WordPress-Extra/ruleset.xml <(xmllint --format "./WordPress-Extra/ruleset.xml"); fi
- if [[ "$SNIFF" == "1" ]]; then diff -B --tabsize=4 ./phpcs.xml.dist.sample <(xmllint --format "./phpcs.xml.dist.sample"); fi
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- if [[ "$LINT" == "1" ]]; then composer validate --no-check-all --strict; fi
# Lint the PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then if find . -path ./vendor -prune -o -path ./bin -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then exit 1; fi; fi

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- if [[ "$LINT" == "1" ]]; then composer validate --no-check-all --strict; fi

# Run the unit tests.
- |
if [[ ${TRAVIS_PHP_VERSION:0:3} > "7.1" ]]; then
php $PHPUNIT_DIR/phpunit-7.phar --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
else
phpunit --filter WordPress --bootstrap="$(pwd)/vendor/squizlabs/php_codesniffer/tests/bootstrap.php" $(pwd)/vendor/squizlabs/php_codesniffer/tests/AllTests.php
fi