symfony2 php codesniffer标准错误

时间:2013-10-14 19:58:19

标签: eclipse symfony codesniffer

我是phpCodeSniffer的新手,我正在尝试将其与 eclipse 集成。我在these instructions之后从 PEAR 下载了phpCodeSniffer,我还从Github和{{3}下载了 Symfony2标准 }。我按照所有说明操作,一切正常,但当我尝试使用带有eclipse的嗅探器时,我收到以下错误:

/usr/bin/php -c /tmp/zend_debug/session7507717624755069136.tmp -d asp_tags=off -d short_open_tag=on /opt/eclipse/plugins/org.phpsrc.eclipse.pti.tools.codesniffer_1.3.0.R20111119000000/php/tools/phpcs.php --report=xml --standard=/usr/share/php/PHP/CodeSniffer/Standards/Symfony2 --tab-width=4 /var/www/siga-nuevo/src/Siga/UserBundle/Controller/UserController.php
PHP Fatal error:  Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff Symfony2.Commenting.FunctionComment.MissingParamComment does not exist' in /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php:814
Stack trace:
0 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php(730): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement))
1 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php(623): PHP_CodeSniffer->getSniffFiles('/usr/share/php/...', 'Symfony2')
2 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php(438): PHP_CodeSniffer->setTokenListeners('/usr/share/php/...', Array)
3 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer/CLI.php(551): PHP_CodeSniffer->process(Array, '/usr/ in /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php on line 814

这是我的eclipse 配置

configuration

1 个答案:

答案 0 :(得分:4)

看起来OpenSky symfony2标准在您的案例中被打破。错误消息的相关部分是这一部分:

Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff Symfony2.Commenting.FunctionComment.MissingParamComment does not exist'

由于symfony遵循所有当前PSR standards - 即PSR-0PSR-1PSR-2PSR-3(其中PSR-3仅提供记录器) monolog尊重的界面。

您也可以直接使用较新版本的PHPCS中包含的PSR-2标准。

最近更新了PHPCS中的PSR-2标准实现 - 与旧的symfony2标准相反。无论如何,这意味着实施应该更准确。