name: Static Analysis

on: ['push', 'pull_request']

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: true

jobs:
  phpstan:
    runs-on: ubuntu-latest

    name: Static

    steps:
    - name: Checkout
      uses: actions/checkout@v5

    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: 8.2
        tools: composer:v2
        coverage: none

    - name: Get Composer cache directory
      id: composer-cache
      run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

    - name: Cache Composer dependencies
      uses: actions/cache@v4
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-php-8.2-composer-${{ hashFiles('**/composer.json') }}
        restore-keys: ${{ runner.os }}-php-8.2-composer-

    - name: Set Collision version
      run: composer config version "8.x-dev"

    - name: Install Dependencies
      run: composer update --no-interaction --prefer-dist --no-progress --ansi

    - name: Run Style Tests
      run: composer test:lint

    - name: Run Types Tests
      run: composer test:types
