1
1
<?php
2
- $ header = <<<EOF
3
- This file is part of the calchen/laravel-dingtalk-robot-notification.
4
2
5
-
3
+ /**
4
+ * 根据 StyleCI 的 Laravel Preset 整理的 PHP Coding Standards Fixer 规则
5
+ * 注释掉的是 Fixer 中不存在的
6
+ * 行尾注释,表示该行规则命名存在差异
7
+ */
8
+ $ rules = [
9
+ '@PSR2 ' => true ,
10
+ 'phpdoc_align ' => true , // align_phpdoc
11
+ 'binary_operator_spaces ' => true ,
12
+ 'blank_line_after_opening_tag ' => true ,
13
+ 'blank_line_before_return ' => true ,
14
+ 'cast_spaces ' => true ,
15
+ 'concat_space ' => true , // concat_without_spaces
16
+ 'declare_equal_normalize ' => true ,
17
+ 'function_typehint_space ' => true ,
18
+ 'hash_to_slash_comment ' => true ,
19
+ 'heredoc_to_nowdoc ' => true ,
20
+ 'include ' => true ,
21
+ // length_ordered_imports 根据 .styleci.yml 禁用
22
+ 'lowercase_cast ' => true ,
23
+ 'lowercase_static_reference ' => true ,
24
+ 'magic_constant_casing ' => true ,
25
+ 'magic_method_casing ' => true ,
26
+ 'method_separation ' => true ,
27
+ 'native_function_casing ' => true ,
28
+ 'native_function_type_declaration_casing ' => true ,
29
+ 'no_alias_functions ' => true ,
30
+ 'no_blank_lines_after_class_opening ' => true ,
31
+ 'no_blank_lines_after_phpdoc ' => true ,
32
+ // 'no_blank_lines_after_throw' => true,
33
+ // 'no_blank_lines_between_imports' => true,
34
+ // 'no_blank_lines_between_traits' => true,
35
+ 'no_empty_phpdoc ' => true ,
36
+ 'no_empty_statement ' => true ,
37
+ 'no_extra_consecutive_blank_lines ' => true ,
38
+ 'no_leading_import_slash ' => true ,
39
+ 'no_leading_namespace_whitespace ' => true ,
40
+ 'no_multiline_whitespace_around_double_arrow ' => true ,
41
+ 'no_multiline_whitespace_before_semicolons ' => true ,
42
+ 'no_short_bool_cast ' => true ,
43
+ 'no_singleline_whitespace_before_semicolons ' => true ,
44
+ 'no_spaces_around_offset ' => ['positions ' => ['inside ' ]], // no_spaces_inside_offset
45
+ 'no_trailing_comma_in_list_call ' => true ,
46
+ 'no_trailing_comma_in_singleline_array ' => true ,
47
+ 'no_unneeded_control_parentheses ' => true ,
48
+ 'no_unreachable_default_argument_value ' => true ,
49
+ // no_unused_imports 根据 .styleci.yml 禁用
50
+ 'no_useless_return ' => true ,
51
+ 'no_whitespace_before_comma_in_array ' => true ,
52
+ 'no_whitespace_in_blank_line ' => true ,
53
+ 'normalize_index_brace ' => true ,
54
+ 'not_operator_with_successor_space ' => true ,
55
+ 'object_operator_without_whitespace ' => true ,
56
+ 'phpdoc_indent ' => true ,
57
+ 'phpdoc_inline_tag ' => true ,
58
+ 'phpdoc_no_access ' => true ,
59
+ 'phpdoc_no_package ' => true ,
60
+ 'phpdoc_no_useless_inheritdoc ' => true ,
61
+ 'phpdoc_scalar ' => true ,
62
+ 'phpdoc_single_line_var_spacing ' => true ,
63
+ 'phpdoc_summary ' => true ,
64
+ 'phpdoc_to_comment ' => true ,
65
+ 'phpdoc_trim ' => true ,
66
+ // 'phpdoc_type_to_var' => true,
67
+ 'phpdoc_types ' => true ,
68
+ 'phpdoc_var_without_name ' => true ,
69
+ 'pre_increment ' => true , // post_increment
70
+ 'no_mixed_echo_print ' => true , // print_to_echo
71
+ 'self_accessor ' => true ,
72
+ 'array_syntax ' => ['syntax ' => 'short ' ], // short_array_syntax
73
+ 'list_syntax ' => ['syntax ' => 'short ' ], // short_list_syntax
74
+ 'short_scalar_cast ' => true ,
75
+ 'simplified_null_return ' => true ,
76
+ 'single_blank_line_before_namespace ' => true ,
77
+ 'single_quote ' => true ,
78
+ 'space_after_semicolon ' => true ,
79
+ 'standardize_not_equals ' => true ,
80
+ 'ternary_operator_spaces ' => true ,
81
+ 'trailing_comma_in_multiline_array ' => true ,
82
+ 'trim_array_spaces ' => true ,
83
+ // 'unalign_equals' => true,
84
+ 'unary_operator_spaces ' => true ,
85
+ 'whitespace_after_comma_in_array ' => true ,
6
86
7
- This source file is subject to the MIT license that is bundled.
8
- EOF ;
87
+ // 根据 .styleci.yml 启用额外规则
88
+ ' ordered_imports ' => true ,
9
89
90
+ ];
10
91
return PhpCsFixer \Config::create ()
11
92
->setRiskyAllowed (true )
12
- ->setRules (array (
13
- '@Symfony ' => true ,
14
- 'header_comment ' => array ('header ' => $ header ),
15
- 'array_syntax ' => array ('syntax ' => 'short ' ),
16
- 'ordered_imports ' => true ,
17
- 'no_useless_else ' => true ,
18
- 'no_useless_return ' => true ,
19
- 'php_unit_construct ' => true ,
20
- 'php_unit_strict ' => true ,
21
- ))
93
+ ->setRules ($ rules )
22
94
->setFinder (
23
95
PhpCsFixer \Finder::create ()
24
96
->exclude ('vendor ' )
25
97
->in (__DIR__ )
26
- )
27
- ;
98
+ );
0 commit comments