我遇到了使用 PSR2 标准的 PHPCS 问题。高低搜索,但令我惊讶的是,我找不到任何人报告同样的问题。
假设我有一个类声明如下:
<?php
class MyChildClass extends \SomeNameSpace\MyParentClass
{
}
然后我通过 PHPCS 运行它:
bash-3.2$ phpcs -s --standard=PSR2 test.php
FILE: test.php
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
3 | ERROR | Expected 0 spaces between "SomeNameSpace" and comma; $1 found
| | (PSR2.Classes.ClassDeclaration.SpaceBeforeComma)
3 | ERROR | Expected 1 space before "MyParentClass"; 13 found
| | (PSR2.Classes.ClassDeclaration.SpaceBeforeName)
--------------------------------------------------------------------------------
Time: 0 seconds, Memory: 4.00Mb
还:
Bash-3.2$ phpcs --version
PHP_CodeSniffer version 1.3.6 (stable) by Squiz Pty Ltd. (http://www.squiz.net)
有没有人遇到过这个?难道我做错了什么?否则我将首先进入嗅探器代码 - 这感觉不对。