-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpcs.xml
More file actions
447 lines (379 loc) · 13.4 KB
/
phpcs.xml
File metadata and controls
447 lines (379 loc) · 13.4 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
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
<?xml version="1.0"?>
<!--
References:
- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
Extended Rules:
- https://github.com/slevomat/coding-standard
- https://github.com/sirbrillig/phpcs-variable-analysis
-->
<ruleset name="MyPHPStandardRuleSet">
<description>My standard rules for PHP.</description>
<file>src</file>
<!--
based on PSR12
-->
<rule ref="PSR12">
</rule>
<!--
Laravel : クラスの命名規約を無視する
-->
<rule ref="Squiz.Classes.ValidClassName">
</rule>
<!--
Laravel : PSR1準拠の名前空間管理を除外する
-->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
</rule>
<!--
メソッド名がキャメルケースでなければならないルールを除外する
-->
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!--
変数展開(interpolation)がない場合は二重引用符を禁止する
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar" />
</rule>
<!--
文字列連結演算子 `.` の左右にスペースを挿入する
-->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1" />
<property name="ignoreNewlines" value="true" />
</properties> </rule>
<!--
関数のプロトタイプ宣言が複数行にまたがる場合、一行一引数で記述する
-->
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.OneParamPerLine">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!--
行あたり文字数の上限を100字にする
-->
<rule ref="Generic.Files.LineLength">
<properties>
<!-- 警告値 -->
<property name="lineLimit" value="120" />
<!-- 禁止値 -->
<property name="absoluteLineLimit" value="120" />
</properties>
</rule>
<!--
ネストしたfor文のカウンタ変数の混在を禁止する
Ex.)
for ($i = 1; $i < 10; $i++) {
// $i++ を $j++ の誤記と見なす
for ($j = 1; $j < 10; $i++) {
}
}
-->
<rule ref="Generic.CodeAnalysis.JumbledIncrementer">
</rule>
<!--
PHP4式のコンストラクタを禁止する
-->
<rule ref="Generic.NamingConventions.ConstructorName">
</rule>
<!--
GOTOを禁止する
-->
<rule ref="Generic.PHP.DiscourageGoto">
</rule>
<rule ref="Generic.PHP.DeprecatedFunctions">
</rule>
<!--
一部の関数の使用を禁止する
- 型キャストの記法
- デバッグ関数を残したままのコミットの禁止
デバッグ用の関数の消し忘れまたはコメントアウト漏れ検知
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<!-- debug funcitons -->
<element key="print_r" value="null" />
<element key="var_dump" value="null" />
<element key="print" value="null" />
<element key="echo" value="null" />
<element key="dump" value="null" />
<element key="debug" value="null" />
<element key="dd" value="null" />
<element key="debug_print_backtrace" value="null" />
<element key="debug_backtrace" value="null" />
<!-- hash funcitons -->
<element key="bcrypt" value="Hash::make" />
<!-- type cast funcitons -->
<element key="strval" value="null" />
<element key="intval" value="null" />
<element key="boolval" value="null" />
<element key="floatval" value="null" />
<element key="settype" value="null" />
</property>
</properties>
</rule>
<!--
空行関連
-->
<!--
メソッドや関数定義間の空行数
-->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0" />
<property name="spacingAfterLast" value="0" />
</properties>
</rule>
<!--
空白関連
-->
<!--
型キャストのあとのスペースを禁止する
- 型キャストの記法
-->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<!--
`!`のあとのスペースを禁止する
-->
<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<!--
スペースによる左揃えを禁止する
-->
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreSpacingBeforeAssignments" value="true" />
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<!--
`->`演算子前後の空白を禁止する
ただし、改行は許容する
-->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing.Before">
</rule>
<!--
デフォルト引数の代入式にスペース挿入を強制する
-->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
<!--
スペースによるアラインメントを許容する
-->
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
</rule>
<!--
引数の左揃えを許容する
-->
<rule ref="Generic.Functions.FunctionCallArgumentSpacing">
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma" />
</rule>
<!--
プロパティの左揃えを許容する
-->
<rule ref="PSR2.Classes.PropertyDeclaration">
<exclude name="PSR2.Classes.PropertyDeclaration.SpacingAfterType" />
</rule>
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="30" />
</properties>
</rule>
<!--
複雑さの指標関連
-->
<!--
ネスト数の制限
-->
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="3" />
<property name="absoluteNestingLevel" value="5" />
</properties>
</rule>
<!--
循環的複雑度の制限
-->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="10" />
<property name="absoluteComplexity" value="20" />
</properties>
</rule>
<!--
https://github.com/slevomat/coding-standard
-->
<!--
プロパティの型指定漏れの検知
Docコメントよりもコード上の型宣言を優先する
自動修正可
-->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!--
引数の型指定漏れの検知
Docコメントよりもコード上の型宣言を優先する
自動修正可
-->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!--
戻り値の型指定漏れの検知
Docコメントよりもコード上の型宣言を優先する
自動修正可
-->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!--
null合体演算子の優先利用
-->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator">
</rule>
<!--
null合体代入演算子の優先利用
-->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator">
</rule>
<!--
`==`による緩い比較を禁止する
自動修正可
-->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators">
</rule>
<!--
使われていないuse文の検出
自動修正可
-->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
</rule>
<!--
同じ名前空間のクラスはuseしない
自動修正可
-->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace">
</rule>
<!--
クラスメンバの記載順
自動修正可
-->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<exclude-pattern>tests/*</exclude-pattern>
<properties>
<property name="groups" type="array">
<!-- use statements -->
<element value="uses" />
<!-- abstract static methods -->
<element value="public static abstract methods" />
<element value="protected static abstract methods" />
<!-- abstract methods -->
<element value="public abstract methods" />
<element value="protected abstract methods" />
<!-- constants -->
<element value="public constants" />
<element value="protected constants" />
<element value="private constants" />
<!-- static properties -->
<element value="public static properties" />
<element value="protected static properties" />
<element value="private static properties" />
<!-- static methods -->
<element value="static constructors" />
<element value="public static methods" />
<element value="protected static methods" />
<element value="private static methods" />
<!-- instance properties -->
<element value="public properties" />
<element value="protected properties" />
<element value="private properties" />
<!-- instance methods -->
<element value="constructor" />
<element value="public methods" />
<element value="protected methods" />
<element value="private methods" />
<!-- special methods -->
<element value="magic methods" />
<element value="destructor" />
</property>
</properties>
</rule>
<!--
use文はアルファベット順に並べる
自動修正可
-->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
</rule>
<!--
型宣言は短い記法を使う
自動修正可
-->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints">
</rule>
<!--
キャストの型宣言は短い記法を使う
自動修正可
-->
<rule ref="SlevomatCodingStandard.PHP.TypeCast">
</rule>
<!--
定数の可視性の明示を強制
自動修正可
-->
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
</rule>
<!--
メソッドの戻り値の型宣言の書式を設定(リンク参照)
自動修正可
@link https://github.com/slevomat/coding-standard#slevomatcodingstandardtypehintsreturntypehintspacing-
-->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
</rule>
<!--
一部のDocコメントのアノテーションを禁止
自動修正可
-->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@author" />
<element value="@copyright" />
<element value="@created" />
<element value="@example" />
<element value="@license" />
<element value="@package" />
<element value="@since" />
</property>
</properties>
</rule>
<!--
https://github.com/sirbrillig/phpcs-variable-analysis
-->
<!--
使われていない引数の検出
-->
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<properties>
<property name="ignoreUnusedRegexp" value="/\A_/" />
</properties>
</rule>
</ruleset>