|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * PHP CS Fixer config. |
| 4 | + */ |
| 5 | +$finder = PhpCsFixer\Finder::create() |
| 6 | + ->in(__DIR__.'/src') |
| 7 | + ->in(__DIR__.'/tests') |
| 8 | + ->name('*.php') |
| 9 | + ->append([__FILE__]) |
| 10 | +; |
| 11 | + |
| 12 | +return (new PhpCsFixer\Config()) |
| 13 | + ->setRules([ |
| 14 | + 'array_syntax' => ['syntax' => 'short'], // Differs from Symfony, where array syntax is long |
| 15 | + 'binary_operator_spaces' => true, |
| 16 | + 'blank_line_after_namespace' => true, |
| 17 | + 'blank_line_after_opening_tag' => true, |
| 18 | + 'blank_line_before_statement' => true, |
| 19 | + 'braces' => true, |
| 20 | + 'cast_spaces' => true, |
| 21 | + 'class_attributes_separation' => true, |
| 22 | + 'class_definition' => true, |
| 23 | + 'constant_case' => true, |
| 24 | + 'combine_consecutive_issets' => true, |
| 25 | + 'combine_consecutive_unsets' => true, |
| 26 | + 'compact_nullable_typehint' => true, |
| 27 | + 'concat_space' => true, |
| 28 | + 'declare_equal_normalize' => true, |
| 29 | + 'dir_constant' => true, |
| 30 | + 'doctrine_annotation_array_assignment' => true, |
| 31 | + 'doctrine_annotation_braces' => true, |
| 32 | + 'doctrine_annotation_indentation' => true, |
| 33 | + 'doctrine_annotation_spaces' => false, // broken |
| 34 | + 'elseif' => true, |
| 35 | + 'encoding' => true, |
| 36 | + 'escape_implicit_backslashes' => true, |
| 37 | + 'explicit_indirect_variable' => true, |
| 38 | + 'explicit_string_variable' => true, |
| 39 | + 'full_opening_tag' => true, |
| 40 | + 'fully_qualified_strict_types' => true, |
| 41 | + 'function_declaration' => true, |
| 42 | + 'function_to_constant' => true, |
| 43 | + 'function_typehint_space' => true, |
| 44 | + 'general_phpdoc_tag_rename' => true, |
| 45 | + 'include' => true, |
| 46 | + 'increment_style' => ['style' => 'post'], // Differs from symfony |
| 47 | + 'indentation_type' => true, |
| 48 | + 'is_null' => true, |
| 49 | + 'line_ending' => true, |
| 50 | + 'linebreak_after_opening_tag' => true, |
| 51 | + 'list_syntax' => ['syntax' => 'short'], |
| 52 | + 'logical_operators' => true, |
| 53 | + 'lowercase_keywords' => true, |
| 54 | + 'lowercase_static_reference' => true, |
| 55 | + 'magic_constant_casing' => true, |
| 56 | + 'method_argument_space' => true, |
| 57 | + // strval($f) is better than ((string)$f) |
| 58 | + // when outter parenthese are required |
| 59 | + 'modernize_types_casting' => false, |
| 60 | + 'multiline_comment_opening_closing' => true, |
| 61 | + 'native_function_casing' => true, |
| 62 | + 'new_with_braces' => true, |
| 63 | + 'no_alias_functions' => true, |
| 64 | + 'no_alternative_syntax' => true, |
| 65 | + 'no_binary_string' => true, |
| 66 | + 'no_blank_lines_after_class_opening' => true, |
| 67 | + 'no_blank_lines_after_phpdoc' => true, |
| 68 | + 'no_break_comment' => true, |
| 69 | + 'no_closing_tag' => true, |
| 70 | + 'no_empty_comment' => true, |
| 71 | + 'no_empty_phpdoc' => true, |
| 72 | + 'no_empty_statement' => true, |
| 73 | + 'no_extra_blank_lines' => true, |
| 74 | + 'no_homoglyph_names' => true, |
| 75 | + 'no_leading_import_slash' => true, |
| 76 | + 'no_leading_namespace_whitespace' => true, |
| 77 | + 'no_mixed_echo_print' => true, |
| 78 | + 'no_multiline_whitespace_around_double_arrow' => true, |
| 79 | + 'no_php4_constructor' => true, |
| 80 | + 'no_short_bool_cast' => true, |
| 81 | + 'no_singleline_whitespace_before_semicolons' => true, |
| 82 | + 'no_spaces_after_function_name' => true, |
| 83 | + 'no_spaces_around_offset' => true, |
| 84 | + 'no_spaces_inside_parenthesis' => true, |
| 85 | + 'no_superfluous_elseif' => true, |
| 86 | + 'no_superfluous_phpdoc_tags' => false, // removes 'mixed' type annotations |
| 87 | + 'no_trailing_comma_in_list_call' => true, |
| 88 | + 'no_trailing_comma_in_singleline_array' => true, |
| 89 | + 'no_trailing_whitespace' => true, |
| 90 | + 'no_trailing_whitespace_in_comment' => true, |
| 91 | + 'no_unneeded_control_parentheses' => true, |
| 92 | + 'no_unneeded_curly_braces' => true, |
| 93 | + 'no_unneeded_final_method' => true, |
| 94 | + 'no_unused_imports' => true, |
| 95 | + 'no_useless_else' => true, |
| 96 | + 'no_useless_return' => true, |
| 97 | + 'no_whitespace_before_comma_in_array' => true, |
| 98 | + 'no_whitespace_in_blank_line' => true, |
| 99 | + 'non_printable_character' => true, |
| 100 | + 'normalize_index_brace' => true, |
| 101 | + 'object_operator_without_whitespace' => true, |
| 102 | + 'ordered_class_elements' => true, |
| 103 | + 'ordered_imports' => true, |
| 104 | + 'php_unit_construct' => true, |
| 105 | + 'php_unit_dedicate_assert' => true, |
| 106 | + 'php_unit_expectation' => true, |
| 107 | + 'php_unit_fqcn_annotation' => true, |
| 108 | + 'php_unit_mock' => true, |
| 109 | + 'php_unit_namespaced' => false, // incompleted / bogus |
| 110 | + 'php_unit_no_expectation_annotation' => true, |
| 111 | + 'php_unit_set_up_tear_down_visibility' => true, |
| 112 | + 'php_unit_test_annotation' => [ |
| 113 | + 'style' => 'prefix', |
| 114 | + ], |
| 115 | + 'phpdoc_align' => true, |
| 116 | + 'phpdoc_annotation_without_dot' => true, |
| 117 | + 'phpdoc_indent' => true, |
| 118 | + 'phpdoc_inline_tag_normalizer' => true, |
| 119 | + 'phpdoc_no_access' => true, |
| 120 | + 'phpdoc_no_alias_tag' => true, |
| 121 | + 'phpdoc_no_empty_return' => true, |
| 122 | + 'phpdoc_no_package' => true, |
| 123 | + 'phpdoc_no_useless_inheritdoc' => true, |
| 124 | + 'phpdoc_order' => true, |
| 125 | + 'phpdoc_order_by_value' => true, |
| 126 | + 'phpdoc_return_self_reference' => true, |
| 127 | + 'phpdoc_scalar' => true, |
| 128 | + 'phpdoc_separation' => true, |
| 129 | + 'phpdoc_single_line_var_spacing' => true, |
| 130 | + 'phpdoc_summary' => true, |
| 131 | + 'phpdoc_tag_type' => true, |
| 132 | + 'phpdoc_to_comment' => true, |
| 133 | + 'phpdoc_trim' => true, |
| 134 | + 'phpdoc_trim_consecutive_blank_line_separation' => true, |
| 135 | + 'phpdoc_types' => true, |
| 136 | + 'phpdoc_types_order' => false, // puts null before the type |
| 137 | + 'phpdoc_var_without_name' => false, |
| 138 | + 'psr_autoloading' => true, |
| 139 | + 'return_assignment' => false, |
| 140 | + 'return_type_declaration' => true, |
| 141 | + 'self_accessor' => true, |
| 142 | + 'semicolon_after_instruction' => true, |
| 143 | + 'set_type_to_cast' => true, |
| 144 | + 'short_scalar_cast' => true, |
| 145 | + 'single_blank_line_at_eof' => true, |
| 146 | + 'single_blank_line_before_namespace' => true, |
| 147 | + 'single_class_element_per_statement' => true, |
| 148 | + 'single_import_per_statement' => true, |
| 149 | + 'single_line_after_imports' => true, |
| 150 | + 'single_line_comment_style' => true, |
| 151 | + 'single_quote' => true, |
| 152 | + 'space_after_semicolon' => true, |
| 153 | + 'standardize_not_equals' => true, |
| 154 | + 'switch_case_semicolon_to_colon' => true, |
| 155 | + 'switch_case_space' => true, |
| 156 | + 'ternary_operator_spaces' => true, |
| 157 | + 'ternary_to_null_coalescing' => true, |
| 158 | + 'trailing_comma_in_multiline' => true, |
| 159 | + 'trim_array_spaces' => true, |
| 160 | + 'unary_operator_spaces' => true, |
| 161 | + 'visibility_required' => [ |
| 162 | + 'elements' => ['property', 'method', 'const'], |
| 163 | + ], |
| 164 | + 'whitespace_after_comma_in_array' => false, // freezes with 100% cpu |
| 165 | + 'yoda_style' => false, // Maybe later |
| 166 | + ]) |
| 167 | + ->setRiskyAllowed(true) |
| 168 | + ->setFinder($finder); |
0 commit comments