我试图将phpcs配置为在各处而不是4处使用两个空格缩进,但是我被卡在一个地方,我无法覆盖多行函数声明的规则
我的代码是
$('#datainiziocpform .input-group.date').datepicker({
startDate:$('#datainizio').val(),
dateFormat: "dd/mm/yyyy",
autoclose:true,
language: "it"
});
尽管这段代码给了我错误
多行函数声明未正确缩进;预期有6个空格,但找到了4个
我的自定义规则集
if (!function_exists('errorlog')) {
function errorlog(
Exception $e,
array $data = []
) {
}
答案 0 :(得分:1)
我采用了上面的代码,并根据提供的规则集运行了该代码,并带有-s
标志以显示Sniff报告错误。
<?php
// test.php
if (!function_exists('errorlog')) {
function errorlog(
Exception $e,
array $data = []
) {
}
}
$ ~/.composer/vendor/bin/phpcs --standard=./rules.xml -s test.php
这是我的输出:
FILE: test.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------
5 | ERROR | [x] Multi-line function declaration not indented correctly; expected 6 spaces but found 4 (Squiz.Functions.MultiLineFunctionDeclaration.Indent)
6 | ERROR | [x] Multi-line function declaration not indented correctly; expected 6 spaces but found 4 (Squiz.Functions.MultiLineFunctionDeclaration.Indent)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 90ms; Memory: 6Mb
Squiz.Functions.MultiLineFunctionDeclaration.Indent
是有问题的嗅探。要找到一种排除那个方法的方法!