This Composer package will enforce a check of your PHP files upon each commit to make sure they comply with the Drupal code standards as defined by Drupal Coder.
This is a PHP Composter Action.
Uses the wonderful PHP CodeSniffer Project.
Just add as a development requirement to your composer.json, and it should work automagically:
composer require --dev nickwilde1990/php-composter-phpcs-drupalNote: If you are using this with a Drupal module which is being run through the DrupalCI test bot, due to how that works/adds test dependencies, you will likely need to also run
composer require --dev "squizlabs/php_codesniffer:^3.3"to force the required version of PHPCS since otherwise, the test bot is locked to the 2.8 branch.
It should just work when you git commit.
The Drupal Coder module provides two
sets of sniffs. By default this uses the Drupal sniff rather than
DrupalPractice. If you want to use DrupalPractice (or any other sniff set),
you can specify that standard to use in your composer.json's extra key:
"extra": {
"php-composter-phpcs-drupal": {
"standard": "DrupalPractice"
}
}All feedback / bug reports / pull requests are welcome.