Just installed php_codesniffer and coder:
composer global require "squizlabs/php_codesniffer=*"
composer global require drupal/coder
After installation, run phpcs -i and the result is as follows:
The installed coding standards are MySource, PEAR, Zend, PSR2, PSR1, Squiz, PSR12, PHPCompatibility, Drupal and DrupalPractice
But when I use git commit, I get an error:
ERROR: Referenced sniff "SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" does not exist
My php version is 7.4. Where am I going wrong?
One trick is to downgrade drupal/coder to 8.3.13, then upgrade it to the latest version. This worked for me, with current version 8.3.18.
Downgrade to 8.3.13:
composer global require drupal/coder:8.3.13
Then upgrade to the latest version:
composer global require drupal/coder
Then verify installed coding standards:
phpcs -i
For me, that outputs:
"The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, Drupal, DrupalPractice, VariableAnalysis and SlevomatCodingStandard"
More info and options at https://www.drupal.org/project/coder/issues/3262291
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With