-
Notifications
You must be signed in to change notification settings - Fork 3
/
.phpcs.xml.dist
148 lines (118 loc) · 4.99 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
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Coding Standard for WP Test Utils" xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Check the code of WP Test Utils.</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>
<!-- Provide the plugin specific prefixes for all naming related sniffs. -->
<property name="prefixes" type="array">
<element value="Yoast\WPTestUtils"/>
</property>
</properties>
<!-- Exclude some rules which are irrelevant.
The code in this package is not run in the context of a WordPress plugin. -->
<exclude name="WordPress.DB"/>
<exclude name="WordPress.Security"/>
<exclude name="WordPress.WP"/>
<exclude name="Yoast.Yoast.JsonEncodeAlternative"/>
<exclude name="WordPressVIPMinimum"/>
<!-- Exclude select "modern PHP" sniffs, which conflict with the minimum supported PHP version of this package. -->
<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>
<!-- Enforce PSR1 compatible namespaces. -->
<rule ref="PSR1.Classes.ClassDeclaration">
<!-- YoastCS only applies this rule to test files. Overrule it to apply to all files. -->
<include-pattern>*\.php</include-pattern>
</rule>
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<rule ref="Yoast.Files.FileName">
<properties>
<property name="psr4_paths" type="array">
<element key="Yoast\WPTestUtils\Tests\\" value="tests/"/>
</property>
</properties>
<include-pattern>/tests/*\.php</include-pattern>
</rule>
<rule ref="Yoast.NamingConventions.NamespaceName">
<properties>
<property name="psr4_paths" type="array">
<element key="Yoast\WPTestUtils\\" value="src/"/>
<element key="Yoast\WPTestUtils\Tests\\" value="tests/"/>
</property>
</properties>
</rule>
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<properties>
<property name="maxColumn" value="72"/>
</properties>
</rule>
<rule ref="WordPress.PHP.NoSilencedErrors">
<properties>
<property name="customAllowedFunctionsList" type="array">
<element value="file_exists"/>
</property>
</properties>
</rule>
<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
#############################################################################
-->
<!-- Declaring a few WordPress native constants. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
<exclude-pattern>/src/BrainMonkey/bootstrap\.php$</exclude-pattern>
</rule>
<!-- These duplicate classes are by design. -->
<rule ref="Generic.Classes.DuplicateClassName">
<exclude-pattern>/src/WPIntegration/TestCase*\.php$</exclude-pattern>
</rule>
<!-- Allow for camelCase method and variable names to be more in line with PHPUnit and BrainMonkey. -->
<rule ref="WordPress.NamingConventions.ValidFunctionName">
<exclude-pattern>/src/BrainMonkey/bootstrap\.php$</exclude-pattern>
<exclude-pattern>/src/Helpers/*\.php$</exclude-pattern>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<exclude-pattern>/src/Helpers/*\.php$</exclude-pattern>
</rule>
<!-- TEST CODE -->
<!-- Final classes is irrelevant for test fixtures. -->
<rule ref="Universal.Classes.RequireFinalClass">
<exclude-pattern>/tests/*/Fixtures/*\.php$</exclude-pattern>
</rule>
<!-- Ignore word count for object names in test fixtures. -->
<rule ref="Yoast.NamingConventions.ObjectNameDepth.MaxExceeded">
<exclude-pattern>/tests/*/Fixtures/*\.php$</exclude-pattern>
</rule>
<!-- Test fixtures are not the actual tests. -->
<rule ref="Yoast.Commenting.TestsHaveCoversTag">
<exclude-pattern>/tests/*/Fixtures/*\.php$</exclude-pattern>
</rule>
</ruleset>