Skip to content

Instantly share code, notes, and snippets.

@miku3920
Last active Feb 24, 2021
Embed
What would you like to do?
一些中文註釋
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PSR12" xsi:noNamespaceSchemaLocation="../../../phpcs.xsd">
<description>My coding standard. https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties</description>
<arg name="tab-width" value="4"/>
<!-- 檢查陣列縮排 -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- 警告參數未使用 -->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<!-- 禁止省略大括號 -->
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<!-- 檢查行尾 -->
<rule ref="Generic.Files.LineEndings"/>
<!-- 警告過長語句 -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120" />
<property name="absoluteLineLimit" value="0" />
</properties>
</rule>
<!-- 檢查(型別)後的間距 -->
<rule ref="Generic.Formatting.NoSpaceAfterCast.SpaceFound"/>
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<!-- 檢查!後的間距 -->
<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<!-- 檢查大括號開啟位置 -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
<properties>
<property name="checkFunctions" value="true" />
<property name="checkClosures" value="true" />
</properties>
</rule>
<!-- 檢查循環複雜度 -->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="5" />
<property name="absoluteComplexity" value="10" />
</properties>
</rule>
<!-- 檢查巢套層次 -->
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="2" />
<property name="absoluteNestingLevel" value="5" />
</properties>
</rule>
<!-- 強制函式使用駝峰式命名 -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<!-- 禁用函式 -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="print" value="echo"/>
<element key="create_function" value="null"/>
</property>
</properties>
</rule>
<!-- 建議不要使用錯誤控制運算符 -->
<rule ref="Generic.PHP.NoSilencedErrors"/>
<!-- 禁止分隔相同符號字串 -->
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<!-- 檢查小括號內參數前後不可有空格 -->
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"/>
<!-- 檢查縮排 -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="exact" value="true" />
</properties>
</rule>
<!-- 檢查...運算符間距 -->
<rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/>
<!-- 方法必須有doc -->
<rule ref="PEAR.Commenting.FunctionComment">
<properties>
<property name="minimumVisibility" value="public" />
</properties>
</rule>
<!-- 檢查控制結構各符號間距 -->
<rule ref="PEAR.ControlStructures.ControlSignature"/>
<!-- 檢查控制結構縮排 -->
<rule ref="PEAR.ControlStructures.MultiLineCondition"/>
<!-- 檢查=縮排 -->
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<!-- 檢查函式小括號內縮排 -->
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="allowMultipleArguments" value="false" />
</properties>
</rule>
<!-- 檢查->縮排 -->
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<!-- 檢查case break縮排 -->
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
<!-- 檢查控制結構參數前後不可有空格 -->
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
<!-- 運算符必須在前方 -->
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement">
<properties>
<property name="allowOnly" value="first" />
</properties>
</rule>
<!-- 檢查控制結構縮排 -->
<rule ref="PSR12.ControlStructures.ControlStructureSpacing"/>
<!-- 限制複合命名空間深度 -->
<rule ref="PSR12.Namespaces.CompoundNamespaceDepth"/>
<!-- 長代碼塊必須有結束註釋 -->
<rule ref="Squiz.Commenting.LongConditionClosingComment">
<properties>
<property name="commentFormat" value=" // end %s()" />
</properties>
</rule>
<!-- :前不可有空格 -->
<rule ref="Squiz.ControlStructures.ControlSignature">
<properties>
<property name="requiredSpacesBeforeColon" value="0" />
</properties>
</rule>
<!-- foreach 參數前後不可有空格 -->
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
<!-- for 參數前後不可有空格 -->
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
<!-- 檢查 function 排板 -->
<rule ref="Squiz.Functions.FunctionDeclaration"/>
<!-- 檢查 function 參數排板 -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
</rule>
<!-- .前後必須有空格 -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1" />
</properties>
</rule>
<!-- 方法間距唯一,前後必須空一行 -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="1" />
<property name="spacingAfterLast" value="1" />
</properties>
</rule>
<!-- 屬性間距唯零,前後必須空一行 -->
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
<properties>
<property name="spacing" value="0" />
<property name="spacingBeforeFirst" value="1" />
<property name="spacingAfterLast" value="1" />
</properties>
</rule>
<!-- ->前後不可有空格 -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
<!-- 運算符前後必須有空格 -->
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreSpacingBeforeAssignments" value="false" />
</properties>
</rule>
<!-- 行尾不可有空格 -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<exclude-pattern>vendor</exclude-pattern>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment