-
Notifications
You must be signed in to change notification settings - Fork 3
/
.php_cs
35 lines (33 loc) · 1.35 KB
/
.php_cs
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
<?php
/** @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.12/README.rst */
$finder = PhpCsFixer\Finder::create()
->exclude([
'views', // views 下的注释和 header_comment 冲突,所以先跳过
'generators',
])
->in([
__DIR__
]);
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => false,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_issets' => true, // 合并多个 isset
'combine_consecutive_unsets' => true, // 合并多个 unset
// 顶部注释
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => '', // 不添加则为空
'location' => 'after_open',
'separate' => 'none',
],
'short_scalar_cast' => true, // 将 (boolean) 这种转为 (bool)
'single_blank_line_before_namespace' => true, // namespace 前只有一个空行
'no_trailing_comma_in_singleline_array' => true, // 单行数组最后没有逗号
'trailing_comma_in_multiline_array' => true, // 多行数组之后有逗号
'blank_line_after_opening_tag' => true, // 在 <?php 开头的后面增加一个空行
'ordered_imports' => true, // use 排序
'no_unused_imports' => true, // 删除无用的 use
])
->setFinder($finder);