0

我正在使用这样的 PHP_CodeSniffer 来扫描我的代码:

vendor/bin/phpcs --standard=PSR12 src

我还将 PhpStorm 配置为使用 PSR-12Preferences -> Editor -> Code Style -> Set From -> PSR12

当我运行 PHP_CodeSniffer 时,一开始没有错误,但如果你使用 PhpStorm 自动缩进我的文件并重新运行 PHP_CodeSniffer,我会收到一些错误:

 286 | ERROR | [x] Multi-line function call not indented correctly; expected 12 spaces but found 16
 287 | ERROR | [x] Multi-line function call not indented correctly; expected 12 spaces but found 16
 288 | ERROR | [x] Multi-line function call not indented correctly; expected 12 spaces but found 16

我尝试更改制表符和缩进的配置,默认情况下是这样的:

在此处输入图像描述

我没有找到任何有效的配置,而且我不明白可能是什么问题,因为我在 PhpStorm 和 PHP_CodeSniffer 中都使用了 PSR12。

我也有这个 phpcs.xml

<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer"
         xsi:noNamespaceSchemaLocation="phpcs.xsd">
    <description>The coding standard for PHP_CodeSniffer itself.</description>

    <file>src</file>

    <arg name="basepath" value="."/>
    <arg name="colors"/>
    <arg name="parallel" value="8"/>
    <arg value="p"/>
    <arg value="s"/>

    <!-- Don't hide tokenizer exceptions -->
    <rule ref="Internal.Tokenizer.Exception">
        <type>error</type>
    </rule>

    <rule ref="PSR12"></rule>
    <rule ref="PSR2"></rule>
    <rule ref="PSR1"></rule>

</ruleset>
4

0 回答 0