dist: trusty
sudo: false
language: php

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

php:
  - 7.4
  - 7.3
  - 7.2
  - 7.1

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

install:
  - travis_retry composer update --no-interaction --prefer-dist  ${COMPOSER_FLAGS}

script: ./vendor/bin/phpunit

jobs:
  allow_failures:
    - php: nightly

  include:
    - stage: Test
      php: 7.1
      env:
        COMPOSER_FLAGS="--prefer-lowest"

    -   stage: Test
        php: nightly
        before_install:
            - composer config platform.php 7.4.99

    - stage: Coverage
      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 --coverage-clover clover.xml
      after_script:
        - wget https://scrutinizer-ci.com/ocular.phar
        - php ocular.phar code-coverage:upload --format=php-clover clover.xml

    - stage: Coding standard
      script:
        - ./vendor/bin/phpcs

    - stage: Lint
      script: vendor/bin/phpstan analyse
