Skip to content
##
# A reusable workflow that checks the PHP coding standards.
##
name: PHP coding standards
# on:
# workflow_call:
# inputs:
# php-version:
# description: 'The PHP version to use.'
# required: false
# type: 'string'
# default: 'latest'
jobs:
phpcs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.0', '7.4', '8.0', '8.1', '8.2', '8.3']
permissions:
contents: read
name: Run coding standards checks on ${{ matrix.php-versions }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: cs2pr
env:
runner: self-hosted
- name: Install Composer dependencies
run: composer install
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Run PHPCS on all files
id: phpcs
run: phpcs -n --report-full --report-checkstyle=./.cache/phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-report.xml
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code