-
Notifications
You must be signed in to change notification settings - Fork 0
/
.phpcs.xml
130 lines (117 loc) · 5.85 KB
/
.phpcs.xml
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
<?xml version="1.0"?>
<ruleset name="RAN PluginLib Coding Standards">
<description>RAN PluginLib Modified Wordpress Coding Standards</description>
<!--
Setup instructions:
1) Install PHPCS & all required code standards using `composer install`
2) Run `composer run lint`. You can use the `-a` flag to run it interactively.
See these links for useful information:
- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
- https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md
- https://github.com/slevomat/coding-standard/blob/master/doc/classes.md
-->
<config name="minimum_supported_wp_version" value="6.0.0"/>
<!-- Scan all files in directory -->
<file>.</file>
<!-- Scan only PHP files -->
<arg name="extensions" value="php"/>
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Show sniff codes in all reports -->
<arg value="ns"/>
<!-- Exclude WP Core folders and files from being checked. -->
<exclude-pattern>/docroot/wp-admin/*</exclude-pattern>
<exclude-pattern>/docroot/wp-includes/*</exclude-pattern>
<exclude-pattern>/docroot/wp-*.php</exclude-pattern>
<exclude-pattern>/docroot/index.php</exclude-pattern>
<exclude-pattern>/docroot/xmlrpc.php</exclude-pattern>
<exclude-pattern>/docroot/wp-content/plugins/*</exclude-pattern>
<!-- Exclude the Composer Vendor directory. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<!-- Exclude the Node Modules directory. -->
<exclude-pattern>/node_modules/*</exclude-pattern>
<!-- Exclude minified Javascript files. -->
<exclude-pattern>*.min.js</exclude-pattern>
<!-- Check for PHP cross-version compatibility. -->
<!--
To enable this, the PHPCompatibilityWP standard needs
to be installed.
See the readme for installation instructions:
https://github.com/PHPCompatibility/PHPCompatibilityWP
For more information, also see:
https://github.com/PHPCompatibility/PHPCompatibility
-->
<!--
<config name="testVersion" value="5.2-"/>
<rule ref="PHPCompatibilityWP"/>
-->
<!--
WPCS custom properties.
https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
-->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="ran_plugLib"/>
</property>
</properties>
</rule>
<!-- WordPress-Extra is a superset of WordPress-Core rules with recomended best practices. -->
<rule ref="WordPress-Extra">
<!--
Modify WordPress-CS by adding an entire ruleset, then rule by rule, remove ones that don't suit a project.
Running `phpcs` with the '-s' flag, to identify the names of the sniffs reporting errors.
We can opt to exclude sniffs which don't suit our project like so:
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing"/>
<exclude name="WordPress.Security.EscapeOutput"/>
-->
<!-- Exceptions for PRS-4 autoloading -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<!-- Exception for Short Ternary -->
<exclude name="Universal.Operators.DisallowShortTernary"/>
</rule>
<!-- Check that everything is properly documented. -->
<rule ref="WordPress-Docs"/>
<!-- Rules adopted from other standards. -->
<!-- Generic rules from CS -->
<!-- Class opening braces should be on the same line as the statement. -->
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
<!-- Braces should always be used, even when they are not required. -->
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<!-- Warn about unused function params. -->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<!-- Warn about @todo comments -->
<rule ref="Generic.Commenting.Todo"/>
<!-- Warn about @fixme comments -->
<rule ref="Generic.Commenting.Fixme"/>
<!-- Braces shall be used for all blocks. -->
<rule ref="Squiz.ControlStructures.ControlSignature"/>
<!-- SlevomatCodingStandard for type hinting -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint" /> -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition" />
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
<!-- SlevomatCodingStandard Class & Trait snifs -->
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature" />
<!-- Review these notion of class/Interface nameing. -->
<!-- https://phpixie.com/blog/naming-interfaces-in-php.html -->
<!-- https://www.reddit.com/r/PHP/comments/2kk4v2/naming_interfaces_in_php_or_why_you_shouldnt_use/ -->
<!-- <rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" /> -->
<!-- <rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" /> -->
<!-- <rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming" /> -->
<!-- <rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming" /> -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration" />
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing" />
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />
</ruleset>