-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpcs.xml.dist
More file actions
190 lines (167 loc) · 7.81 KB
/
Copy pathphpcs.xml.dist
File metadata and controls
190 lines (167 loc) · 7.81 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="conta-azul-cli">
<description>Coding standard for the Conta Azul CLI, based on the Doctrine Coding Standard with 2-space indentation.</description>
<arg name="extensions" value="php"/>
<!-- Project indentation uses spaces, with a tab expanded to two columns. -->
<arg name="tab-width" value="2"/>
<file>./src</file>
<file>./tests</file>
<file>./bin</file>
<file>./phpcs-sniffs</file>
<file>./tools</file>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<rule ref="Doctrine">
<!--
Squiz.Arrays.ArrayDeclaration.ValueNoNewline misfires on arrow
functions used as the first value in a multi-line array: it flags
lines that are already correctly split, and phpcbf's fix for it
inserts a newline in the middle of the "fn" token, corrupting the
file. Reproduced against a minimal case on squizlabs/php_codesniffer
3.13.6; not specific to this project's ruleset overrides.
-->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline"/>
<!--
Doctrine forbids "Interface"/"Exception" name suffixes. This project
follows the Symfony convention instead (HttpClientInterface, etc.,
already used by its dependencies), so both are kept off.
-->
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<!--
Squiz.Commenting.FunctionComment cannot parse the parameter name out of
a @param tag whose type is a multi-line PHPStan/Psalm array shape
(array{...} split across lines): it reports a false "Missing parameter
name". Reproduced with a minimal multi-line array{} case against
squizlabs/php_codesniffer 3.13.6; single-line array shapes parse fine.
This project documents wide config/payload shapes this way, so the
sniff is disabled rather than flattening those docblocks to one line.
-->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamName"/>
</rule>
<!--
Doctrine/PSR-12 default to 4-space indentation. This project uses 2, so
the two sniffs that own indent width are overridden here; everything
else about scope/array indentation (brace alignment, continuation
lines, etc.) is inherited from Doctrine unchanged.
-->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2" />
<property name="tabIndent" value="false" />
<property name="exact" value="true" />
</properties>
</rule>
<rule ref="Generic.Arrays.ArrayIndent">
<properties>
<property name="indent" value="2" />
</properties>
</rule>
<!--
Doctrine excludes double-arrow alignment wholesale (its comment says
"disable arrow alignment"). This project wants the same vertical
alignment for "=>" in multi-line arrays that Generic.Formatting.
MultipleStatementAlignment already enforces for "=" in sequential
assignments, so re-include just that one error code. A bare
<rule ref> here is not enough to undo an <exclude> from a nested
standard (Doctrine's own exclude still wins); setting the severity
explicitly is what actually re-enables it. KeyNotAligned and
ValueNotAligned stay excluded: KeyNotAligned fights this project's
2-space Generic.Arrays.ArrayIndent (Doctrine's own comment notes it
"uses indentation of only single space"), and ValueNotAligned isn't
part of what was asked for.
-->
<rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
<severity>5</severity>
</rule>
<!--
Doctrine/PSR-12 place a function or method's opening brace on its own
line (BSD-Allman). This is enforced by Squiz.Functions.
MultiLineFunctionDeclaration, which for single-line declarations
internally instantiates Generic.Functions.OpeningFunctionBraceBsdAllman
and calls it directly, bypassing normal sniff registration. So the
violation is actually recorded under
Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine, not under
the Generic sniff's own code. Confirmed with a minimal repro; silencing
Generic.Functions.OpeningFunctionBraceBsdAllman directly has no effect
and leaves it fighting the Kernighan-Ritchie sniff below in an
unresolvable phpcbf loop. Closures are unaffected: PEAR's
FunctionDeclaration sniff already applies K&R to them regardless.
-->
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
<severity>0</severity>
</rule>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<!--
Doctrine does not reference this Slevomat sniff. Multi-line arrays where
every item has an explicit key must have those keys in alphabetical
order, so a specific property is easy to scan for. Arrays with any
unkeyed item (list-style) are left alone, since order is semantically
meaningful there.
-->
<rule ref="SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys"/>
<!-- Project-specific sniffs with no Doctrine equivalent. -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="absoluteNestingLevel" value="99" />
<property name="nestingLevel" value="8" />
</properties>
</rule>
<rule ref="Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase">
<type>warning</type>
</rule>
<rule ref="Generic.PHP.DiscourageGoto">
<type>error</type>
</rule>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<!--
Doctrine already forbids the classic PHP alias functions (chop, sizeof,
is_null, etc). The project-specific additions layered on top are
eval/extract/ob_end_flush/ob_flush/ob_get_flush, which are security- or
output-buffering-sensitive in a Symfony CLI context. Re-declaring the
sniff replaces its property array wholesale, so Doctrine's list is
repeated here rather than merged automatically.
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="eval" value="null"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="ob_end_flush" value="ob_get_clean"/>
<element key="ob_flush" value="null"/>
<element key="ob_get_flush" value="ob_get_clean"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops">
<type>warning</type>
</rule>
<!-- Local reimplementation of ISDrupal.Functions.DebuggingFunctions. -->
<rule ref="./phpcs-sniffs/ContaAzulCli/Sniffs/Functions/DebuggingFunctionsSniff.php">
<type>error</type>
</rule>
</ruleset>