forked from yuannancheng/fictional-university
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.phpcs-example.xml
452 lines (389 loc) · 16.3 KB
/
.phpcs-example.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<?xml version="1.0"?>
<ruleset name="Custom Standard" namespace="MyProject\CS\Standard">
<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument.
If you have custom sniffs, and they use a namespace prefix
that is different to the name of the directory containing
your ruleset.xml file, you can set the namespace prefix using
the namespace attribute of the ruleset tag.
For example, if your namespace format for sniffs is
MyProject\CS\Standard\Sniffs\Category, set the namespace to
MyProject\CS\Standard (everything up to \Sniffs\)
显示规则集标签的名称属性
使用 -v 命令行运行 PHP_CodeSniffer 时的参数。
如果您有自定义嗅探,并且它们使用命名空间前缀
这与包含的目录的名称不同
您的ruleset.xml文件中,您可以使用设置命名空间前缀
规则集标签的命名空间属性。
例如,如果您的嗅探命名空间格式是
MyProject\CS\Standard\Sniffs\Category,将命名空间设置为
MyProject\CS\Standard(直到 \Sniffs\ 为止的所有内容)
-->
<!--
The content of the description tag is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
描述标签的内容没有显示在任何地方
除了在此文件中,因此它可以包含以下信息
将来可能会更改此文件的开发人员。
-->
<description>A custom coding standard</description>
<!--
You can hard-code config values used by sniffs directly
into your custom standard. Note that this does not work
for config values that override command line arguments,
such as show_warnings and report_format.
The following tag is equivalent to the command line argument:
--runtime-set zend_ca_path /path/to/ZendCodeAnalyzer
您可以直接对嗅探使用的配置值进行硬编码
纳入您的定制标准。 请注意,这不起作用
对于覆盖命令行参数的配置值,
例如 show_warnings 和 reports_format。
以下标记相当于命令行参数:
--runtime-set zend_ca_path /path/to/ZendCodeAnalyzer
-->
<config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer"/>
<!--
If no files or directories are specified on the command line
your custom standard can specify what files should be checked
instead.
Note that file and directory paths specified in a ruleset are
relative to the ruleset's location, and that specifying any file or
directory path on the command line will ignore all file tags.
-->
<file>./path/to/directory</file>
<file>./path/to/file.php</file>
<!--
You can hard-code ignore patterns directly into your
custom standard so you don't have to specify the
patterns on the command line.
The following two tags are equivalent to the command line argument:
--ignore=*/tests/*,*/data/*
-->
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/data/*</exclude-pattern>
<!--
Patterns can be specified as relative if you would
like the relative path of the file checked instead of the
full path. This can sometimes help with portability.
The relative path is determined based on the paths you
pass into PHP_CodeSniffer on the command line.
-->
<exclude-pattern type="relative">^/tests/*</exclude-pattern>
<exclude-pattern type="relative">^/data/*</exclude-pattern>
<!--
You can hard-code command line values into your custom standard.
Note that this does not work for the command line values:
-v[v][v], -l, -d, --sniffs and --standard
The following tags are equivalent to the command line arguments:
--extensions=php,inc --report=summary --colors -sp
-->
<arg name="extensions" value="php,inc" />
<arg name="report" value="summary"/>
<arg name="colors"/>
<arg value="sp"/>
<!--
You can hard-code custom php.ini settings into your custom standard.
The following tag sets the memory limit to 64M.
-->
<ini name="memory_limit" value="64M"/>
<!--
If your helper classes need custom autoloading rules that you are
not able to include in other ways, you can hard-code files to include
before the ruleset is processed and any sniff classes have been loaded.
Note that autoload file paths are relative to the ruleset's location.
This is different to bootstrap files, which are loaded after the ruleset
has already been processed.
-->
<autoload>/path/to/autoload.php</autoload>
<autoload>/path/to/other/autoload.php</autoload>
<autoload>./autoload.php</autoload>
<!--
Include all sniffs in the PEAR standard. Note that the
path to the standard does not have to be specified as the
PEAR standard exists inside the PHP_CodeSniffer install
directory.
包括 PEAR 标准中的所有嗅探。 请注意,不必指定标准的路径,因为 PEAR 标准
存在于 PHP_CodeSniffer 安装目录中。
-->
<rule ref="PEAR"/>
<!--
Include all sniffs in an external standard directory. Note
that we have to specify the full path to the standard's
directory because it does not exist inside the PHP_CodeSniffer
install directory.
将所有嗅探包含在外部标准目录中。 请注意,我们必须指定标准目录的完整路径,
因为它不存在于 PHP_CodeSniffer 安装目录中。
-->
<rule ref="/home/username/standards/mystandard"/>
<!--
Include everything in another ruleset.xml file. This is
really handy if you want to customise another developer's
custom standard. They just need to distribute their single
ruleset file to allow this.
-->
<rule ref="/home/username/standards/custom.xml"/>
<!--
Relative paths can also be used everywhere absolute paths are used.
Make sure the reference starts with ./ or ../ so PHP_CodeSniffer
knows it is a relative path.
-->
<rule ref="./standards/mystandard"/>
<rule ref="../username/custom.xml"/>
<!--
Include all sniffs in the Squiz standard except one. Note that
the name of the sniff being excluded is the code that the sniff
is given by PHP_CodeSniffer and is based on the file name and
path of the sniff class. You can display these codes using the
-s command line argument when checking a file.
-->
<rule ref="Squiz">
<exclude name="Squiz.PHP.CommentedOutCode"/>
</rule>
<!--
You can also exclude a single sniff message.
-->
<rule ref="Squiz">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<!--
Or, you can exclude a whole category of sniffs.
-->
<rule ref="Squiz">
<exclude name="Squiz.PHP"/>
</rule>
<!--
You can even exclude a whole standard. This example includes
all sniffs from the Squiz standard, but excludes any that come
from the Generic standard.
-->
<rule ref="Squiz">
<exclude name="Generic"/>
</rule>
<!--
Include some specific sniffs from the Generic standard.
Note again that the name of the sniff is the code that
PHP_CodeSniffer gives it.
-->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<!--
If you are including sniffs that are not installed, you can
reference the sniff class using an absolute or relative path
instead of using the sniff code.
-->
<rule ref="/path/to/standards/Generic/Sniffs/Commenting/TodoSniff.php"/>
<rule ref="../Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php"/>
<!--
Here we are including a specific sniff but also changing
the error message of a specific message inside the sniff.
Note that the specific code for the message, which is
TaskFound in this case, is defined by the sniff developer.
You can display these codes by using the -s command line
argument when checking a file.
Also note that this message has a variable inside it,
which is why it is important that sniffs use a printf style
format for their error messages.
We also drop the severity of this message from the
default value (5) so that it is hidden by default. It can be
displayed by setting the minimum severity on the PHP_CodeSniffer
command line. This is great if you want to use some messages
only in code reviews and not have them block code commits.
-->
<rule ref="Generic.Commenting.Todo.TaskFound">
<message>Please review this TODO comment: %s</message>
<severity>3</severity>
</rule>
<!--
You can also change the type of a message from error to
warning and vice versa.
-->
<rule ref="Generic.Commenting.Todo.CommentFound">
<type>error</type>
</rule>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<type>warning</type>
</rule>
<!--
Or change the type of all messages produced by
a sniff, category, or standard.
-->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<type>error</type>
</rule>
<rule ref="Squiz.Strings">
<type>warning</type>
</rule>
<rule ref="PSR12">
<type>warning</type>
</rule>
<!--
Here we change two messages from the same sniff. Note how the
codes are slightly different because the sniff developer has
defined both a MaxExceeded message and a TooLong message. In the
case of this sniff, one is used for warnings and one is used
for errors.
在这里,我们更改了同一嗅探中的两条消息。 请注意代码略有不同,因为嗅探开发人员
定义了 MaxExceeded 消息和 TooLong 消息。 在这种嗅探的情况下,一个用于警告,一个用于错误。
-->
<rule ref="Generic.Files.LineLength.MaxExceeded">
<message>Line contains %2$s chars, which is more than the limit of %1$s</message>
</rule>
<rule ref="Generic.Files.LineLength.TooLong">
<message>Line longer than %s characters; contains %s characters</message>
</rule>
<!--
Some sniffs have public member vars that allow you to
customise specific elements of the sniff. In the case of
the Generic LineLength sniff, you can customise the limit
at which the sniff will throw warnings and the limit at
which it will throw errors.
一些嗅探器具有公共成员变量,允许您自定义嗅探器的特定元素。
对于 Generic LineLength 嗅探,您可以自定义嗅探抛出警告的限制以及抛出错误的限制。
The rule below includes the LineLength sniff but changes the
settings so the sniff will show warnings for any line longer
than 90 chars and errors for any line longer than 100 chars.
下面的规则包括 LineLength 嗅探,但更改了设置,以便嗅探将对任何长度超过 90 个字符的行
显示警告,并为任何长度超过 100 个字符的行显示错误。
-->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="90"/>
<property name="absoluteLineLimit" value="100"/>
</properties>
</rule>
<!--
Another useful example of changing sniff settings is
to specify the end of line character that your standard
should check for.
-->
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\r\n"/>
</properties>
</rule>
<!--
Boolean values should be specified by using the strings
"true" and "false" rather than the integers 0 and 1.
-->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="8"/>
<property name="ignoreMultiLine" value="true"/>
</properties>
</rule>
<!--
Array values are specified by using "element" tags
with "key" and "value" attributes.
NOTE: This syntax is is only supported in PHP_CodeSniffer
versions 3.3.0 and greater.
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="create_function" value="null"/>
</property>
</properties>
</rule>
<!--
Before version 3.3.0, array values are specified by using a string
representation of the array.
NOTE: This syntax is deprecated and will be removed in
PHP_CodeSniffer version 4.0
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array" value="delete=>unset,print=>echo,create_function=>null" />
</properties>
</rule>
<!--
If you are including another standard, some array properties may
have already been defined. Instead of having to redefine them
you can choose to extend the property value instead. Any elements with
new keys will be added to the property value, and any elements with
existing keys will override the imported value.
NOTE: This syntax is is only supported in PHP_CodeSniffer
versions 3.4.0 and greater.
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array" extend="true">
<element key="sizeof" value="count"/>
</property>
</properties>
</rule>
<!--
If you want to completely disable an error message in a sniff
but you don't want to exclude the whole sniff, you can
change the severity of the message to 0. In this case, we
want the Squiz DoubleQuoteUsage sniff to be included in our
standard, but we don't want the ContainsVar error message to
ever be displayed.
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<severity>0</severity>
</rule>
<!--
There is a special internal error message produced by PHP_CodeSniffer
when it is unable to detect code in a file, possible due to
the use of short open tags even though php.ini disables them.
You can disable this message in the same way as sniff messages.
Again, the code here will be displayed in the PHP_CodeSniffer
output when using the -s command line argument while checking a file.
-->
<rule ref="Internal.NoCodeFound">
<severity>0</severity>
</rule>
<!--
You can hard-code ignore patterns for specific sniffs,
a feature not available on the command line. Please note that
all sniff-specific ignore patterns are checked using absolute paths.
The code here will hide all messages from the Squiz DoubleQuoteUsage
sniff for files that match either of the two exclude patterns.
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/data/*</exclude-pattern>
</rule>
<!--
You can also be more specific and just exclude some messages.
Please note that all message-specific ignore patterns are
checked using absolute paths.
The code here will just hide the ContainsVar error generated by the
Squiz DoubleQuoteUsage sniff for files that match either of the two
exclude patterns.
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/data/*</exclude-pattern>
</rule>
<!--
You can hard-code include patterns for specific sniffs,
allowing you to only include sniffs when checking specific files.
Please note that all sniff-specific include patterns are checked using
absolute paths.
The code here will only run the Squiz DoubleQuoteUsage sniff for
files that match either of the two include patterns.
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<include-pattern>*/templates/*</include-pattern>
<include-pattern>*\.tpl$</include-pattern>
</rule>
<!--
As with exclude rules, you can be more specific and just include
some messages. Please note that all message-specific include patterns
are checked using absolute paths.
The code here will just show the ContainsVar error generated by the
Squiz DoubleQuoteUsage sniff for files that match either of the two
include patterns.
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<include-pattern>*/templates/*</include-pattern>
<include-pattern>*\.tpl$</include-pattern>
</rule>
</ruleset>