You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

184 lines
8.3 KiB

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