我正在创建一个用于在WordPress中嗅探代码的自定义规则集,并为此使用了PHP_CodeSniffer。
可以在这里找到自定义规则集:。
现在,当我尝试使用它们时,我会得到这个错误。
Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff "WordPress" does not exist' in /wpcs/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1167
我正在使用PHP_CodeSniffer来分析我的php代码。问题是我的应用程序的代码相当复杂(大约10,000个文件),而且它有点旧(大约15年),所以它没有遵循PSR这样的标准。
这就是为什么CodeSniffer会生成非常大的报告。因为解决所有“问题”需要花费太多时间,我在考虑忽略一些事情,f.e。
Class name must begin with a capital letter
或
Opening brace of a class must be on the line after the definition
有没有一种方法可以让CodeSniffer在创建报告时忽略这些错误?
我正在尝试找出使用phpcs代码嗅探器强制执行哪种代码样式。
由于Symfony2的流行,使用它的代码标准似乎是一个很好的实践。另一方面,它的代码风格是基于PSR2的,所以这似乎是人们应该使用的最基本的风格。
此外,在squizlabs/php_codesniffer的基本安装中,不包括Symfony2标准,必须手动安装,而PSR2很容易获得。
所以我想知道与PSR2相比,Symfony2指南的主要区别是什么,以便决定使用哪种指南。
例如,我意识到Symfony2样式会强制执行该Concat operator must not be surrounded by spaces,而PSR2会忽略这
我正在尝试使用PHP_CodeSniffer根据zend编码标准来探测php文件中的问题。问题是一些基本规则没有被检测到,例如
String Literals
$a = "Example String";
should give a warning because the standard is
$a = 'Example String';
我是不是漏掉了什么,这不是代码标准的一部分吗?
使用Rubocop,我可以覆盖.rubocop.yml文件(如 )中的规则
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but c
我正在尝试在OS X Mountain Lion上安装PHP CodeSniffer -我似乎遇到了一个奇怪的问题
当运行'phpcs‘时,我得到以下错误:
PHP Warning: include_once(PHP/CodeSniffer/CLI.php): failed to open stream: No such
file or directory in /usr/lib/php/pear/bin/phpcs on line 31
PHP Warning: include_once(): Failed opening 'PHP/CodeSniffer/CLI.ph
最初,我使用了下面的代码,但没有成功;
export http_proxy=http://username@password:host:port
值得注意的是,我没有直接得到连接错误;
[root@pal ~]# sudo pear info PHP_CodeSniffer-1.2.1
No information found for `PHP_CodeSniffer-1.2.1'
我正在使用Vagrant和Puppet来设置虚拟机。我遇到了从Pear安装PHP CodeSniffer的问题。我看到的错误是这样的:
==> default: err: /Stage[main]//Package[pear.php.net/PHP_CodeSniffer]/ensure: change from absent to present failed: Execution of '/usr/bin/pear upgrade -a pear.php.net/PHP_CodeSniffer' returned 1: Failed loading /usr/lib/
我有这样的代码:
function processRequest() {
// get the verb
$method = strtolower($_SERVER['REQUEST_METHOD']);
switch ($method) {
case 'get':
handleGet();
break;
case 'post':
handlePost();
// $data = $_POST;
break;
case 'delete