Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referenced sniff "SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" does not exist

Tags:

drupal

phpcs

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?

like image 898
River Zhao Avatar asked Sep 16 '25 00:09

River Zhao


1 Answers

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

like image 77
Nick Hope Avatar answered Sep 18 '25 12:09

Nick Hope