11<?xml version =" 1.0" ?>
22<ruleset name =" WordPress Coding Standards for Plugins" >
3- <description >Generally-applicable sniffs for WordPress plugins</description >
4-
5- <!--
6- #############################################################################
7- COMMAND LINE ARGUMENTS
8- https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
9- #############################################################################
10- -->
11-
12- <file >.</file >
13-
14- <!-- Only check PHP files. -->
15- <arg name =" extensions" value =" php" />
16-
17- <!-- Show progress, show the error codes for each message (source). -->
18- <arg value =" ps" />
19-
20- <!-- Strip the filepaths down to the relevant bit. 加入這行就會失效了 -->
21- <!-- <arg name="basepath" value="."/> -->
22-
23- <!-- Check up to 8 files simultaneously. -->
24- <arg name =" parallel" value =" 8" />
25-
26- <rule ref =" WordPress-Core" >
27- <exclude name =" Squiz.Commenting.FileComment.MissingPackageTag" />
28- <exclude name =" WordPress.PHP.DevelopmentFunctions.error_log_print_r" />
29- </rule >
30- <rule ref =" WordPress-Docs" >
31- <exclude-pattern >*/tests/*</exclude-pattern >
32- </rule >
33- <rule ref =" WordPress-Extra" />
34- <rule ref =" WordPress" >
35- <exclude name =" WordPress.Files.FileName" />
36- <exclude name =" WordPress.PHP.YodaConditions.NotYoda" />
37- <exclude name =" Generic.Arrays.DisallowShortArraySyntax" />
38- <exclude name =" WordPress.Security.EscapeOutput.OutputNotEscaped" />
39- <exclude name =" PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" />
40- <exclude name =" PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" />
41- <exclude name =" WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" />
42- <exclude name =" WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore" />
43- <exclude name =" WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter" />
44- <exclude name =" WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis" />
45-
46- </rule >
47-
48- <exclude-pattern >./release/*</exclude-pattern >
49- <exclude-pattern >*/node_modules/*</exclude-pattern >
50- <exclude-pattern >*/vendor/*</exclude-pattern >
51- <exclude-pattern >*/tests/*</exclude-pattern >
52- <rule ref =" Generic.WhiteSpace.ScopeIndent" >
53- <properties >
54- <property name =" indent" value =" 4" />
55- <property name =" exact" value =" true" />
56- <property name =" tabIndent" value =" true" />
57- </properties >
58- </rule >
59-
60- <config name =" testVersion" value =" 8.0-" />
61- <rule ref =" PHPCompatibility" />
62-
63- <!-- Enforce PSR1 compatible namespaces. -->
64- <rule ref =" PSR1.Classes.ClassDeclaration" />
65-
66- <!-- Enforce that classes are abstract or final. -->
67- <rule ref =" Universal.Classes.RequireFinalClass" >
68- <!-- ... with the exception of four sniffs which are known to be extended by external standards. -->
69- <exclude-pattern >/WordPress/Sniffs/NamingConventions/ValidHookNameSniff\.php$</exclude-pattern >
70- <exclude-pattern >/WordPress/Sniffs/Security/(EscapeOutput|NonceVerification|ValidatedSanitizedInput)Sniff\.php$</exclude-pattern >
71- </rule >
72-
73- <!-- Enforce that methods in traits are always final. -->
74- <rule ref =" Universal.FunctionDeclarations.RequireFinalMethodsInTraits" />
75-
76- <!--
77- #############################################################################
78- SNIFF SPECIFIC CONFIGURATION
79- #############################################################################
80- -->
81-
82- <rule ref =" WordPress.Arrays.MultipleStatementAlignment" >
83- <properties >
84- <property name =" alignMultilineItems" value =" !=100" />
85- <property name =" exact" value =" true" phpcs-only =" true" />
86- </properties >
87- </rule >
88-
89- <!-- exclude Full-Stop comment style -->
90- <rule ref =" Squiz.Commenting.FunctionComment" >
91- <exclude name =" Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
92- <exclude name =" Squiz.Commenting.InlineComment.InvalidEndChar" />
93- </rule >
94-
95- <!-- Allow short syntax arrays. -->
96- <rule ref =" Generic.Arrays.DisallowLongArraySyntax" />
97- <rule ref =" Universal.Arrays.DisallowShortArraySyntax.Found" >
98- <severity >0</severity >
99- </rule >
100- <!-- Disallow long array syntax -->
101- <rule ref =" Generic.Arrays.DisallowShortArraySyntax.Found" >
102- <exclude-pattern >*</exclude-pattern >
103- </rule >
104-
105-
106- <rule ref =" Generic.Files.LineEndings" >
107- <exclude name =" Generic.Files.LineEndings.InvalidEOLChar" />
108- </rule >
109-
110- <!-- 允許單行 <?php. -->
111- <rule ref =" Squiz.PHP.EmbeddedPhp.ContentAfterOpen" >
112- <severity >0</severity >
113- </rule >
114-
3+ <description >Generally-applicable sniffs for WordPress plugins</description >
4+
5+ <!--
6+ #############################################################################
7+ COMMAND LINE ARGUMENTS
8+ https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
9+ #############################################################################
10+ -->
11+
12+ <file >.</file >
13+
14+ <!-- Only check PHP files. -->
15+ <arg name =" extensions" value =" php" />
16+
17+ <!-- Show progress, show the error codes for each message (source). -->
18+ <arg value =" ps" />
19+
20+ <!-- Strip the filepaths down to the relevant bit. 加入這行就會失效了 -->
21+ <!-- <arg name="basepath" value="."/> -->
22+
23+ <!-- Check up to 8 files simultaneously. -->
24+ <arg name =" parallel" value =" 8" />
25+
26+ <rule ref =" WordPress-Core" >
27+ <exclude name =" Squiz.Commenting.FileComment.MissingPackageTag" />
28+ <exclude name =" WordPress.PHP.DevelopmentFunctions.error_log_print_r" />
29+ </rule >
30+ <rule ref =" WordPress-Docs" >
31+ <exclude-pattern >*/tests/*</exclude-pattern >
32+ </rule >
33+ <rule ref =" WordPress-Extra" />
34+ <rule ref =" WordPress" >
35+ <exclude name =" WordPress.Files.FileName" />
36+ <exclude name =" WordPress.PHP.YodaConditions.NotYoda" />
37+ <exclude name =" Generic.Arrays.DisallowShortArraySyntax" />
38+ <exclude name =" WordPress.Security.EscapeOutput.OutputNotEscaped" />
39+ <exclude name =" PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" />
40+ <exclude name =" PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" />
41+ <exclude name =" WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" />
42+ <exclude name =" WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore" />
43+ <exclude name =" WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter" />
44+ <exclude name =" WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis" />
45+ <exclude name =" WordPress.DateTime.RestrictedFunctions.date_date" />
46+ <exclude name =" Generic.Commenting.DocComment.MissingShort" />
47+ <exclude name =" PEAR.Functions.FunctionCallSignature.Indent" />
48+ </rule >
49+
50+ <exclude-pattern >.idea/*</exclude-pattern >
51+ <exclude-pattern >js/*</exclude-pattern >
52+ <exclude-pattern >./release/*</exclude-pattern >
53+ <exclude-pattern >*/node_modules/*</exclude-pattern >
54+ <exclude-pattern >*/vendor/*</exclude-pattern >
55+ <exclude-pattern >*/tests/*</exclude-pattern >
56+ <rule ref =" Generic.WhiteSpace.ScopeIndent" >
57+ <properties >
58+ <property name =" indent" value =" 4" />
59+ <property name =" exact" value =" true" />
60+ <property name =" tabIndent" value =" true" />
61+ </properties >
62+ </rule >
63+
64+ <config name =" testVersion" value =" 8.0-" />
65+ <rule ref =" PHPCompatibility" />
66+
67+ <!-- Enforce PSR1 compatible namespaces. -->
68+ <rule ref =" PSR1.Classes.ClassDeclaration" />
69+
70+ <!-- Enforce that classes are abstract or final. -->
71+ <rule ref =" Universal.Classes.RequireFinalClass" >
72+ <!-- ... with the exception of four sniffs which are known to be extended by external standards. -->
73+ <exclude-pattern >/WordPress/Sniffs/NamingConventions/ValidHookNameSniff\.php$</exclude-pattern >
74+ <exclude-pattern >
75+ /WordPress/Sniffs/Security/(EscapeOutput|NonceVerification|ValidatedSanitizedInput)Sniff\.php$
76+ </exclude-pattern >
77+ </rule >
78+
79+ <!-- Enforce that methods in traits are always final. -->
80+ <rule ref =" Universal.FunctionDeclarations.RequireFinalMethodsInTraits" />
81+
82+ <!--
83+ #############################################################################
84+ SNIFF SPECIFIC CONFIGURATION
85+ #############################################################################
86+ -->
87+
88+ <rule ref =" WordPress.Arrays.MultipleStatementAlignment" >
89+ <properties >
90+ <property name =" alignMultilineItems" value =" !=100" />
91+ <property name =" exact" value =" true" phpcs-only =" true" />
92+ </properties >
93+ </rule >
94+
95+ <!-- exclude Full-Stop comment style -->
96+ <rule ref =" Squiz.Commenting.FunctionComment" >
97+ <exclude name =" Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
98+ <exclude name =" Squiz.Commenting.InlineComment.InvalidEndChar" />
99+ </rule >
100+
101+ <!-- Allow short syntax arrays. -->
102+ <rule ref =" Generic.Arrays.DisallowLongArraySyntax" />
103+ <rule ref =" Universal.Arrays.DisallowShortArraySyntax.Found" >
104+ <severity >0</severity >
105+ </rule >
106+ <!-- Disallow long array syntax -->
107+ <rule ref =" Generic.Arrays.DisallowShortArraySyntax.Found" >
108+ <exclude-pattern >*</exclude-pattern >
109+ </rule >
110+
111+
112+ <rule ref =" Generic.Files.LineEndings" >
113+ <exclude name =" Generic.Files.LineEndings.InvalidEOLChar" />
114+ </rule >
115+
116+ <!-- 允許單行 <?php. -->
117+ <rule ref =" Squiz.PHP.EmbeddedPhp.ContentAfterOpen" >
118+ <severity >0</severity >
119+ </rule >
115120
116121</ruleset >
0 commit comments