-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpcs.xml
More file actions
106 lines (89 loc) · 3.93 KB
/
phpcs.xml
File metadata and controls
106 lines (89 loc) · 3.93 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
<?xml version="1.0" encoding="UTF-8"?>
<phpcs>
<!--
WP GitHub Updater - PHP Coding Standards Configuration
This configuration enforces the coding standards defined in our
project instructions, specifically:
🚨 MANDATORY STANDARDS:
- ALL strings MUST use double quotes: "string" not 'string'
- WordPress security best practices (escaping, sanitization)
- Text domain validation for i18n functions
- PSR-12 compliance for modern PHP 8+ conventions
- Proper documentation standards for public APIs
Package-specific allowances:
- PSR-4 naming conventions (not WordPress file naming)
- Namespace usage instead of global prefixes
- String interpolation with variables in double quotes
- Reasonable line length limits (120/160 characters)
-->
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg value="p"/>
<!-- Show progress -->
<arg value="s"/>
<!-- Paths to check -->
<file>src</file>
<file>tests</file>
<!-- Base PSR12 standard -->
<rule ref="PSR12"/>
<!-- 🚨 CRITICAL RULE: Enforce double quotes for strings -->
<!-- This is our MANDATORY string quotation standard -->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
<!-- Allow variables in double quotes (string interpolation) -->
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<!-- WordPress Security (Critical for WordPress integration) -->
<rule ref="WordPress.Security.EscapeOutput"/>
<rule ref="WordPress.Security.ValidatedSanitizedInput"/>
<!-- Exclude WordPress.Security checks from test files -->
<rule ref="WordPress.Security">
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/fixtures/*</exclude-pattern>
</rule>
<!-- WordPress i18n (Text domain validation) -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="wp-github-updater"/>
</property>
</properties>
<!-- Allow dynamic text domains from configuration -->
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralText"/>
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralDomain"/>
</rule>
<!-- Basic Documentation (without overly strict requirements) -->
<rule ref="Squiz.Commenting.ClassComment">
<exclude name="Squiz.Commenting.ClassComment.TagNotAllowed"/>
<!-- Allow test classes without doc comments -->
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!-- Allow WordPress-style method naming for i18n wrappers -->
<rule ref="PSR1.Methods.CamelCapsMethodName">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<type>warning</type> <!-- Make this a warning instead of error -->
</rule>
<!-- Allow flexibility for package-specific conventions -->
<rule ref="WordPress.Files.FileName">
<severity>0</severity> <!-- PSR-4 naming -->
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<severity>0</severity> <!-- Namespaced package -->
</rule>
<rule ref="PSR1.Files.SideEffects">
<severity>0</severity> <!-- Test files can have side effects -->
</rule>
<!-- Allow reasonable line lengths for readability -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="160"/>
</properties>
</rule>
<!-- Exclude external dependencies -->
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>*.min.*</exclude-pattern>
</phpcs>