dist: trusty
sudo: false
language: php

php:
  - 7.1
  - 7.2
  - 7.3
  - 7.4snapshot

before_install:
  - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
  - travis_retry composer self-update

install:
  - rm composer.lock
  - travis_retry composer update --prefer-dist

script:
  - ./vendor/bin/phpunit -v

jobs:
  include:
    - stage: Test
      env: COVERAGE
      php: 7.1
      before_script:
        - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
        - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
      script:
        - ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml
      after_script:
        - travis_retry wget https://scrutinizer-ci.com/ocular.phar
        - travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

    - stage: Code Quality
      env: CODING_STANDARDS
      php: 7.1
      install: travis_retry composer install --prefer-dist
      script: ./vendor/bin/phpcs

    - stage: Code Quality
      env: STATIC_ANALYSIS
      php: 7.1
      install: travis_retry composer install --prefer-dist
      script:
        - ./vendor/bin/phpstan analyse

    - stage: Code Quality
      env: BENCHMARK
      php: 7.1
      install: travis_retry composer install --prefer-dist
      script: php -n ./vendor/bin/phpbench run --iterations=3 --warmup=1 --report=aggregate

cache:
  directories:
    - $HOME/.composer/cache
