- Works on every PHP code base, including WordPress(all rules are bundled).
- Supports configuration files (
phpcs.xml
,phpcs.xml.dist
, ...). - Fixes all fixable errors.
This action runs PHPCS and fix errors using PHPCBF. If the errors are not fixable the job will fail, if they are phpcbf will fix them.
The WordPress rulesets are bundled and made available to phpcs
. The action supports using PHPCS configuration files if there is a phpcs.xml
or other supported file names.
inputs:
github_token:
description: 'GITHUB_TOKEN'
default: '${{ github.token }}'
workdir:
description: 'Working directory relative to the root directory.'
default: '.'
### Flags for phpcs-wordpress ###
phpcs_args:
description: 'Additional PHPCS flags'
default: '.'
phpcbf_args:
description: 'Additional PHPCBF flags'
default: '.'
phpcs_standard:
description: 'Coding standard for PHPCS to use when checking files'
default: 'WordPress'
use_default_configuration_file:
description: 'Whether to use default configuration file(phpcs.xml) or not'
default: 'true'
name: WPCS checker
on: push
jobs:
linter_name:
name: runner / phpcs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shalior/wordpress-phpcs-action@master
with:
github_token: ${{ secrets.github_token }}
use_default_configuration_file: true
phpcs_args: '-n' # ignore warnings
- uses: stefanzweifel/git-auto-commit-action@v4 # auto commit the fixes action for GitHub
with:
commit_message: Fix PHPCS errors
The following sniffs are currently available. You can configure the standard(s) used by using the phpcs_standard
input setting. By default, WordPress
is used.
- MySource
- PEAR
- PHPCompatibility
- PHPCompatibilityWP
- PSR1
- PSR12
- PSR2
- Squiz
- WordPress
- WordPress-Core
- Wordpress-Docs
- WordPress-Extra
- WordPress-VIP-Go
- WordPressVIPMinimum
- Zend
- (Soon) WooCommerce
This action is based on action-phpcs-wordpress.