name: Static analysis

on:
  push:
    branches:
      - master
  pull_request:

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

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

      - name: PHPStan
        uses: docker://oskarstark/phpstan-ga:0.12.48
        env:
          REQUIRE_DEV: true
        with:
          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: docker://oskarstark/php-cs-fixer-ga:2.16.4
        with:
          args: --dry-run --diff-format udiff

  psalm:
    name: Psalm
    runs-on: ubuntu-latest
    steps:
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '7.4'
          extensions: mbstring, intl
          tools: composer:v2

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

      - name: Download dependencies
        run: |
          composer require --dev --no-update psalm/phar:3.16
          composer update --no-interaction --prefer-dist

      - name: Psalm
        run: |
          ./vendor/bin/psalm.phar --version
          ./vendor/bin/psalm.phar --output-format=github --no-progress --show-info=false --stats
