name: PHP Code Style

on:
  push:
    branches-ignore:
      - stable
      - old-stable
  pull_request:

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

permissions:
  contents: read  #  to fetch code (actions/checkout)

jobs:
    phpcs:
        name: PHP CodeSniffer
        runs-on: ubuntu-latest
        if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
        steps:
            - uses: actions/checkout@v4
              with:
                  fetch-depth: 0

            - name: Setup PHP
              uses: shivammathur/setup-php@v2
              with:
                  php-version: '8.2'

            - name: run PHP codesniffer
              run: |
                cd _test
                composer install --no-interaction --no-progress --no-suggest --prefer-dist
                composer run check
