|
| 1 | +<?php |
| 2 | + |
| 3 | +use PhpCsFixer\Config; |
| 4 | +use PhpCsFixer\Finder; |
| 5 | + |
| 6 | +$rules = [ |
| 7 | + 'array_syntax' => ['syntax' => 'short'], |
| 8 | + 'array_indentation' => true, |
| 9 | + 'blank_line_after_namespace' => true, |
| 10 | + 'blank_line_after_opening_tag' => true, |
| 11 | + 'braces' => true, |
| 12 | + 'cast_spaces' => true, |
| 13 | + 'concat_space' => [ |
| 14 | + 'spacing' => 'one', |
| 15 | + ], |
| 16 | + 'declare_equal_normalize' => true, |
| 17 | + 'elseif' => true, |
| 18 | + 'encoding' => true, |
| 19 | + 'full_opening_tag' => true, |
| 20 | + 'fully_qualified_strict_types' => true, // added by Shift |
| 21 | + 'function_declaration' => true, |
| 22 | + 'function_typehint_space' => true, |
| 23 | + 'heredoc_to_nowdoc' => true, |
| 24 | + 'include' => true, |
| 25 | + 'increment_style' => ['style' => 'post'], |
| 26 | + 'indentation_type' => true, |
| 27 | + 'linebreak_after_opening_tag' => true, |
| 28 | + 'line_ending' => true, |
| 29 | + 'lowercase_cast' => true, |
| 30 | + 'lowercase_keywords' => true, |
| 31 | + 'lowercase_static_reference' => true, // added from Symfony |
| 32 | + 'magic_method_casing' => true, // added from Symfony |
| 33 | + 'magic_constant_casing' => true, |
| 34 | + 'method_argument_space' => true, |
| 35 | + 'native_function_casing' => true, |
| 36 | + 'no_alias_functions' => true, |
| 37 | + 'no_extra_blank_lines' => [ |
| 38 | + 'tokens' => [ |
| 39 | + 'extra', |
| 40 | + 'throw', |
| 41 | + 'use', |
| 42 | + 'use_trait', |
| 43 | + ], |
| 44 | + ], |
| 45 | + 'no_blank_lines_after_class_opening' => true, |
| 46 | + 'no_blank_lines_after_phpdoc' => true, |
| 47 | + 'no_closing_tag' => true, |
| 48 | + 'no_empty_phpdoc' => true, |
| 49 | + 'no_empty_statement' => true, |
| 50 | + 'no_leading_import_slash' => true, |
| 51 | + 'no_leading_namespace_whitespace' => true, |
| 52 | + 'no_mixed_echo_print' => [ |
| 53 | + 'use' => 'echo', |
| 54 | + ], |
| 55 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 56 | + 'multiline_whitespace_before_semicolons' => [ |
| 57 | + 'strategy' => 'no_multi_line', |
| 58 | + ], |
| 59 | + 'no_short_bool_cast' => true, |
| 60 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 61 | + 'no_spaces_after_function_name' => true, |
| 62 | + 'no_spaces_inside_parenthesis' => true, |
| 63 | + 'no_trailing_comma_in_list_call' => true, |
| 64 | + 'no_trailing_comma_in_singleline_array' => true, |
| 65 | + 'no_trailing_whitespace' => true, |
| 66 | + 'no_trailing_whitespace_in_comment' => true, |
| 67 | + 'no_unreachable_default_argument_value' => true, |
| 68 | + 'no_useless_return' => true, |
| 69 | + 'no_unused_imports' => true, |
| 70 | + 'no_whitespace_before_comma_in_array' => true, |
| 71 | + 'no_whitespace_in_blank_line' => true, |
| 72 | + 'normalize_index_brace' => true, |
| 73 | + 'not_operator_with_successor_space' => true, |
| 74 | + 'object_operator_without_whitespace' => true, |
| 75 | + 'phpdoc_indent' => true, |
| 76 | + 'phpdoc_no_access' => true, |
| 77 | + 'phpdoc_no_package' => true, |
| 78 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 79 | + 'phpdoc_scalar' => true, |
| 80 | + 'phpdoc_single_line_var_spacing' => true, |
| 81 | + 'phpdoc_summary' => true, |
| 82 | + 'phpdoc_to_comment' => true, |
| 83 | + 'phpdoc_trim' => true, |
| 84 | + 'phpdoc_types' => true, |
| 85 | + 'phpdoc_var_without_name' => true, |
| 86 | + 'self_accessor' => true, |
| 87 | + 'short_scalar_cast' => true, |
| 88 | + 'simplified_null_return' => false, // disabled by Shift |
| 89 | + 'single_blank_line_at_eof' => true, |
| 90 | + 'single_blank_line_before_namespace' => true, |
| 91 | + 'single_import_per_statement' => true, |
| 92 | + 'single_line_after_imports' => true, |
| 93 | + 'single_line_comment_style' => [ |
| 94 | + 'comment_types' => ['hash'], |
| 95 | + ], |
| 96 | + 'single_space_after_construct' => true, |
| 97 | + 'single_quote' => true, |
| 98 | + 'space_after_semicolon' => true, |
| 99 | + 'standardize_not_equals' => true, |
| 100 | + 'switch_case_semicolon_to_colon' => true, |
| 101 | + 'switch_case_space' => true, |
| 102 | + 'ternary_operator_spaces' => true, |
| 103 | + 'trim_array_spaces' => true, |
| 104 | + 'unary_operator_spaces' => true, |
| 105 | + 'whitespace_after_comma_in_array' => true, |
| 106 | + |
| 107 | + // php-cs-fixer 3: Renamed rules |
| 108 | + 'constant_case' => ['case' => 'lower'], |
| 109 | + 'general_phpdoc_tag_rename' => true, |
| 110 | + 'phpdoc_inline_tag_normalizer' => true, |
| 111 | + 'phpdoc_tag_type' => true, |
| 112 | + 'psr_autoloading' => true, |
| 113 | + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], |
| 114 | + |
| 115 | + // php-cs-fixer 3: Changed options |
| 116 | + 'binary_operator_spaces' => [ |
| 117 | + 'default' => 'single_space', |
| 118 | + 'operators' => ['=>' => null], |
| 119 | + ], |
| 120 | + 'blank_line_before_statement' => [ |
| 121 | + 'statements' => ['return'], |
| 122 | + ], |
| 123 | + 'class_attributes_separation' => [ |
| 124 | + 'elements' => [ |
| 125 | + 'const' => 'one', |
| 126 | + 'method' => 'one', |
| 127 | + 'property' => 'one', |
| 128 | + ], |
| 129 | + ], |
| 130 | + 'class_definition' => [ |
| 131 | + 'multi_line_extends_each_single_line' => true, |
| 132 | + 'single_item_single_line' => true, |
| 133 | + 'single_line' => true, |
| 134 | + ], |
| 135 | + 'ordered_imports' => [ |
| 136 | + 'sort_algorithm' => 'alpha', |
| 137 | + ], |
| 138 | + |
| 139 | + // php-cs-fixer 3: Removed rootless options (*) |
| 140 | + 'no_unneeded_control_parentheses' => [ |
| 141 | + 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'], |
| 142 | + ], |
| 143 | + 'no_spaces_around_offset' => [ |
| 144 | + 'positions' => ['inside', 'outside'], |
| 145 | + ], |
| 146 | + 'visibility_required' => [ |
| 147 | + 'elements' => ['property', 'method', 'const'], |
| 148 | + ], |
| 149 | + |
| 150 | +]; |
| 151 | + |
| 152 | +$finder = Finder::create() |
| 153 | + ->in([ |
| 154 | + __DIR__ . '/source', |
| 155 | + ]) |
| 156 | + ->name('*.php') |
| 157 | + ->notName('*.blade.php') |
| 158 | + ->ignoreDotFiles(true) |
| 159 | + ->ignoreVCS(true); |
| 160 | + |
| 161 | +return (new Config()) |
| 162 | + ->setFinder($finder) |
| 163 | + ->setRules($rules) |
| 164 | + ->setRiskyAllowed(true) |
| 165 | + ->setUsingCache(true); |
0 commit comments