Using php = 7.2
Composer = 1.7.2
Commands:-
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml --sniffs=Drupal.Classes.UnusedUseStatement /path/to/drupal/example_module
phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/drupal/example_module
Error:-
PHP Fatal error: Uncaught Error: Class 'Symfony\Component\Yaml\Yaml' not found in /home/lenovo/.composer/vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php:61
Stack trace:
#0 /usr/share/php/PHP/CodeSniffer/src/Files/File.php(497): DrupalPractice\Sniffs\InfoFiles\NamespacedDependencySniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 0)
#1 /usr/share/php/PHP/CodeSniffer/src/Files/LocalFile.php(91): PHP_CodeSniffer\Files\File->process()
#2 /usr/share/php/PHP/CodeSniffer/src/Runner.php(585): PHP_CodeSniffer\Files\LocalFile->process()
#3 /usr/share/php/PHP/CodeSniffer/src/Runner.php(394): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
#4 /usr/share/php/PHP/CodeSniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
#5 /usr/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
#6 {main}
thrown in /home/lenovo/.composer/vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php on line 61
My composer file code:-
{
"require": {
"drush/drush": "10.*",
"drupal/coder": "^8.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"twig/twig": "1.42.4"
}
}
Comments
Comment #2
rohit-rajput-sahab CreditAttribution: rohit-rajput-sahab commentedComment #3
klausias you can see the wrong PHPCS class is used from /usr/share/php/PHP/CodeSniffer instead of from your composer folder at /home/lenovo/.composer/vendor.
Please uninstall PHP CodeSniffer from /usr/share/php/PHP and try again.
Comment #4
rohit-rajput-sahab CreditAttribution: rohit-rajput-sahab commentedThank you for your comments. I uninstalled PHP CodeSniffer from /usr/share/php/PHP and run command. It's working without any error but I removed module name in mymodule.info.yml file and run below commands. The command nothing showing any error and warnings.
Please help me.
Commands:-
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml --sniffs=Drupal.Classes.UnusedUseStatement /path/to/drupal/example_module
phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/drupal/example_module
Comment #5
rohit-rajput-sahab CreditAttribution: rohit-rajput-sahab commentedComment #6
Arkener CreditAttribution: Arkener at INDICIA commentedThe module name currently isn't one of the keys that's being validated on Drupal 8 projects. Could you add the following to your *.info.yml file and check again using
phpcs --standard=DrupalPractice --extensions=yml /path/to/drupal/example_module
This should display the following output:
Comment #7
rohit-rajput-sahab CreditAttribution: rohit-rajput-sahab commentedmymodule.info.yml file code is below
type: module
description: 'XXXXXXXXXXXXXXXxx.'
package: XXXXXXXXXXXX API
core: 8.x
And I ran "phpcs --standard=DrupalPractice --extensions=yml /path/to/drupal/mumodule/mymodule.info.yml"
Nothing is showing
Comment #8
Arkener CreditAttribution: Arkener at INDICIA commentedThe module name currently isn't one of the keys that's being validated, which means your given info file is valid according to the DrupalPractice standard. Could you change your info file to following and check again:
Comment #9
rohit-rajput-sahab CreditAttribution: rohit-rajput-sahab commented@Arkener
Ok, thanks for "*.info.yml"
What about other YML files like "*libraries.yml", "*.links.menu.yml", "*.services.yml", and "*.routing.yml" etc.
Comment #10
Arkener CreditAttribution: Arkener at INDICIA commentedAll YAML files in the given directory will be scanned if you pass the yml extension
phpcs --standard=DrupalPractice --extensions=yml /path/to/drupal/mymodule
. This includes the libraries, menu, services and routing files. The scanned files can be displayed using the verbose option, for examplephpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/drupal/example_module -v
Comment #11
klausiThanks for your support here Arkener! With that I think we can close this, let me know if there are still questions.