-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.phpcs.xml.dist
More file actions
152 lines (134 loc) · 7.06 KB
/
.phpcs.xml.dist
File metadata and controls
152 lines (134 loc) · 7.06 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
<?xml version="1.0"?>
<ruleset
name="GopherPress"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Code standards for the GopherPress WordPress plugin.</description>
<!-- Self-contained root — phpcs-lint.sh stops chaining here. -->
<config name="phpcs-lint-root" value="true"/>
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!-- What to scan -->
<file>.</file>
<!-- Ignoring Files and Folders:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/assets/*</exclude-pattern>
<exclude-pattern>*/proxy/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/.cache/*</exclude-pattern>
<exclude-pattern>*/index.php</exclude-pattern>
<!-- How to scan -->
<arg value="sp"/> <!-- Show sniff and progress -->
<arg name="colors"/> <!-- Show results with colors. Disable if working on Windows -->
<arg name="basepath" value="."/> <!-- Strip the file paths down to the relevant bit -->
<arg name="parallel" value="8"/> <!-- Enables parallel processing when available for faster results -->
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->
<ini name="memory_limit" value="1G"/>
<!-- Rules: Check PHP version compatibility - see
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="8.0-"/>
<!-- Rules: VIP Coding Standards - see
https://github.com/Automattic/VIP-Coding-Standards -->
<rule ref="WordPress-VIP-Go">
<exclude name="WordPressVIPMinimum.JS"/>
</rule>
<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<rule ref="WordPress-Extra"/> <!-- Includes WordPress-Core -->
<rule ref="WordPress-Docs"/>
<!-- For help in understanding this minimum_supported_wp_version:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#setting-minimum-supported-wp-version-for-all-sniffs-in-one-go-wpcs-0140 -->
<config name="minimum_supported_wp_version" value="5.9"/>
<!-- Reintroduce some whitespace rules WordPressVIPMinimum removes -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<severity>5</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine">
<severity>5</severity>
</rule>
<!-- Exclude noisy sniffs -->
<rule ref="Squiz.Commenting.FileComment.MissingPackageTag">
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
<exclude name="Squiz.Commenting.FileComment.Missing"/>
</rule>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed">
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"/>
</rule>
<!-- VIP-specific restrictions that do not apply to a standard WordPress plugin.
GopherPress uses file I/O for PID files, daemon logs, and local font loading —
all within the plugin's own upload directory or vendor path, not remote URLs.
Adjacent-post and attachment functions are used in read-only content rendering. -->
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_file_put_contents">
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_file_put_contents"/>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fwrite">
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fwrite"/>
</rule>
<rule ref="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown">
<exclude name="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown"/>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_previous_post">
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_previous_post"/>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post">
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post"/>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid">
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid"/>
</rule>
<rule ref="WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined">
<exclude name="WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined"/>
</rule>
<!-- Procedural / bootstrap files that intentionally have no namespace. -->
<rule ref="Emrikol.Namespaces.Namespace.MissingNamespace">
<exclude-pattern>gopherpress.php</exclude-pattern>
<exclude-pattern>inc/polyfills.php</exclude-pattern>
<exclude-pattern>inc/gopher-server.php</exclude-pattern>
</rule>
<!-- gopher-server.php is a standalone CLI daemon script that bootstraps WordPress
by writing to $_SERVER and uses short unambiguous local variable names.
PrefixAllGlobals and SuperglobalWrite do not apply to this context. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound">
<exclude-pattern>inc/gopher-server.php</exclude-pattern>
</rule>
<rule ref="Emrikol.PHP.DisallowSuperglobalWrite.SuperglobalWrite">
<exclude-pattern>inc/gopher-server.php</exclude-pattern>
</rule>
<!-- stream_socket_* returns a resource in PHP 8.0; PHPDoc `resource` type is correct. -->
<rule ref="Squiz.Commenting.FunctionComment.InvalidTypeHint">
<exclude-pattern>inc/gopher-server.php</exclude-pattern>
</rule>
<!-- Plugin-specific settings -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="gopherpress"/>
</property>
</properties>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="gopherpress_"/>
<element value="GOPHERPRESS_"/>
<element value="GopherPress"/>
</property>
</properties>
</rule>
<!-- Custom Sniffs — emrikol/phpcs -->
<rule ref="Emrikol"/>
<!-- WordPress presets — must come before plugin class registration so that
extend="true" below appends to the preset list rather than being overwritten by it. -->
<rule ref="vendor/emrikol/phpcs/presets/wordpress-classes.xml"/>
<rule ref="vendor/emrikol/phpcs/presets/wordpress-global-classes.xml"/>
<rule ref="vendor/emrikol/phpcs/presets/php-global-classes.xml"/>
<!-- Ignore StrictTypes for main plugin file (WordPress plugin bootstrap) -->
<rule ref="Emrikol.PHP.StrictTypes.MissingStrictTypes">
<exclude-pattern>gopherpress.php</exclude-pattern>
</rule>
</ruleset>