WordPress-Coding-Standards: Failed when running command with Wordpress
php version 7.1.11
squizlabs/php_codesniffer (2.9.0)
I install vai composer with squizlabs/php_codesniffer (2.9.0)
Then I run configure point to install path and path to wpcs
And I run command phpcs --standard=WordPress wp-content/themes/kymenlaaksonjate/template-service.php
Then got error below
PHP Fatal error: Interface 'PHP_CodeSniffer_Sniff' not found in /home/sakona/dev/wpcs/WordPress/Sniff.php on line 36
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/phpcs:0
PHP 2. PHP_CodeSniffer\Runner->runPHPCS() /usr/local/bin/phpcs:6
PHP 3. PHP_CodeSniffer\Runner->init() phar:///usr/local/bin/phpcs/src/Runner.php:2
PHP 4. PHP_CodeSniffer\Ruleset->__construct() phar:///usr/local/bin/phpcs/src/Runner.php:2
PHP 5. PHP_CodeSniffer\Ruleset->registerSniffs() phar:///usr/local/bin/phpcs/src/Ruleset.php:2
PHP 6. PHP_CodeSniffer\Autoload::loadFile() phar:///usr/local/bin/phpcs/src/Ruleset.php:2
PHP 7. include() phar:///usr/local/bin/phpcs/autoload.php:2
PHP 8. spl_autoload_call() /home/sakona/dev/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php:29
PHP 9. PHP_CodeSniffer\Autoload::load() /home/sakona/dev/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php:29
PHP 10. PHP_CodeSniffer\Autoload::loadFile() phar:///usr/local/bin/phpcs/autoload.php:2
PHP 11. include() phar:///usr/local/bin/phpcs/autoload.php:2
PHP 12. spl_autoload_call() /home/sakona/dev/wpcs/WordPress/AbstractClassRestrictionsSniff.php:21
PHP 13. PHP_CodeSniffer\Autoload::load() /home/sakona/dev/wpcs/WordPress/AbstractClassRestrictionsSniff.php:21
PHP 14. PHP_CodeSniffer\Autoload::loadFile() phar:///usr/local/bin/phpcs/autoload.php:2
PHP 15. include() phar:///usr/local/bin/phpcs/autoload.php:2
PHP 16. spl_autoload_call() /home/sakona/dev/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php:27
PHP 17. PHP_CodeSniffer\Autoload::load() /home/sakona/dev/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php:27
PHP 18. PHP_CodeSniffer\Autoload::loadFile() phar:///usr/local/bin/phpcs/autoload.php:2
PHP 19. include() phar:///usr/local/bin/phpcs/autoload.php:2
Please get help on this. Thanks,
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (10 by maintainers)
There is no version of WPCS which is compatible with PHPCS 3.0.0 as that version contained quite some bugs still.
You either need 2.9.0/2.9.1 or version 3.0.2 or higher. For the best results, always use an up-to-date version of PHPCS, which would currently be version 3.1.1.
What error do you get when you run
phpcs -e --standard=WordPress?And can you try to run
phpcs -ito see if the WPCS standards are registered correctly in the install you are using ?You’ll probably will need to run both commands as
vendor/bin/phpcs.