on:
  pull_request: ~
  push:
    branches:
      - "master"

name: Static analysis
jobs:
  phpstan:
    name: PHPStan
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Download dependencies
        run: |
          composer update --no-interaction --prefer-dist --optimize-autoloader

      - name: PHPStan
        uses: docker://oskarstark/phpstan-ga:0.12.48
        env:
          REQUIRE_DEV: true
        with:
          entrypoint: /composer/vendor/bin/phpstan
          args: analyze --no-progress

  php-cs-fixer:
    name: PHP-CS-Fixer
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: PHP-CS-Fixer
        uses: OskarStark/php-cs-fixer-ga@2.17.3
        with:
          args: --dry-run --diff-format udiff

  psalm:
    name: Psalm
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Psalm
        uses: docker://vimeo/psalm-github-actions:3.17.2
        env:
          REQUIRE_DEV: true
        with:
          args: --no-progress --show-info=false --stats
