-
Notifications
You must be signed in to change notification settings - Fork 8
/
.phpcs.xml.dist
154 lines (122 loc) · 5.88 KB
/
.phpcs.xml.dist
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
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Yoast WHIP"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Yoast WHIP rules for PHP_CodeSniffer</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<file>.</file>
<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>
<!-- Cache the results between runs. -->
<arg name="cache" value="./.cache/phpcs.cache"/>
<!--
#############################################################################
USE THE YoastCS RULESET
#############################################################################
-->
<rule ref="Yoast">
<properties>
<!-- Set the minimum supported WP version for all sniff which use it in one go. -->
<property name="minimum_wp_version" value="3.0"/>
<!-- Provide the plugin specific prefixes for all naming related sniffs. -->
<property name="prefixes" type="array">
<element value="Yoast\WHIP"/>
<element value="Yoast\WHIPv2"/>
<element value="whip"/>
</property>
<property name="psr4_paths" type="array">
<element key="Yoast\WHIPv2\\" value="src/"/>
<element key="Yoast\WHIP\Tests\\" value="tests/"/>
</property>
</properties>
<!-- Historically, this library has used camelCaps not snakecase for variable and function names. -->
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="WordPress.NamingConventions.ValidFunctionName"/>
<!-- Exclude select "modern PHP" sniffs, which conflict with the minimum supported PHP version of this package. -->
<exclude name="SlevomatCodingStandard.Functions.StaticClosure"/><!-- PHP 5.4+ -->
<exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference"/><!-- PHP 5.5+ -->
<exclude name="Modernize.FunctionCalls.Dirname.Nested"/><!-- PHP 7.0+. -->
<exclude name="PSR12.Properties.ConstantVisibility"/><!-- PHP 7.1+. -->
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/><!-- PHP 7.1+. -->
</rule>
<!-- Check that variable names are in camelCaps. -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<!-- Private properties should, however, *not* start with an underscore. -->
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
</rule>
<!-- Check that function and method names are in camelCaps. -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName">
<properties>
<!-- Allow for two adjacent capital letters for acronyms. -->
<property name="strict" value="false"/>
</properties>
<!-- Exclude WordPress example function. -->
<exclude-pattern>/src/Facades/wordpress\.php$</exclude-pattern>
<!-- Exclude mocks of WP Core functions which comply with the WP function name rules instead. -->
<exclude-pattern>/tests/Unit/Doubles/WpCoreFunctionsMock\.php$</exclude-pattern>
</rule>
<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
#############################################################################
-->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<!-- Valid usage: For testing purposes, allow non-prefixed globals. -->
<exclude-pattern>/tests/Unit/Doubles/WPCoreFunctionsMock\.php$</exclude-pattern>
</rule>
<rule ref="Yoast.NamingConventions.ValidHookName.WrongPrefix">
<!-- Valid usage: Example code for external users of the module. -->
<exclude-pattern>/src/Facades/wordpress\.php$</exclude-pattern>
</rule>
<!-- The variable parameters passed to the WHIP exceptions are mostly used to retrieve
the _type_ of the variable. Additionally, we may not be in a WP context. -->
<rule ref="WordPress.Security.EscapeOutput.ExceptionNotEscaped">
<severity>0</severity>
</rule>
<rule ref="Yoast.Files.FileName.InvalidFunctionsFileName">
<exclude-pattern>/src/Facades/wordpress\.php$</exclude-pattern>
<exclude-pattern>/tests/Unit/Doubles/WPCoreFunctionsMock\.php$</exclude-pattern>
</rule>
<!--
#############################################################################
TEMPORARY TWEAK
YoastCS demands short arrays (PHP 5.4), but the WHIP module still supports PHP 5.3.
#############################################################################
-->
<rule ref="Universal.Arrays.DisallowShortArraySyntax">
<severity>5</severity>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax">
<severity>0</severity>
</rule>
<!--
#############################################################################
TEMPORARY ADJUSTMENTS
Adjustments which should be removed once the associated issue has been resolved.
#############################################################################
-->
<!-- Textdomain is passed in dynamically which will not work correctly with gettext().
Ticket: https://github.com/Yoast/whip/issues/2 -->
<rule ref="WordPress.WP.I18n.NonSingularStringLiteralDomain">
<exclude-pattern>/src/Messages/HostMessage\.php$</exclude-pattern>
<exclude-pattern>/src/Messages/UpgradePhpMessage\.php$</exclude-pattern>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound">
<!-- These hook setups should be reviewed.
Ticket: https://github.com/Yoast/whip/issues/67 -->
<exclude-pattern>/src/Host\.php$</exclude-pattern>
<exclude-pattern>/src/Messages/UpgradePhpMessage\.php$</exclude-pattern>
</rule>
</ruleset>