language: php

git:
  depth: 1

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

env:
  global:
    - COMPOSER_ALLOW_XDEBUG=0
    - SYMFONY_DEPRECATIONS_HELPER='weak_vendors'

matrix:
  include:
    # Latest dependencies with all PHP versions
    - php: 5.6
    - php: 7.0
    - php: 7.1
    - php: 7.2
    - php: 7.3

    # Ignore the platform requirements for the upcoming PHP version
    - php: nightly
      env: COMPOSER_FLAGS='--ignore-platform-reqs'

    # Generate the coverage with the latest PHP version
    - php: 7.3
      env: COVERAGE='--coverage-clover build/logs/clover.xml'

    # Lowest dependencies with the oldest and latest PHP versions
    - php: 5.6
      env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
    - php: 7.3
      env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
  allow_failures:
    - php: nightly
  fast_finish: true

before_install:
  - if [[ ! $COVERAGE ]]; then phpenv config-rm xdebug.ini || true; fi

install:
  # To be removed when this is resolved: https://github.com/composer/composer/issues/5355
  - if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --no-interaction --no-suggest; fi
  - composer update $COMPOSER_FLAGS --no-interaction --no-suggest

script:
  - if [[ $COVERAGE ]]; then mkdir -p build/logs; fi
  - php vendor/bin/phpunit $COVERAGE

after_script:
  - if [[ $COVERAGE ]]; then php vendor/bin/php-coveralls; fi
