Skip to content

Commit

Permalink
Composer: add PHPCSUtils and PHPCSExtra as dependencies
Browse files Browse the repository at this point in the history
Composer:
* Add PHPCSUtils and PHPCSExtra as dependencies.
* Remove the DealerDirect plugin from `require-dev` as well as from `suggests` as it comes with PHPCSUtils/PHPCSExtra automatically and not having it here may prevent conflicts with allowed versions in the future.

Travis:
* Alias PHPCS 4.x to `3.9.99` to allow testing with the dependencies before PHPCS 4.x is officially supported by them.
* When testing with PHPCS 4.x, we need `--prefer-source` as otherwise the test files we use from PHPCS itself won't be included.
    The way I've implemented this uses a [new feature](composer/composer#6301) which is available since Composer 1.10.0 to selectively download from source.
    This prevents *all* packages being downloaded from source for the PHPCS `4.x` build, which would slow down the build and negate the Travis caching.

Note: the install/upgrade instructions in the Readme and other documentation will be addressed in a separate PR late in the 3.0 cycle, so as not to confuse people using the latest release, while 3.0.0 development is ongoing.
  • Loading branch information
jrfnl committed Jun 30, 2020
1 parent 6275522 commit f73d151
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ jobs:
# Add extra build to test against PHPCS 4.
- stage: test
php: 7.4
env: PHPCS_BRANCH="4.0.x-dev"
env: PHPCS_BRANCH="4.0.x-dev as 3.9.99"

allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
- env: PHPCS_BRANCH="4.0.x-dev"
- env: PHPCS_BRANCH="4.0.x-dev as 3.9.99"

before_install:
# Speed up build time by disabling Xdebug.
Expand All @@ -147,21 +147,23 @@ before_install:
- export XMLLINT_INDENT=" "
- export PHPUNIT_DIR=/tmp/phpunit

- |
if [[ $TRAVIS_PHP_VERSION == "nightly" || $PHPCS_BRANCH == "4.0.x-dev" ]]; then
# Even though we're not doing a dev install, dev requirements are still checked.
# Neither the PHPCS Composer plugin nor PHPCompatibility allows yet for PHPCS 4.x.
# The Composer plugin also doesn't allow for installation on PHP 8.x/nightly.
composer remove --dev dealerdirect/phpcodesniffer-composer-installer phpcompatibility/php-compatibility --no-update --no-scripts
if [[ ${PHPCS_BRANCH:0:2} == "4." ]]; then
# Set Composer up to download only PHPCS from source for PHPCS 4.x.
# The source is needed to get the base testcase from PHPCS.
composer config preferred-install.squizlabs/php_codesniffer source
else
composer config preferred-install.squizlabs/php_codesniffer auto
fi
- composer require squizlabs/php_codesniffer:${PHPCS_BRANCH} --update-no-dev --no-suggest --no-scripts
- composer require squizlabs/php_codesniffer:"${PHPCS_BRANCH}" --update-no-dev --no-suggest --no-scripts
- |
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
# The above require already does the install.
$(pwd)/vendor/bin/phpcs --config-set installed_paths $(pwd)
composer install-codestandards
fi
# Download PHPUnit 7.x for builds on PHP >= 7.2 as the PHPCS
# test suite is currently not compatible with PHPUnit 8.x.
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
],
"require": {
"php": ">=5.4",
"squizlabs/php_codesniffer": "^3.5.0"
"squizlabs/php_codesniffer": "^3.5.0",
"phpcsstandards/phpcsutils": "^1.0",
"phpcsstandards/phpcsextra": "^1.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
"phpcompatibility/php-compatibility": "^9.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0",
"phpcsstandards/phpcsdevtools": "^1.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
},
"minimum-stability": "RC",
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"check-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"
Expand Down

0 comments on commit f73d151

Please sign in to comment.