PHPCS is already installed as a project dependency (we run `composer
install` for each build job) so there is no need to install it as a
global package in `tests/bin/phpcs.sh`.
This is an attempt to fix the PHPCS Travis build job that started
failing with the following error:
```
Running Code Sniffer.
tests/bin/phpcs.sh: line 14: phpcs: command not found
The command "bash tests/bin/phpcs.sh" exited with 127.
```
(https://travis-ci.org/github/woocommerce/woocommerce/jobs/736440739#L508)
Commit d6bd82865c removed apigen from
WooCommerce core repository as we are moving it to its own repository (https://github.com/woocommerce/woocommerce-api-docs). This
commit removes the apigen from configuration files. In most cases, it is
just removing the apigen directory from the exclude list of things like
PHPCS and Code Climate.
PR https://github.com/woocommerce/woocommerce/pull/23082 made some changes to the Travis configuration and one of those changes broke the PHPCS when running inside Travis with the following error:
```
ERROR: Referenced sniff "WooCommerce-Core" does not exist
```
For example: https://travis-ci.org/woocommerce/woocommerce/jobs/509471213#L659
This problem went unnoticed during the PR review as no PHP file was modified in it and thus there was no file for PHPCS to check.
This commit fixes the error above by installing the Composer package `woocommerce/woocommerce-sniffs` which is the package that provides `WooCommerce-Core` sniffs and which installs `wp-coding-standards/wpcs` as one of its requirements. I couldn't find an easy way to make this work installing `woocommerce/woocommerce-sniffs` globally so that is why this commit also removes the `global` parameter when calling composer.
This commit renames PHPCS configutarion file to `phpcs.xml`. With the default name, it is not necessary to use the argument `--standard=phpcs.ruleset.xml` anymore when calling `phpcs`.
PR #17680 added a new PHP 7.1 Travis build job to generate code coverage report. PHPCS was configured to run on all PHP 7.1 build jobs. So this means that after #17680 was merged, Travis started running PHPCS twice.
This commit fixes this issue by setting a new environment variable called `$RUN_PHPCS` and using this variable, instead of the PHP version, to decide when to run PHPCS.