language: php

dist: trusty 
php:
    - 5.6
    - 7.0
    - 7.1
    - nightly
    - hhvm

dist: trusty 

env:
    # The default env behaviour: phpunit, no coverage, no style checks
  - PHPUNIT=true

matrix:
  fast_finish: true

  exclude:
      # Disable phpunit test on 5.6, reenable with COVERAGE
    - php: 5.6
      env: PHPUNIT=true

  include:
      # This reenables php5.6/phpunit test with COVERAGE
    - php: 5.6
      env: PHPUNIT=true COVERAGE_SHARDS=10 COVERAGE=true

      # This runs phpcs on php7.0 - only code style
    - php: 5.6
      env: CODESTYLE=true

sudo: false

before_script:
    - travis_retry composer selfupdate
    - travis_retry composer install --prefer-source
    - if [ "${COVERAGE}" != "true" ]; then phpenv config-rm xdebug.ini && echo "xdebug disabled" || exit 0; fi

script:
    - if [ "${PHPUNIT}" = "true" ]; then vendor/bin/phpunit --coverage-text --coverage-clover=tests/output/coverage.clover; fi

after_success:
    - wget https://scrutinizer-ci.com/ocular.phar
    - if [ "${COVERAGE}" = "true" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;
