name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

permissions:
  contents: read

jobs:
  tests:
    name: Tests (PHP ${{ matrix.php }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php: ['8.1', '8.2', '8.3']

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

      - name: Setup PHP
        uses: ./.github/actions/setup-php
        with:
          php-version: ${{ matrix.php }}

      - name: Run PHPUnit tests
        run: vendor/bin/phpunit --colors=always --display-all-issues

  static-analysis:
    name: Static Analysis
    runs-on: ubuntu-latest

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

      - name: Setup PHP
        uses: ./.github/actions/setup-php

      - name: Run PHPStan
        run: vendor/bin/phpstan analyse --configuration=phpstan.neon

      - name: Run PHP CodeSniffer
        run: vendor/bin/phpcs -n
