使用Atom Beautify和PHP_CodeSniffer的不正确的PHP缩进

时间:2019-07-10 13:48:38

标签: atom-editor phpcodesniffer atom-beautify

说明

实际上,似乎Atom Beautify无法“看到”我针对PHP_CodeSniffer的自定义规则集。当我启动它时,如果运行命令phpcbf --standard=phpcs.xml.dist 404.php,将不会得到相同的结果。

复制步骤

Add code to Atom editor
Run command Atom Beautify: Beautify Editor
This beautified code does not look right!

自定义规则集

相反,您在这里找到我的配置文件phpcs.xml.dist:

<?xml version="1.0" encoding="UTF-8"?>

<ruleset name="WordPress Custom">
  <description>PHP_CodeSniffer custom ruleset: indentation with spaces</description>

  <arg name="tab-width" value="2"/>

  <rule ref="WordPress">
    <exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
  </rule>

  <rule ref="Generic.WhiteSpace.ScopeIndent">
    <properties>
      <property name="indent" value="2"/>
      <property name="exact" value="true"/>
      <property name="tabIndent" value="false"/>
      <property name="ignoreIndentationTokens" type="array">
        <element value="T_HEREDOC"/>
        <element value="T_NOWDOC"/>
      </property>
    </properties>
  </rule>

  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>

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

  <rule ref="PSR2.ControlStructures.SwitchDeclaration">
    <properties>
      <property name="indent" value="2"/>
    </properties>
  </rule>
</ruleset>

0 个答案:

没有答案