name: Lint & Test

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

jobs:
  php-lint:
    name: PHP Lint & Static Analysis
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php-version: ['8.1', '8.2', '8.3']
    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          tools: composer

      - name: Install Composer dependencies
        run: composer install --no-interaction --prefer-dist

      - name: Run PHP_CodeSniffer
        run: .composer-vendor/bin/phpcs

      - name: Run PHPStan
        if: matrix.php-version == '8.3'
        run: .composer-vendor/bin/phpstan analyse --no-progress

  js-lint:
    name: JavaScript Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '24'

      - name: Install npm dependencies
        run: npm ci

      - name: Run ESLint
        run: npx eslint script.js script/

  css-lint:
    name: LESS/CSS Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '24'

      - name: Install npm dependencies
        run: npm ci

      - name: Run Stylelint
        run: npx stylelint "css/**/*.less" "*.less"
