| 1 |
<?php |
| 2 |
|
| 3 |
$finder = PhpCsFixer\Finder::create() |
| 4 |
->exclude(['vendor', 'tests/data/Calculation']) |
| 5 |
->in('samples') |
| 6 |
->in('src') |
| 7 |
->in('tests/PhpSpreadsheetTests') |
| 8 |
; |
| 9 |
|
| 10 |
return PhpCsFixer\Config::create() |
| 11 |
->setRiskyAllowed(true) |
| 12 |
->setFinder($finder) |
| 13 |
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__)) |
| 14 |
->setRules([ |
| 15 |
'align_multiline_comment' => true, |
| 16 |
'array_syntax' => ['syntax' => 'short'], |
| 17 |
'backtick_to_shell_exec' => true, |
| 18 |
'binary_operator_spaces' => true, |
| 19 |
'blank_line_after_namespace' => true, |
| 20 |
'blank_line_after_opening_tag' => true, |
| 21 |
'blank_line_before_statement' => true, |
| 22 |
'braces' => true, |
| 23 |
'cast_spaces' => true, |
| 24 |
'class_attributes_separation' => ['elements' => ['method', 'property']], // const are often grouped with other related const |
| 25 |
'class_definition' => true, |
| 26 |
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE |
| 27 |
'combine_consecutive_issets' => true, |
| 28 |
'combine_consecutive_unsets' => true, |
| 29 |
'compact_nullable_typehint' => true, |
| 30 |
'concat_space' => ['spacing' => 'one'], |
| 31 |
'declare_equal_normalize' => true, |
| 32 |
'declare_strict_types' => false, // Too early to adopt strict types |
| 33 |
'dir_constant' => true, |
| 34 |
'doctrine_annotation_array_assignment' => true, |
| 35 |
'doctrine_annotation_braces' => true, |
| 36 |
'doctrine_annotation_indentation' => true, |
| 37 |
'doctrine_annotation_spaces' => true, |
| 38 |
'elseif' => true, |
| 39 |
'encoding' => true, |
| 40 |
'ereg_to_preg' => true, |
| 41 |
'escape_implicit_backslashes' => true, |
| 42 |
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read |
| 43 |
'explicit_string_variable' => false, // I feel it makes the code actually harder to read |
| 44 |
'final_internal_class' => true, |
| 45 |
'full_opening_tag' => true, |
| 46 |
'function_declaration' => true, |
| 47 |
'function_to_constant' => true, |
| 48 |
'function_typehint_space' => true, |
| 49 |
'general_phpdoc_annotation_remove' => false, // No use for that |
| 50 |
'hash_to_slash_comment' => true, |
| 51 |
'header_comment' => false, // We don't use common header in all our files |
| 52 |
'heredoc_to_nowdoc' => false, // Not sure about this one |
| 53 |
'include' => true, |
| 54 |
'increment_style' => true, |
| 55 |
'indentation_type' => true, |
| 56 |
'is_null' => ['use_yoda_style' => false], |
| 57 |
'linebreak_after_opening_tag' => true, |
| 58 |
'line_ending' => true, |
| 59 |
'list_syntax' => ['syntax' => 'long'], // Stay compatiblew with PHP 5.6 |
| 60 |
'lowercase_cast' => true, |
| 61 |
'lowercase_constants' => true, |
| 62 |
'lowercase_keywords' => true, |
| 63 |
'magic_constant_casing' => true, |
| 64 |
'mb_str_functions' => false, // No, too dangerous to change that |
| 65 |
'method_argument_space' => true, |
| 66 |
'method_chaining_indentation' => true, |
| 67 |
'method_separation' => true, |
| 68 |
'modernize_types_casting' => true, |
| 69 |
'multiline_comment_opening_closing' => true, |
| 70 |
'native_function_casing' => true, |
| 71 |
'native_function_invocation' => false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now |
| 72 |
'new_with_braces' => true, |
| 73 |
'no_alias_functions' => true, |
| 74 |
'no_blank_lines_after_class_opening' => true, |
| 75 |
'no_blank_lines_after_phpdoc' => true, |
| 76 |
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace |
| 77 |
'no_break_comment' => true, |
| 78 |
'no_closing_tag' => true, |
| 79 |
'no_empty_comment' => true, |
| 80 |
'no_empty_phpdoc' => true, |
| 81 |
'no_empty_statement' => true, |
| 82 |
'no_extra_blank_lines' => true, |
| 83 |
'no_homoglyph_names' => true, |
| 84 |
'no_leading_import_slash' => true, |
| 85 |
'no_leading_namespace_whitespace' => true, |
| 86 |
'no_mixed_echo_print' => true, |
| 87 |
'no_multiline_whitespace_around_double_arrow' => true, |
| 88 |
'no_multiline_whitespace_before_semicolons' => true, |
| 89 |
'non_printable_character' => true, |
| 90 |
'no_null_property_initialization' => true, |
| 91 |
'no_php4_constructor' => true, |
| 92 |
'normalize_index_brace' => true, |
| 93 |
'no_short_bool_cast' => true, |
| 94 |
'no_short_echo_tag' => true, |
| 95 |
'no_singleline_whitespace_before_semicolons' => true, |
| 96 |
'no_spaces_after_function_name' => true, |
| 97 |
'no_spaces_around_offset' => true, |
| 98 |
'no_spaces_inside_parenthesis' => true, |
| 99 |
'no_superfluous_elseif' => false, // Might be risky on a huge code base |
| 100 |
'not_operator_with_space' => false, // No we prefer to keep '!' without spaces |
| 101 |
'not_operator_with_successor_space' => false, // idem |
| 102 |
'no_trailing_comma_in_list_call' => true, |
| 103 |
'no_trailing_comma_in_singleline_array' => true, |
| 104 |
'no_trailing_whitespace_in_comment' => true, |
| 105 |
'no_trailing_whitespace' => true, |
| 106 |
'no_unneeded_control_parentheses' => true, |
| 107 |
'no_unneeded_curly_braces' => true, |
| 108 |
'no_unneeded_final_method' => true, |
| 109 |
'no_unreachable_default_argument_value' => true, |
| 110 |
'no_unused_imports' => true, |
| 111 |
'no_useless_else' => true, |
| 112 |
'no_useless_return' => true, |
| 113 |
'no_whitespace_before_comma_in_array' => true, |
| 114 |
'no_whitespace_in_blank_line' => true, |
| 115 |
'object_operator_without_whitespace' => true, |
| 116 |
'ordered_class_elements' => false, // We prefer to keep some freedom |
| 117 |
'ordered_imports' => true, |
| 118 |
'phpdoc_add_missing_param_annotation' => true, |
| 119 |
'phpdoc_align' => false, // Waste of time |
| 120 |
'phpdoc_annotation_without_dot' => true, |
| 121 |
'phpdoc_indent' => true, |
| 122 |
'phpdoc_inline_tag' => true, |
| 123 |
'phpdoc_no_access' => true, |
| 124 |
'phpdoc_no_alias_tag' => true, |
| 125 |
'phpdoc_no_empty_return' => true, |
| 126 |
'phpdoc_no_package' => true, |
| 127 |
'phpdoc_no_useless_inheritdoc' => true, |
| 128 |
'phpdoc_order' => true, |
| 129 |
'phpdoc_return_self_reference' => true, |
| 130 |
'phpdoc_scalar' => true, |
| 131 |
'phpdoc_separation' => true, |
| 132 |
'phpdoc_single_line_var_spacing' => true, |
| 133 |
'phpdoc_summary' => true, |
| 134 |
'phpdoc_to_comment' => true, |
| 135 |
'phpdoc_trim' => true, |
| 136 |
'phpdoc_types_order' => true, |
| 137 |
'phpdoc_types' => true, |
| 138 |
'phpdoc_var_without_name' => true, |
| 139 |
'php_unit_construct' => true, |
| 140 |
'php_unit_dedicate_assert' => true, |
| 141 |
'php_unit_expectation' => true, |
| 142 |
'php_unit_fqcn_annotation' => true, |
| 143 |
'php_unit_mock' => true, |
| 144 |
'php_unit_namespaced' => true, |
| 145 |
'php_unit_no_expectation_annotation' => true, |
| 146 |
'php_unit_strict' => false, // We sometime actually need assertEquals |
| 147 |
'php_unit_test_annotation' => true, |
| 148 |
'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage |
| 149 |
'pow_to_exponentiation' => false, |
| 150 |
'protected_to_private' => true, |
| 151 |
'psr0' => true, |
| 152 |
'psr4' => true, |
| 153 |
'random_api_migration' => false, // This breaks our unit tests |
| 154 |
'return_type_declaration' => true, |
| 155 |
'self_accessor' => true, |
| 156 |
'semicolon_after_instruction' => false, // Buggy in `samples/index.php` |
| 157 |
'short_scalar_cast' => true, |
| 158 |
'silenced_deprecation_error' => true, |
| 159 |
'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null |
| 160 |
'single_blank_line_at_eof' => true, |
| 161 |
'single_blank_line_before_namespace' => true, |
| 162 |
'single_class_element_per_statement' => true, |
| 163 |
'single_import_per_statement' => true, |
| 164 |
'single_line_after_imports' => true, |
| 165 |
'single_line_comment_style' => true, |
| 166 |
'single_quote' => true, |
| 167 |
'space_after_semicolon' => true, |
| 168 |
'standardize_not_equals' => true, |
| 169 |
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()` |
| 170 |
'strict_comparison' => false, // No, too dangerous to change that |
| 171 |
'strict_param' => false, // No, too dangerous to change that |
| 172 |
'switch_case_semicolon_to_colon' => true, |
| 173 |
'switch_case_space' => true, |
| 174 |
'ternary_operator_spaces' => true, |
| 175 |
'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6 |
| 176 |
'trailing_comma_in_multiline_array' => true, |
| 177 |
'trim_array_spaces' => true, |
| 178 |
'unary_operator_spaces' => true, |
| 179 |
'visibility_required' => true, |
| 180 |
'void_return' => false, // Cannot use that with PHP 5.6 |
| 181 |
'whitespace_after_comma_in_array' => true, |
| 182 |
'yoda_style' => false, |
| 183 |
]); |
| 184 |
|