.php-cs-fixer.dist.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. $finder = PhpCsFixer\Finder::create()
  3. ->exclude('vendor')
  4. ->notPath('src/PhpSpreadsheet/Writer/ZipStream3.php')
  5. ->in(__DIR__);
  6. $config = new PhpCsFixer\Config();
  7. $config
  8. ->setRiskyAllowed(true)
  9. ->setFinder($finder)
  10. ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect(null, 600))
  11. ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
  12. ->setRules([
  13. 'align_multiline_comment' => true,
  14. 'array_indentation' => true,
  15. 'array_syntax' => ['syntax' => 'short'],
  16. 'backtick_to_shell_exec' => true,
  17. 'binary_operator_spaces' => true,
  18. 'blank_line_after_namespace' => true,
  19. 'blank_line_after_opening_tag' => true,
  20. 'blank_line_before_statement' => false,
  21. 'blank_lines_before_namespace' => ['max_line_breaks' => 2, 'min_line_breaks' => 2], // we want 1 blank line before namespace
  22. 'cast_spaces' => true,
  23. 'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
  24. 'class_definition' => false,
  25. 'combine_consecutive_issets' => true,
  26. 'combine_consecutive_unsets' => true,
  27. 'combine_nested_dirname' => true,
  28. 'comment_to_phpdoc' => false, // interferes with annotations
  29. 'compact_nullable_type_declaration' => true,
  30. 'concat_space' => ['spacing' => 'one'],
  31. 'constant_case' => true,
  32. 'date_time_immutable' => false, // Break our unit tests
  33. 'declare_equal_normalize' => true,
  34. 'declare_strict_types' => false, // Too early to adopt strict types
  35. 'dir_constant' => true,
  36. 'doctrine_annotation_array_assignment' => true,
  37. 'doctrine_annotation_braces' => true,
  38. 'doctrine_annotation_indentation' => true,
  39. 'doctrine_annotation_spaces' => true,
  40. 'elseif' => true,
  41. 'encoding' => true,
  42. 'ereg_to_preg' => true,
  43. 'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
  44. 'explicit_string_variable' => false, // I feel it makes the code actually harder to read
  45. 'final_class' => false, // We need non-final classes
  46. 'final_internal_class' => true,
  47. 'final_public_method_for_abstract_class' => false, // We need non-final methods
  48. 'self_static_accessor' => true,
  49. 'fopen_flag_order' => true,
  50. 'fopen_flags' => true,
  51. 'full_opening_tag' => true,
  52. 'fully_qualified_strict_types' => false,
  53. 'function_declaration' => true,
  54. 'function_to_constant' => true,
  55. 'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright']],
  56. 'global_namespace_import' => true,
  57. 'header_comment' => false, // We don't use common header in all our files
  58. 'heredoc_indentation' => true,
  59. 'heredoc_to_nowdoc' => false, // Not sure about this one
  60. 'implode_call' => true,
  61. 'include' => true,
  62. 'increment_style' => true,
  63. 'indentation_type' => true,
  64. 'is_null' => true,
  65. 'line_ending' => true,
  66. 'linebreak_after_opening_tag' => true,
  67. 'list_syntax' => ['syntax' => 'short'],
  68. 'logical_operators' => true,
  69. 'lowercase_cast' => true,
  70. 'lowercase_keywords' => true,
  71. 'lowercase_static_reference' => true,
  72. 'magic_constant_casing' => true,
  73. 'magic_method_casing' => true,
  74. 'mb_str_functions' => false, // No, too dangerous to change that
  75. 'method_argument_space' => true,
  76. 'method_chaining_indentation' => true,
  77. 'modernize_types_casting' => true,
  78. 'multiline_comment_opening_closing' => true,
  79. 'multiline_whitespace_before_semicolons' => true,
  80. 'native_constant_invocation' => false, // Micro optimization that look messy
  81. 'native_function_casing' => true,
  82. 'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
  83. 'new_with_parentheses' => ['anonymous_class' => true, 'named_class' => true],
  84. 'no_alias_functions' => true,
  85. 'no_alternative_syntax' => true,
  86. 'no_binary_string' => true,
  87. 'no_blank_lines_after_class_opening' => true,
  88. 'no_blank_lines_after_phpdoc' => true,
  89. 'no_break_comment' => true,
  90. 'no_closing_tag' => true,
  91. 'no_empty_comment' => true,
  92. 'no_empty_phpdoc' => true,
  93. 'no_empty_statement' => true,
  94. 'no_extra_blank_lines' => true,
  95. 'no_homoglyph_names' => true,
  96. 'no_leading_import_slash' => true,
  97. 'no_leading_namespace_whitespace' => true,
  98. 'no_mixed_echo_print' => true,
  99. 'no_multiline_whitespace_around_double_arrow' => true,
  100. 'no_null_property_initialization' => true,
  101. 'no_php4_constructor' => true,
  102. 'no_short_bool_cast' => true,
  103. 'echo_tag_syntax' => ['format' => 'long'],
  104. 'no_singleline_whitespace_before_semicolons' => true,
  105. 'no_spaces_after_function_name' => true,
  106. 'no_spaces_around_offset' => true,
  107. 'no_superfluous_elseif' => false, // Might be risky on a huge code base
  108. //'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
  109. 'no_trailing_comma_in_singleline' => ['elements' => ['arguments', 'array_destructuring', 'array', 'group_import']],
  110. 'no_trailing_whitespace' => true,
  111. 'no_trailing_whitespace_in_comment' => true,
  112. 'no_unneeded_control_parentheses' => true,
  113. 'no_unneeded_braces' => true,
  114. 'no_unneeded_final_method' => true,
  115. 'no_unreachable_default_argument_value' => true,
  116. 'no_unset_cast' => true,
  117. 'no_unset_on_property' => true,
  118. 'no_unused_imports' => true,
  119. 'no_useless_else' => true,
  120. 'no_useless_return' => true,
  121. 'no_whitespace_before_comma_in_array' => true,
  122. 'no_whitespace_in_blank_line' => true,
  123. 'non_printable_character' => true,
  124. 'normalize_index_brace' => true,
  125. 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
  126. 'not_operator_with_successor_space' => false, // idem
  127. 'nullable_type_declaration_for_default_null_value' => true,
  128. 'object_operator_without_whitespace' => true,
  129. 'ordered_class_elements' => false, // We prefer to keep some freedom
  130. 'ordered_imports' => true,
  131. 'ordered_interfaces' => true,
  132. 'php_unit_construct' => true,
  133. 'php_unit_dedicate_assert' => true,
  134. 'php_unit_dedicate_assert_internal_type' => true,
  135. 'php_unit_expectation' => true,
  136. 'php_unit_fqcn_annotation' => true,
  137. 'php_unit_internal_class' => false, // Because tests are excluded from package
  138. 'php_unit_method_casing' => true,
  139. 'php_unit_mock' => true,
  140. 'php_unit_mock_short_will_return' => true,
  141. 'php_unit_namespaced' => true,
  142. 'php_unit_no_expectation_annotation' => true,
  143. 'phpdoc_order_by_value' => ['annotations' => ['covers']],
  144. 'php_unit_set_up_tear_down_visibility' => true,
  145. 'php_unit_size_class' => false, // That seems extra work to maintain for little benefits
  146. 'php_unit_strict' => false, // We sometime actually need assertEquals
  147. 'php_unit_test_annotation' => true,
  148. 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
  149. 'php_unit_test_class_requires_covers' => false, // We don't care as much as we should about coverage
  150. 'phpdoc_add_missing_param_annotation' => false, // Don't add things that bring no value
  151. 'phpdoc_align' => false, // Waste of time
  152. 'phpdoc_annotation_without_dot' => true,
  153. 'phpdoc_indent' => true,
  154. //'phpdoc_inline_tag' => true,
  155. 'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
  156. 'phpdoc_no_access' => true,
  157. 'phpdoc_no_alias_tag' => true,
  158. 'phpdoc_no_empty_return' => true,
  159. 'phpdoc_no_package' => true,
  160. 'phpdoc_no_useless_inheritdoc' => true,
  161. 'phpdoc_order' => true,
  162. 'phpdoc_return_self_reference' => true,
  163. 'phpdoc_scalar' => true,
  164. 'phpdoc_separation' => true,
  165. 'phpdoc_single_line_var_spacing' => true,
  166. 'phpdoc_summary' => true,
  167. 'phpdoc_to_comment' => false, // interferes with annotations
  168. 'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use
  169. 'phpdoc_to_return_type' => false, // idem
  170. 'phpdoc_trim' => true,
  171. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  172. 'phpdoc_types' => true,
  173. 'phpdoc_types_order' => false,
  174. 'phpdoc_var_annotation_correct_order' => true,
  175. 'phpdoc_var_without_name' => true,
  176. 'pow_to_exponentiation' => true,
  177. 'protected_to_private' => true,
  178. //'psr0' => true,
  179. //'psr4' => true,
  180. 'random_api_migration' => true,
  181. 'return_assignment' => false, // Sometimes useful for clarity or debug
  182. 'return_type_declaration' => true,
  183. 'self_accessor' => true,
  184. 'self_static_accessor' => true,
  185. 'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
  186. 'set_type_to_cast' => true,
  187. 'short_scalar_cast' => true,
  188. 'simple_to_complex_string_variable' => false, // Would differ from TypeScript without obvious advantages
  189. 'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
  190. 'single_blank_line_at_eof' => true,
  191. 'single_class_element_per_statement' => true,
  192. 'single_import_per_statement' => true,
  193. 'single_line_after_imports' => true,
  194. 'single_line_comment_style' => true,
  195. 'single_line_throw' => false, // I don't see any reason for having a special case for Exception
  196. 'single_quote' => false,
  197. 'single_trait_insert_per_statement' => true,
  198. 'space_after_semicolon' => true,
  199. 'spaces_inside_parentheses' => ['space' => 'none'],
  200. 'standardize_increment' => true,
  201. 'standardize_not_equals' => true,
  202. 'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
  203. 'strict_comparison' => false, // No, too dangerous to change that
  204. 'strict_param' => false, // No, too dangerous to change that
  205. 'string_implicit_backslashes' => false, // was escape_implicit_backslashes, too confusing
  206. 'string_line_ending' => true,
  207. 'switch_case_semicolon_to_colon' => true,
  208. 'switch_case_space' => true,
  209. 'ternary_operator_spaces' => true,
  210. 'ternary_to_null_coalescing' => true,
  211. 'trailing_comma_in_multiline' => true,
  212. 'trim_array_spaces' => true,
  213. 'type_declaration_spaces' => ['elements' => ['function', 'property']], // was function_typehint_space
  214. 'unary_operator_spaces' => true,
  215. 'visibility_required' => ['elements' => ['property', 'method']], // not const
  216. 'void_return' => true,
  217. 'whitespace_after_comma_in_array' => true,
  218. 'yoda_style' => false,
  219. ]);
  220. return $config;