php code sniffer codeigniter错误 - “CodeIgniter.Files.ClosingLocationComment”不存在

时间:2016-06-29 17:07:54

标签: php codeigniter codesniffer

我花了一整天时间在我的Mac El Capitan上安装梨,代码嗅探器。我还从这个链接Sniffs for codeigniter安装了codeigniter sniff 并遵循这个video tutorial。   现在,当我测试我的codeigniter代码时,我得到以下错误

amits-iMac:~ amitpatil$ phpcs --standard=Codeignitor /Applications/AMPPS/www/project/front/application/controllers/about.php

Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff "CodeIgniter.Files.ClosingLocationComment" does not exist' in /Users/amitpatil/pear/share/pear/PHP/CodeSniffer.php:1144
Stack trace:
#0 /Users/amitpatil/pear/share/pear/PHP/CodeSniffer.php(757): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement), '/Users/amitpati...', 0)
#1 /Users/amitpatil/pear/share/pear/PHP/CodeSniffer.php(561): PHP_CodeSniffer->processRuleset('/Users/amitpati...')
#2 /Users/amitpatil/pear/share/pear/PHP/CodeSniffer/CLI.php(870): PHP_CodeSniffer->initStandard(Array, Array)
#3 /Users/amitpatil/pear/share/pear/PHP/CodeSniffer/CLI.php(106): PHP_CodeSniffer_CLI->process()
#4 /usr/local/bin/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
thrown in /Users/amitpatil/pear/share/pear/PHP/CodeSniffer.php on line 1144

1 个答案:

答案 0 :(得分:0)

该repo看起来很旧,它不适用于我尝试过的任何PHP_CodeSniffer版本。但修复相对简单。只需要重命名src目录:

$ cd CodeIgniter-for-PHP_CodeSniffer
$ mv src CodeIgniter

现在它应该通过运行命令来工作: phpcs --standard=/path/to/CodeIgniter-for-PHP_CodeSniffer/CodeIgniter /path/to/code