Php 多行函数调用未正确缩进

Php 多行函数调用未正确缩进,php,wordpress,codesniffer,phpcodesniffer,Php,Wordpress,Codesniffer,Phpcodesniffer,在我使用的编码标准中,我们使用2个空格进行缩进 <!-- Tabs should represent 2 spaces. --> <arg name="tab-width" value="2"/> <!-- Set the default indent value and force spaces instead of tabs --> <rule ref="WordPress"> <exclude name="Generic.Wh

在我使用的编码标准中,我们使用2个空格进行缩进

<!-- Tabs should represent 2 spaces. -->
<arg name="tab-width" value="2"/>

<!-- Set the default indent value and force spaces instead of tabs -->
<rule ref="WordPress">
    <exclude name="Generic.WhiteSpace.DisallowSpaceIndent" />
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
  <properties>
    <property name="indent" value="2"/>
    <property name="tabIndent" value="false"/>
  </properties>
</rule>
<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
但是那太多了两个空格。我在github上发现了一些问题,但没有找到解决方案


如何修复此问题?

不幸的是,PHPC还没有共享配置设置,因此您需要为报告错误的其他嗅探设置缩进设置

如果将
-s
命令行参数添加到PHPCS,则会得到每个错误消息的嗅探代码。该代码告诉您哪个嗅探报告了错误,需要更改

在本例中,我认为是
PEAR.Functions.FunctionCallSignature
sniff

可在此处找到此嗅探的设置:

如果是这样,您需要将其添加到规则集中:

<rule ref="PEAR.Functions.FunctionCallSignature">
  <properties>
    <property name="indent" value="2"/>
  </properties>
</rule


请看这个[如何在Github上格式化PHP代码这与PHP_code_formatter无关,但与WordPress编码标准和PHP_CodeSniffer…似乎就是这样。因此,基本上如果我在其他地方看到这种情况,我需要看看是哪种嗅探引起的,然后更改属性?谢谢你的帮助:)是的,这就是你需要的过程很高兴它对你有用。
<?php

class MyClass{
  public function my_function() {
    add_submenu_page(
        'my-top-level-slug',
        'My Custom Page',
        'My Custom Page',
        'manage_options',
        'my-top-level-slug'
    );
  }
}
<rule ref="PEAR.Functions.FunctionCallSignature">
  <properties>
    <property name="indent" value="2"/>
  </properties>
</rule