language: php
sudo: false
dist: trusty

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

php:
  - 5.5
  - 5.6
  - 7.0
  - 7.1
  - 7.2
  - 7.4snapshot

env:
  global:
    - deps=no
    - SYMFONY_DEPRECATIONS_HELPER=3

before_install:
  - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
  - composer self-update
  - if [ "$SYMFONY_VERSION" != "" ]; then jq "(.require, .\"require-dev\")|=(with_entries(if .key|test(\"^symfony/\") then .value|=\"${SYMFONY_VERSION}\" else . end))" composer.json|ex -sc 'wq!composer.json' /dev/stdin; fi;

install:
  - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update -n --prefer-dist

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

jobs:
  include:
    - php: 5.5
      env: deps=low SYMFONY_DEPRECATIONS_HELPER=weak
      install:
        - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist

    - php: 5.6
      env: SYMFONY_VERSION="2.8.*"

    - php: 7.0
      env: SYMFONY_VERSION="3.2.*"

    - php: 7.1
      env: stability=RC SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="3.4.*"
      install:
        - travis_retry composer update -n --prefer-dist

    - php: 7.1
      env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.1.*"
      install:
        - composer require --dev "symfony/messenger:4.1.*" --no-update
        - travis_retry composer update -n --prefer-dist

    - php: 7.1
      env: stability=dev SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="4.2.*"
      install:
        - composer require --dev "symfony/messenger:4.2.*" --no-update
        - travis_retry composer update -n --prefer-dist

    - php: 7.2
      env: stability=alpha
      install:
        - composer config minimum-stability alpha
        - travis_retry composer update -n --prefer-dist

    - stage: Code Quality
      env: CODING_STANDARDS
      php: 7.1
      install:
        - travis_retry composer require -n --prefer-dist --dev doctrine/coding-standard:^5.0
      script:
        - ./vendor/bin/phpcs

    - stage: Coverage
      php: 7.2
      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:
        - php ./vendor/bin/coveralls -v

  allow_failures:
    - php: 7.4snapshot
