PHP Codesniffer로 선호하는 들여 쓰기 수준을 어떻게 설정할 수 있습니까?

StackOverflow https://stackoverflow.com//questions/9650154

  •  11-12-2019
  •  | 
  •  

문제

나는 무시 들여 쓰기 수준을 원하지 않는다.

기본값이 아닌 특정 들여 쓰기 수준을 시행하고 싶습니다. 4.

분명히 이것은 가능합니다 :

여기에 이미지 설명

방법?

이 물건에 대한 문서는 나를 멸망시키는 것처럼 보입니다.

도움이 되었습니까?

해결책

Apparently one way to do it is this: create a new "Standard", create a new ruleset.xml, then insert into that ruleset.xml file, an XML stanza that sets the property.

For example, (I'm on Windows so my backslashes are all backslashes and not fwd slashes)

cd \dev\phpcs\CodeSniffer
mkdir NewStandard

Within that directory, create ruleset.xml, containing this :

<?xml version="1.0"?>
<ruleset name="Custom Standard">
  <description>My custom coding standard</description>
  <rule ref="PEAR">
    <exclude name="PEAR.Commenting.ClassComment"/>
    <exclude name="PEAR.Commenting.FileComment"/>
    <exclude name="PEAR.Commenting.FunctionComment"/>
    <exclude name="PEAR.Commenting.InlineComment"/>
    <exclude name="PEAR.Classes.ClassDeclaration"/>
    <exclude name="Generic.Files.LineEndings"/>
  </rule>

  <rule ref="PEAR.WhiteSpace.ScopeIndent">
    <properties>
      <property name="indent" value="2"/>
    </properties>
  </rule>

</ruleset>

The final stanza within the xml file sets the appropriate property.

To do this, you have to know that

A) the indenting sniff (rule) is PEAR.WhiteSpace.ScopeIndent

B) the property on that sniff is called indent.

Then, run phpcs as normal like so:

\php\php.exe phpcs\scripts\phpcs --standard=NewStandard --report=emacs MyCode.php

documentation:

http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top