在我使用的编码标准中,我们使用 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" />
这通常工作正常,但如果我有,例如这个
<?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'
);
}
}
add_submenu_page()
我得到函数的参数在哪里
多行函数调用未正确缩进;预计有 8 个空格,但找到了 6 个
所以“正确”看起来像
<?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'
);
}
}
但这两个空格太多了。我在github上发现了一些问题,但没有找到解决方案。
如何解决这个问题?