-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphpcs.xml
More file actions
171 lines (146 loc) · 6.5 KB
/
phpcs.xml
File metadata and controls
171 lines (146 loc) · 6.5 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0"?>
<ruleset name="Body Refactoring Coding Standards">
<description>Custom ruleset based on WordPress Coding Standards for Body Refactoring</description>
<!-- What to scan -->
<file>consent.php</file>
<file>deploy.php</file>
<file>index.php</file>
<file>login.php</file>
<file>logout.php</file>
<file>schedule-editor.php</file>
<file>tools.php</file>
<file>assets/</file>
<file>schedules/</file>
<!-- Only scan PHP files (JS/CSS handled by ESLint/Stylelint) -->
<arg name="extensions" value="php"/>
<!-- Show progress and colors -->
<arg value="ps"/>
<arg name="colors"/>
<!-- Show sniff codes in all reports -->
<arg value="ns"/>
<!-- Strip file paths for readability -->
<arg name="basepath" value="."/>
<!-- Check for cross-version support -->
<config name="testVersion" value="8.3-"/>
<rule ref="PHPCompatibilityWP">
<include-pattern>*\.php$</include-pattern>
</rule>
<!-- Use WordPress Extra as base (includes WordPress-Core) -->
<rule ref="WordPress-Extra">
<!-- Allow short array syntax -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<!-- Allow short ternary -->
<exclude name="Universal.Operators.DisallowShortTernary"/>
<!-- Allow file names without prefix (not a plugin) -->
<exclude name="WordPress.Files.FileName"/>
<!-- Allow non-prefixed hooks (not a plugin) -->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals"/>
<!-- Disallow Yoda conditions -->
<exclude name="WordPress.PHP.YodaConditions"/>
<!-- Allow short open echo tags -->
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound"/>
<exclude name="Squiz.PHP.EmbeddedPhp.ShortOpenEchoNoSemicolon"/>
<!-- Do not enforce alignment -->
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"/>
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned"/>
<!-- Not a WordPress plugin - no enqueue system -->
<exclude name="WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet"/>
<exclude name="WordPress.WP.EnqueuedResources.NonEnqueuedScript"/>
<!-- Standalone app - escaping handled differently -->
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped"/>
<!-- Standalone app - no WordPress nonce/sanitization system -->
<exclude name="WordPress.Security.ValidatedSanitizedInput.MissingUnslash"/>
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized"/>
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotValidated"/>
<exclude name="WordPress.Security.NonceVerification.Missing"/>
<!-- Standalone app - PHP native functions OK -->
<exclude name="WordPress.DateTime.RestrictedFunctions.date_date"/>
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/>
</rule>
<!-- Use WordPress Documentation standards for comments -->
<rule ref="WordPress-Docs">
<!-- Exclude in favour of YoastCS FileComment sniff -->
<exclude name="Squiz.Commenting.FileComment"/>
</rule>
<!-- Yoast FileComment exclusions (extends Squiz sniff) -->
<rule ref="Yoast.Commenting.FileComment">
<exclude name="Yoast.Commenting.FileComment.IncorrectAuthor"/>
<exclude name="Yoast.Commenting.FileComment.IncorrectCopyright"/>
<exclude name="Yoast.Commenting.FileComment.MissingAuthorTag"/>
<exclude name="Yoast.Commenting.FileComment.MissingSubpackageTag"/>
<exclude name="Yoast.Commenting.FileComment.MissingCopyrightTag"/>
<exclude name="Yoast.Commenting.FileComment.PackageTagOrder"/>
<exclude name="Yoast.Commenting.FileComment.SubpackageTagOrder"/>
<exclude name="Yoast.Commenting.FileComment.AuthorTagOrder"/>
<exclude name="Yoast.Commenting.FileComment.CopyrightTagOrder"/>
</rule>
<!-- Disallow Yoda conditions -->
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
<!-- Disallow long array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Enforce tab indentation -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<!-- Require docblocks for all functions -->
<rule ref="Squiz.Commenting.FunctionComment">
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
</rule>
<!-- Inline comment end char as warning instead of error -->
<rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
<type>warning</type>
</rule>
<!-- Line length -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
<!-- Enforce concatenation operators at start of line in multi-line -->
<rule ref="Universal.Operators.ConcatPosition"/>
<!-- Forbid long closures (max 5 lines) -->
<rule ref="Universal.FunctionDeclarations.NoLongClosures">
<properties>
<property name="maxLines" value="5"/>
</properties>
<exclude name="Universal.FunctionDeclarations.NoLongClosures.ExceedsRecommended"/>
</rule>
<!-- Enforce return type hints -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableObjectTypeHint" value="true"/>
<property name="enableMixedTypeHint" value="true"/>
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<!-- Enforce parameter type hints -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="enableObjectTypeHint" value="true"/>
<property name="enableMixedTypeHint" value="true"/>
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<!-- Enforce property type hints -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation"/>
</rule>
<!-- Enforce alphabetically sorted use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="psr12Compatible" value="true"/>
<property name="caseSensitive" value="false"/>
</properties>
</rule>
<!-- Disallow unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Disallow use const/function statements -->
<rule ref="Universal.UseStatements.DisallowUseConst"/>
<rule ref="Universal.UseStatements.DisallowUseFunction"/>
<!-- PSR-1 class declaration -->
<rule ref="PSR1.Classes.ClassDeclaration"/>
</ruleset>