Run the following from the root of your project:
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev helsingborg-stad/phpcs
Specific ruleset for WordPress themes and plugins.
<?xml version="1.0"?>
<ruleset name="Some Wordpress Plugin">
<file>./source/php</file>
<file>./tests</file>
<rule ref="Hbg-WordPress"></rule>
</ruleset>
Included are 2 binaries for running phpcs and phpcbf on changed files only. The changes in the current branch are compared to supplied branch, and are meant to be used in a CI environment.
vendor/bin/phpcs-changed origin/main
This example runs phpcs on all changed files in the current branch compared to origin/main.
vendor/bin/phpcbf-changed origin/main
This example runs phpcbf on all changed files in the current branch compared to origin/main.