Hi. I installed code sniffer (2.5.1) and coder using composer (tells me I'm using version ^8.2 for drupal/coder), but I'm getting the following error all the time in PHP Storm:
phpcs: Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found' in /Users/charles/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Drupal/Sniffs/Commenting/FileCommentSniff.php:13 Stack trace: #0 /Users/charles/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(1353): include_once() #1 /Users/charles/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php(560): PHP_CodeSniffer->registerSniffs(Array, Array)
Is this to do with the code sniffer version, as mentioned here: https://www.drupal.org/node/2397017 or could it be something else?
I understand that code sniffer removed the comment parser from recent versions - so is that the problem, and I should be using an earlier version?
Thanks :-)
Comments
Comment #2
klausilooks like you have some global old version of phpcs installed. Did you follow https://www.drupal.org/node/1419988 ? What is the output of "which phpcs" in your terminal? What does "ls -l" say on that file?
Comment #3
foxtrotcharlie CreditAttribution: foxtrotcharlie as a volunteer commentedThanks @klausi - yes I did follow those instructions but perhaps I missed something...Here's the output of the commands you mentioned:
which phpcs:
-l /Users/charles/.composer/vendor/bin/phpcs
which composer:
composer global show:
Thanks :-)
Comment #4
klausiSo it looks like your PHPCS setup is broken. /Users/charles/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Drupal/Sniffs/Commenting/FileCommentSniff.php should not exist because Coder is not part of PHPCS. Or did you link some version of Coder there?
I would suggest that you remove /Users/charles/.composer/vendor/squizlabs/php_codesniffer and install it again. Then follow the install instructions at https://www.drupal.org/node/1419988 and set Coder with something like phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder_sniffer
Comment #5
foxtrotcharlie CreditAttribution: foxtrotcharlie as a volunteer commentedThank you so much - deleting the directory and re-installing codesniffer sorted this out. What a relief :-)