name: PHP

on:
  push:
  pull_request:
  schedule:
    - cron:  '0 3 * * *'

jobs:
  analyze:
    name: "Code style and static analysis"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: '7.4'
          extensions: mbstring, intl, zip

      - name: Install dependencies
        run: |
          composer update --no-interaction
          composer require --dev phpstan/phpstan # Not part of require-dev, because it won't install on PHP 5.6
          composer require --dev ergebnis/composer-normalize

      - name: Check composer.json
        run: |
          composer validate --strict
          composer normalize --dry-run

      - name: Run checks
        run: |
          composer analyze
          composer codestyle:check
