When I try to run phpcs with the coder Drupal standards I get these errors: -
PHP Fatal error: Interface 'PHP_CodeSniffer_Sniff' not found in \AppData\Roaming\Composer\vendor\drupal\coder\coder_sniffer\Drupal\Sniffs\Array\ArraySniff.php on line 24
Fatal error: Interface 'PHP_CodeSniffer_Sniff' not found in \AppData\Roaming\Composer\vendor\drupal\coder\coder_sniffer\Drupal\Sniffs\Array\ArraySniff.php on line 24
Other phpcs standards are okay. Is there a way I need to reference back to the interface? It could be the way this is setup for Windows but I did carefully follow the install instructions.
Thanks for reading :-)
Comments
Comment #2
klausiWhat version of phpcs do you use? phpcs --version
The interface should be included with PHPCS, so not sure what goes wrong there.
Comment #3
klausiLet me know if you have more info.
Comment #4
c-logemannOn some installation tests today I had the same error when I used a 3.* version of PHP CodeSniffer. But coder requires a version ">=2.7.0 <3.0" which is automatically correct when installing via composer.
Comment #5
szeidler commentedEdit: I was actually wrong. If you have PHP_CodeSniffer installed before using version 3, it will automatically load the latest coder version without the < 3.0 constraint :) You will need to remove PHP_CodeSniffer first and then install drupal/coder once again to resolve the dependencies.
Comment #6
kunalkursija commentedI was facing the same issue as @Dubs.
I resolved it by downgrading my PHPCS from 3.0 to 2.7.0.
Below mentioned is my global composer JSON.
Comment #7
dubs commentedThanks for the replies and so sorry for not responding sooner. You know how it is sometimes - you move on and forget you ever had an issue!
I will try what you've suggested and hope this works.
Comment #8
dang42 commentedI'm still pretty much a composer noob, so when I read #6, I manually modified my composer.json file to include the
"squizlabs/php_codesniffer": "2.7.0",entry and, while I knew I'd need to do something more, I had no idea what that "something" might be.For others still at the "do what you're told without yet understanding what you're doing" stage, ensure the above code is in the json file, then run
composer global updateon the command line. That's it.Hopefully this will save someone some time...
Comment #9
anton-staroverov commentedTotally helped! Thank you so much!
Comment #10
agileadam+1 for this. Thank you all.
Comment #11
msankhala commentedEven last version of 2.* series also fix this issue. Update this in
~/.composer/composer.jsonand then run
composer global updatewill fix this.OR you can manually update to last stable version of 2.* series by
composer global require squizlabs/php_codesniffer:2.9.1Comment #12
super_romeo commentedThis helped me:
Comment #13
technikh commented#12 worked for me.
Comment #14
michel.settembrino commented+1 for https://www.drupal.org/project/coder/issues/2809335#comment-12275323
Worked for me too!
Comment #15
glass.dimly commentedFixed with #11.
Comment #16
Anonymous (not verified) commentedI like to re-open this issue... it no longer works with the latest version of php_codesniffer:3.2.3.
Steps to reproduce:
composer global update squizlabs/php_codesniffer
composer global update drupal/coder
phpcs --config-set installed_paths ~/.config/composer/vendor/drupal/coder/coder_sniffer
phpcs --standard=Drupal module_name/module_name.module
To workaround I have downgraded cs to 2.9.1 for now:
composer global update squizlabs/php_codesniffer:2.9.1.
Comment #17
kenorb commentedComment #18
kenorb commentedDuplicate of: #2863898: Support PHP_CodeSniffer version 3.3.1
Comment #19
wendyz commentedThe same as #17
Downgraded cs to 2.9.1 and it fixed the problem.
Comment #20
apolitsin commentedwaiting for PHP_CodeSniffer-3.+ support
Comment #21
zach.bimson commented+1 PHP_CodeSniffer-3.+ support
Comment #22
jimafisk commentedDowngrading codesniffer worked for me too. Steps on Ubuntu:
1. vim ~/.config/composer/composer.json
2. Change the line
"squizlabs/php_codesniffer": "*",to"squizlabs/php_codesniffer": "2.9.1",3. composer global update
This runs the following:
Codesniffer 3 support would be great! Thanks for all the hard work on the module :).
Comment #23
mialdi98 commented+1 PHP_CodeSniffer-3.+ support