|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -return (new PhpCsFixer\Config())->setRules([ |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +$finder = PhpCsFixer\Finder::create() |
| 6 | + ->in(__DIR__) |
| 7 | + ->name('*.php') |
| 8 | + ->notPath('/^vendor\//') |
| 9 | +; |
| 10 | + |
| 11 | +$config = new PhpCsFixer\Config(); |
| 12 | + |
| 13 | +return $config->setRules([ |
4 | 14 | '@PSR2' => false,
|
| 15 | + 'declare_strict_types' => true, |
5 | 16 | 'array_indentation' => true,
|
6 | 17 | 'array_syntax' => [
|
7 |
| - 'syntax' => 'short', |
| 18 | + 'syntax' => 'short', // short array() => [] , long [] => array() |
8 | 19 | ],
|
9 | 20 | 'blank_line_after_namespace' => true,
|
10 | 21 | 'blank_line_after_opening_tag' => true,
|
11 |
| - 'blank_line_before_statement' => [ |
12 |
| - 'statements' => [ |
13 |
| - 'declare', |
14 |
| - 'default', |
15 |
| - 'exit', |
16 |
| - 'goto', |
17 |
| - 'include', |
18 |
| - 'include_once', |
19 |
| - 'phpdoc', |
20 |
| - 'require', |
21 |
| - 'require_once', |
22 |
| - 'return', |
23 |
| - 'switch', |
24 |
| - 'try', |
25 |
| - 'yield', |
26 |
| - 'yield_from', |
27 |
| - ], |
28 |
| - ], |
29 |
| - 'braces' => [ |
30 |
| - 'allow_single_line_closure' => true, |
31 |
| - 'position_after_functions_and_oop_constructs' => 'same', |
| 22 | + 'blank_line_before_statement' => true, // blank before return, try, break, continue |
| 23 | + 'single_space_around_construct' => true, |
| 24 | + 'control_structure_braces' => true, |
| 25 | + 'control_structure_continuation_position' => true, |
| 26 | + 'declare_parentheses' => true, |
| 27 | + 'no_multiple_statements_per_line' => true, |
| 28 | + 'braces_position' => [ |
| 29 | + 'functions_opening_brace' => 'same_line', |
| 30 | + 'classes_opening_brace' => 'same_line', |
32 | 31 | ],
|
| 32 | + 'statement_indentation' => true, |
| 33 | + 'no_extra_blank_lines' => true, |
33 | 34 | 'cast_spaces' => true,
|
34 | 35 | 'class_definition' => [
|
35 | 36 | 'single_line' => false,
|
36 | 37 | ],
|
37 | 38 | 'clean_namespace' => true,
|
38 | 39 | 'combine_consecutive_issets' => false,
|
39 |
| - 'combine_consecutive_unsets' => false, |
40 |
| - 'concat_space' => ['spacing' => 'one'], |
41 |
| - 'constant_case' => true, |
| 40 | + 'combine_consecutive_unsets' => false, // unset($a); unset($b); => unset($a, $b); |
| 41 | + 'concat_space' => ['spacing' => 'one'], // $foo = 'bar' . 3 . 'baz' . 'qux'; |
| 42 | + 'constant_case' => true, // nuLL, FALSE, True => null, false, true |
42 | 43 | 'elseif' => true,
|
43 | 44 | 'encoding' => true,
|
44 |
| - 'function_typehint_space' => true, |
45 |
| - 'include' => true, |
| 45 | + 'type_declaration_spaces' => ['elements' => ['function', 'property']], |
| 46 | + 'include' => true, // include("sample.php"); => include_once "sample.php" |
46 | 47 | 'indentation_type' => true,
|
47 | 48 | 'linebreak_after_opening_tag' => true,
|
48 | 49 | 'list_syntax' => ['syntax' => 'short'],
|
49 |
| - 'lowercase_cast' => true, |
50 |
| - 'lowercase_keywords' => true, |
| 50 | + 'lowercase_cast' => true, // (InTegEr),(BOOLEAN), => (integer),(boolean) |
| 51 | + 'lowercase_keywords' => true, // WHILE, FOREACH => while, foreach |
51 | 52 | 'lowercase_static_reference' => true,
|
52 | 53 | 'magic_constant_casing' => true,
|
53 | 54 | 'magic_method_casing' => true,
|
54 | 55 | 'native_function_casing' => true,
|
55 |
| - 'native_function_type_declaration_casing' => true, |
| 56 | + 'native_type_declaration_casing' => true, |
56 | 57 | 'no_blank_lines_after_class_opening' => true,
|
57 | 58 | 'no_empty_statement' => true,
|
58 | 59 | 'no_leading_import_slash' => true,
|
59 | 60 | 'no_mixed_echo_print' => ['use' => 'echo'],
|
60 | 61 | 'no_spaces_after_function_name' => true,
|
61 | 62 | 'no_spaces_around_offset' => true,
|
62 |
| - 'no_spaces_inside_parenthesis' => true, |
| 63 | + 'spaces_inside_parentheses' => ['space' => 'none'], |
63 | 64 | 'no_trailing_whitespace' => true,
|
64 | 65 | 'no_whitespace_in_blank_line' => true,
|
65 | 66 | 'operator_linebreak' => ['only_booleans' => true],
|
66 |
| - 'ordered_class_elements' => [ |
67 |
| - 'order' => [ |
68 |
| - 'use_trait', |
69 |
| - 'case', |
70 |
| - 'constant_public', |
71 |
| - 'constant_protected', |
72 |
| - 'constant_private', |
73 |
| - 'property_public', |
74 |
| - 'property_protected', |
75 |
| - 'property_private', |
76 |
| - 'construct', |
77 |
| - 'destruct', |
78 |
| - 'magic', |
79 |
| - 'phpunit', |
80 |
| - 'method_abstract', |
81 |
| - 'method_public', |
82 |
| - 'method_protected', |
83 |
| - 'method_private', |
84 |
| - ], |
85 |
| - 'sort_algorithm' => 'alpha', |
86 |
| - ], |
| 67 | + 'ordered_class_elements' => ['sort_algorithm' => 'alpha'], |
87 | 68 | 'short_scalar_cast' => true,
|
88 | 69 | 'single_blank_line_at_eof' => true,
|
89 | 70 | 'single_class_element_per_statement' => ['elements' => ['const', 'property']],
|
90 | 71 | 'single_quote' => true,
|
91 | 72 | 'ternary_operator_spaces' => true,
|
92 | 73 | 'trailing_comma_in_multiline' => true,
|
93 | 74 | 'whitespace_after_comma_in_array' => true,
|
| 75 | + 'visibility_required' => true, |
| 76 | + 'return_type_declaration'=> ['space_before' => 'none'], |
94 | 77 | ])
|
95 | 78 | ->setIndent(' ')
|
96 | 79 | ->setLineEnding("\n")
|
| 80 | + ->setFinder($finder) |
| 81 | + ->setRiskyAllowed(true) |
97 | 82 | ;
|
0 commit comments