language: php

sudo: false

notifications:
  email:
    on_success: never

php:
  - 7.2
  - 7.3
  - 7.4
  - nightly

matrix:
  fast_finish: true
  allow_failures:
    - php: nightly
  include:
    - php: 7.2
      env: dependencies=lowest

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

before_script:
  - if [[ $(phpenv version-name) == '7.2' ]]; then composer require satooshi/php-coveralls '~1.0' -n ; fi
  - if [[ $(phpenv version-name) != '7.2' ]]; then composer install -n ; fi
  - if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi;
  - echo "extension = apcu.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
  - echo 'apc.enable_cli = 1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

script:
  - if [[ $(phpenv version-name) == '7.2' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
  - if [[ $(phpenv version-name) != '7.2' ]]; then vendor/bin/phpunit ; fi
  - if [[ $(phpenv version-name) == '7.4' ]]; then vendor/bin/phpstan analyse -c phpstan.neon ; fi

after_script:
  - if [[ $(phpenv version-name) == '7.2' ]]; then php vendor/bin/coveralls -v ; fi
