Problem/Motivation
After updating drupal/coder from v8.3.1 to v8.3.2 we can no longer run PHPCS and receive the following error.
# vendor/bin/phpcs .
Fatal error: Cannot declare class Drupal\Sniffs\InfoFiles\ClassFilesSniff, because the name is already in use in ./vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php on line 23
Rolling back to drupal/coder:8.3.1 resolves the issue.
Here are the relevant packages and versions in use for our project. I've also already verified that I have no global installation for the relevant packages. All installs are local to my project.
drupal/core 8.6.13
drupal/coder 8.3.2
squizlabs/php_codesniffer 3.4.2
dealerdirect/phpcodesniffer-composer-installer v0.4.4
Proposed resolution
Find and fix the namespace clash for class Drupal\Sniffs\InfoFiles\ClassFilesSniff
Remaining tasks
Add some tests?
Release notes snippet
Comments
Comment #2
vladimiraus+1. Reverting back to
8.3.1can be a temporary fix.Comment #3
evgeny.chernyavskiy commentedConfirming this issue cropped up after upgrading to 8.3.2. Looks like the class in question is autoloaded, and then loaded explicitly yet again in
vendor/drupal/coder/coder_sniffer/DrupalPractice/ruleset.xml. Patch attached.Comment #4
klausiHm, I added a test case explicitly for DrupalPractice calls ... can you create this as pull request at https://github.com/pfrenssen/coder ? Then we can see the automated test results.
Comment #5
evgeny.chernyavskiy commentedSure thing, here you go: https://github.com/pfrenssen/coder/pull/31
Comment #7
klausiThanks, I tried a couple of thing to reproduce the problem I had with ClassFilesSniff but did not run into the problem anymore, so this should be fine.
Thanks!
Comment #8
klausi@chOP and @VladimirAus: can you test the 8.x-3.x dev version of Coder now and let me know if this fixes your problem? Then I can release Coder 8.3.3.
Comment #9
chop commented@klausi,
Confirmed that this commit has fixed the issue for me when using Drupal and DrupalPractice standards.
Test steps performed:
I happy to report that the fix seems to work for me. Thanks for jumping on this quickly.
Comment #10
chop commentedWhy did the status change back to active?
Setting it to fixed again.
Comment #11
klausiThanks, released as Coder 8.3.3!
Comment #12
vladimirausThanks @klausi and @chOP
Works for me.
Comment #13
jonathan1055 commentedI had previously raised #3049433: Coding standards not running on d.o. - upgrade to coder 8.3.4 which looks like the same problem? Maybe I did that on the wrong issue queue as got no response. I did search for the issue but maybe not in the Coder queue.