language: php

branches:
  # Only test the master branch and SemVer tags.
  only:
    - master
    - '/^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/'

matrix:
  include:
    -
      php: 7.1
      env: 'HIGHEST_LOWEST="update" STABILITY="RC"'
    -
      php: 7.0.11
      env: DO_POST_BUILD_ACTIONS=1
    -
      php: 5.6
    -
      php: 5.5
    -
      php: 5.4
      env: 'HIGHEST_LOWEST="update --prefer-lowest"'

sudo: false

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

before_script:
  # If running a highest/lowest dependencies test, get rid of composer.lock
  - |
    if [ -n "$HIGHEST_LOWEST" ] ; then
      rm composer.lock
      composer config --unset platform.php
      composer config minimum-stability ${STABILITY-stable}
    fi
  - 'composer -n ${HIGHEST_LOWEST-install} --prefer-dist'
  - composer why symfony/console
  # Print out all  of the installed packages in alphabetical order, with versions
  - composer licenses

script:
  - vendor/bin/phpunit
  - 'vendor/bin/phpcs --standard=PSR2 -n src'

after_success:
  - 'travis_retry php vendor/bin/coveralls -v'
  - |
    # Only do post-build actions in one environment, and only if there is a GITHUB token.
    if [ -z "$DO_POST_BUILD_ACTIONS" ] ; then
      return
    fi
    if [ -z "$GITHUB_TOKEN" ]; then
      echo "No GITHUB_TOKEN defined; exiting."
      return
    fi
    ###
    # Run composer lock update on cron jobs.
    # See: https://github.com/danielbachhuber/composer-lock-updater
    ###
    if [ "$TRAVIS_EVENT_TYPE" != "cron" ] ; then
      echo "Not a cron job; exiting."
      return
    fi
    ###
    # Only run on one job of a master branch build
    ###
    if [ "master" != "$TRAVIS_BRANCH" ] ; then
      echo "composer.lock update only runs on the master branch."
      return
    fi
    ###
    # Install composer-lock-updater
    ###
    export PATH="$HOME/.composer/vendor/bin:$PATH"
    composer global require danielbachhuber/composer-lock-updater
    ###
    # Optional: install Sensio Labs security checker to include security advisories in PR comments
    ###
    mkdir -p $HOME/bin
    wget -O $HOME/bin/security-checker.phar http://get.sensiolabs.org/security-checker.phar
    chmod +x $HOME/bin/security-checker.phar
    export PATH="$HOME/bin:$PATH"
    ###
    # Install hub for creating GitHub pull requests
    ###
    wget -O hub.tgz https://github.com/github/hub/releases/download/v2.2.9/hub-linux-amd64-2.2.9.tgz
    tar -zxvf hub.tgz
    export PATH=$PATH:$PWD/hub-linux-amd64-2.2.9/bin/
    ###
    # Run composer-lock-updater
    ###
    clu




