-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathphpcs.xml.dist
More file actions
138 lines (107 loc) · 6.12 KB
/
phpcs.xml.dist
File metadata and controls
138 lines (107 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?xml version="1.0" ?>
<ruleset name="WordPress.org Coding Standards">
<description>Apply customized version of WordPress Coding Standards to WordPress.org PHP scripts.</description>
<!-- Show sniff codes in all reports -->
<arg value="ps" />
<arg name="colors" />
<!-- Exclude 3rd-party files -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/plugins/plugin-directory/libs/*</exclude-pattern>
<exclude-pattern>*/plugins/theme-directory/lib/*</exclude-pattern>
<exclude-pattern>*/plugins/wpf-stripe/stripe-php/*</exclude-pattern>
<!-- Exclude JS/CSS files. -->
<exclude-pattern>*.js[x]?</exclude-pattern>
<exclude-pattern>*.[s]?css</exclude-pattern>
<!-- Scan all (php) files in the current folder and subfolders -->
<file>.</file>
<arg name="extensions" value="php" />
<!-- WordPress.org runs recent versions of WordPress. -->
<config name="minimum_wp_version" value="6.9"/>
<!-- Check for PHP cross-version compatibility. -->
<config name="testVersion" value="8.4-"/>
<rule ref="PHPCompatibilityWP"/>
<rule ref="WordPress-Core">
<!-- Allow embedded PHP tags on a single line. -->
<exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterOpen" />
<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd" />
<!-- Class file names are not always predictable. -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<!-- Translators comments are a judgement call. -->
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment" />
<!-- Not practical for a large and varied codebase. -->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound" />
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound" />
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound" />
<!-- Aligning things can make the code more readable. -->
<exclude name="WordPress.WhiteSpace.PrecisionAlignment.Found" />
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma" />
<exclude name="WordPress.WhiteSpace.OperatorSpacing.SpacingBefore" />
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.SpaceBeforeArrayCloser" />
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" />
<exclude name="Squiz.Strings.ConcatenationSpacing.PaddingFound" />
<!-- There are cases where having multiple items on a single line is appropriate. -->
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine" />
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
<!-- Short array syntax is already used throughout the codebase. -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<!-- The <?php and ?> tags can be on a line with content in templates. -->
<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeOpen" />
<exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterEnd" />
<!-- trigger_error() is used for logging in production. -->
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_trigger_error" />
<!-- print_r() is acceptable in CLI and debugging contexts. -->
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_print_r" />
<!-- Warn about mis-aligned array items, but don't automatically "fix" them. -->
<exclude phpcbf-only="true" name="PEAR.Functions.FunctionCallSignature" />
</rule>
<rule ref="WordPress-Docs">
<!-- Descriptive names make explicit comments unnecessary in many cases. -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Squiz.Commenting.VariableComment.Missing" />
<exclude name="Squiz.Commenting.VariableComment.MissingVar" />
<!-- Requiring full stops on inline/param comments is pedantic. -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
<!-- Package tags add clutter without value. -->
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
<!-- We only use basic exceptions. -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" />
<!-- Whitespace makes things more readable. -->
<exclude name="Squiz.Commenting.FileComment.SpacingAfterOpen" />
<!-- Valid in some cases like closing tags from another file. -->
<exclude name="Squiz.Commenting.InlineComment.SpacingAfter" />
<!-- Not wrong for WordPress plugin file headers. -->
<exclude name="Squiz.Commenting.FileComment.WrongStyle" />
<!-- Class comments are often omitted, causing PHPCS to confuse plugin headers for class comments. -->
<exclude name="Squiz.Commenting.ClassComment.WrongStyle" />
<exclude name="Squiz.Commenting.ClassComment.SpacingAfter" />
<!-- WordPress translators comments require no space after //. -->
<exclude name="Squiz.Commenting.InlineComment.NoSpaceBefore" />
</rule>
<!-- Commented-out code is sometimes intentional for reference. -->
<rule ref="Squiz.PHP.CommentedOutCode.Found">
<severity>0</severity>
</rule>
<!-- Custom capabilities are valid in the WordPress.org environment. -->
<rule ref="WordPress.WP.Capabilities.Unknown">
<severity>0</severity>
</rule>
<rule ref="WordPress-Extra">
<!-- Allow use statements right after namespace. -->
<exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter" />
<!-- Allow short ternary operator (?:). -->
<exclude name="Universal.Operators.DisallowShortTernary" />
<!-- Nonce verification is often handled at a higher level. -->
<exclude name="WordPress.Security.NonceVerification.Missing" />
<exclude name="WordPress.Security.NonceVerification.Recommended" />
</rule>
</ruleset>