Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,27 @@ jobs:
with:
fetch-depth: 0 # important!

# we may use whatever way to install phpcs, just specify the path on the next step
# however, curl seems to be the fastest
- name: Install PHP_CodeSniffer
- name: Set up PHP 8.4
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: |
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
php phpcs.phar --version
php phpcbf.phar --version
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: 8.4
tools: composer

- name: Install Dependencies
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: composer install --prefer-dist --no-progress

- name: Check PHP formatting
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: |
php phpcbf.phar --standard=phpcs.xml --no-colors || phpcbf_status=$?
if [ "${phpcbf_status:-0}" -gt 1 ]; then
exit "$phpcbf_status"
fi
./vendor/bin/phpcbf --standard=phpcs.xml --no-colors --runtime-set ignore_non_auto_fixable_on_exit 1
git diff --exit-code -- lib test

- uses: tinovyatkin/action-php-codesniffer@0043b33b3629611c37e8bc7ee8a4e061dc9a7ea2 # v1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
with:
files: "**.php" # you may customize glob as needed
phpcs_path: php phpcs.phar
phpcs_path: ./vendor/bin/phpcs
standard: phpcs.xml
scope: "file"
19 changes: 3 additions & 16 deletions bin/fmt
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,10 @@ fi

# Run PHPCBF on all PHP files in lib/ and test/ directories
echo "Running PHPCBF on lib/ and test/ directories..."
./vendor/bin/phpcbf --standard=phpcs.xml lib/ test/ || {
# PHPCBF returns exit code 1 when it fixes files, which is expected behavior
# Only fail if it's a different error (exit code 2 or higher)
exit_code=$?
if [ $exit_code -gt 1 ]; then
fatal "PHPCBF failed with exit code $exit_code"
fi
echo "PHPCBF finished fixing files (exit code $exit_code is expected when fixes are made)"
}
./vendor/bin/phpcbf --standard=phpcs.xml --runtime-set ignore_non_auto_fixable_on_exit 1 lib/ test/

# Also format the example.php file
echo "Running PHPCBF on example.php..."
./vendor/bin/phpcbf --standard=phpcs.xml example.php || {
exit_code=$?
if [ $exit_code -gt 1 ]; then
fatal "PHPCBF failed on example.php with exit code $exit_code"
fi
}
./vendor/bin/phpcbf --standard=phpcs.xml --runtime-set ignore_non_auto_fixable_on_exit 1 example.php

echo "PHP formatting complete!"
echo "PHP formatting complete!"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"require-dev": {
"phpunit/phpunit": "^11.0",
"squizlabs/php_codesniffer": "^3.7"
"squizlabs/php_codesniffer": "^4.0"
},
"autoload": {
"psr-4": {
Expand Down
23 changes: 14 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading