.php_cs.dist 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php declare(strict_types=1);
  2. $header = <<<'EOF'
  3. This file is part of sebastian/complexity.
  4. (c) Sebastian Bergmann <sebastian@phpunit.de>
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. EOF;
  8. $finder = PhpCsFixer\Finder::create()
  9. ->files()
  10. ->in(__DIR__ . '/src')
  11. ->in(__DIR__ . '/tests/unit')
  12. ->in(__DIR__ . '/tests/integration');
  13. return PhpCsFixer\Config::create()
  14. ->setFinder($finder)
  15. ->setRiskyAllowed(true)
  16. ->setRules([
  17. 'align_multiline_comment' => true,
  18. 'array_indentation' => true,
  19. 'array_syntax' => ['syntax' => 'short'],
  20. 'binary_operator_spaces' => [
  21. 'operators' => [
  22. '=' => 'align_single_space_minimal',
  23. '=>' => 'align_single_space_minimal',
  24. ],
  25. ],
  26. 'blank_line_after_namespace' => true,
  27. 'blank_line_before_statement' => [
  28. 'statements' => [
  29. 'break',
  30. 'continue',
  31. 'declare',
  32. 'default',
  33. 'die',
  34. 'do',
  35. 'exit',
  36. 'for',
  37. 'foreach',
  38. 'goto',
  39. 'if',
  40. 'include',
  41. 'include_once',
  42. 'require',
  43. 'require_once',
  44. 'return',
  45. 'switch',
  46. 'throw',
  47. 'try',
  48. 'while',
  49. 'yield',
  50. ],
  51. ],
  52. 'braces' => true,
  53. 'cast_spaces' => true,
  54. 'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
  55. 'combine_consecutive_issets' => true,
  56. 'combine_consecutive_unsets' => true,
  57. 'compact_nullable_typehint' => true,
  58. 'concat_space' => ['spacing' => 'one'],
  59. 'constant_case' => true,
  60. 'declare_equal_normalize' => ['space' => 'none'],
  61. 'declare_strict_types' => true,
  62. 'dir_constant' => true,
  63. 'elseif' => true,
  64. 'encoding' => true,
  65. 'explicit_indirect_variable' => true,
  66. 'explicit_string_variable' => true,
  67. 'full_opening_tag' => true,
  68. 'fully_qualified_strict_types' => true,
  69. 'function_declaration' => true,
  70. 'global_namespace_import' => [
  71. 'import_classes' => true,
  72. 'import_constants' => true,
  73. 'import_functions' => true,
  74. ],
  75. 'header_comment' => ['header' => $header, 'separate' => 'none'],
  76. 'heredoc_to_nowdoc' => true,
  77. 'increment_style' => [
  78. 'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
  79. ],
  80. 'indentation_type' => true,
  81. 'is_null' => true,
  82. 'line_ending' => true,
  83. 'list_syntax' => ['syntax' => 'short'],
  84. 'logical_operators' => true,
  85. 'lowercase_keywords' => true,
  86. 'lowercase_static_reference' => true,
  87. 'magic_constant_casing' => true,
  88. 'magic_method_casing' => true,
  89. 'method_argument_space' => ['ensure_fully_multiline' => true],
  90. 'modernize_types_casting' => true,
  91. 'multiline_comment_opening_closing' => true,
  92. 'multiline_whitespace_before_semicolons' => true,
  93. 'native_constant_invocation' => false,
  94. 'native_function_casing' => false,
  95. 'native_function_invocation' => false,
  96. 'native_function_type_declaration_casing' => true,
  97. 'new_with_braces' => false,
  98. 'no_alias_functions' => true,
  99. 'no_alternative_syntax' => true,
  100. 'no_blank_lines_after_class_opening' => true,
  101. 'no_blank_lines_after_phpdoc' => true,
  102. 'no_blank_lines_before_namespace' => true,
  103. 'no_closing_tag' => true,
  104. 'no_empty_comment' => true,
  105. 'no_empty_phpdoc' => true,
  106. 'no_empty_statement' => true,
  107. 'no_extra_blank_lines' => true,
  108. 'no_homoglyph_names' => true,
  109. 'no_leading_import_slash' => true,
  110. 'no_leading_namespace_whitespace' => true,
  111. 'no_mixed_echo_print' => ['use' => 'print'],
  112. 'no_multiline_whitespace_around_double_arrow' => true,
  113. 'no_null_property_initialization' => true,
  114. 'no_php4_constructor' => true,
  115. 'no_short_bool_cast' => true,
  116. 'no_short_echo_tag' => true,
  117. 'no_singleline_whitespace_before_semicolons' => true,
  118. 'no_spaces_after_function_name' => true,
  119. 'no_spaces_around_offset' => true,
  120. 'no_spaces_inside_parenthesis' => true,
  121. 'no_superfluous_elseif' => true,
  122. 'no_superfluous_phpdoc_tags' => [
  123. 'allow_mixed' => true,
  124. ],
  125. 'no_trailing_comma_in_list_call' => true,
  126. 'no_trailing_comma_in_singleline_array' => true,
  127. 'no_trailing_whitespace' => true,
  128. 'no_trailing_whitespace_in_comment' => true,
  129. 'no_unneeded_control_parentheses' => true,
  130. 'no_unneeded_curly_braces' => true,
  131. 'no_unneeded_final_method' => true,
  132. 'no_unreachable_default_argument_value' => true,
  133. 'no_unset_on_property' => true,
  134. 'no_unused_imports' => true,
  135. 'no_useless_else' => true,
  136. 'no_useless_return' => true,
  137. 'no_whitespace_before_comma_in_array' => true,
  138. 'no_whitespace_in_blank_line' => true,
  139. 'non_printable_character' => true,
  140. 'normalize_index_brace' => true,
  141. 'object_operator_without_whitespace' => true,
  142. 'ordered_class_elements' => [
  143. 'order' => [
  144. 'use_trait',
  145. 'constant_public',
  146. 'constant_protected',
  147. 'constant_private',
  148. 'property_public_static',
  149. 'property_protected_static',
  150. 'property_private_static',
  151. 'property_public',
  152. 'property_protected',
  153. 'property_private',
  154. 'method_public_static',
  155. 'construct',
  156. 'destruct',
  157. 'magic',
  158. 'phpunit',
  159. 'method_public',
  160. 'method_protected',
  161. 'method_private',
  162. 'method_protected_static',
  163. 'method_private_static',
  164. ],
  165. ],
  166. 'ordered_imports' => [
  167. 'imports_order' => [
  168. PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
  169. PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
  170. PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
  171. ]
  172. ],
  173. 'ordered_interfaces' => [
  174. 'direction' => 'ascend',
  175. 'order' => 'alpha',
  176. ],
  177. 'phpdoc_add_missing_param_annotation' => false,
  178. 'phpdoc_align' => true,
  179. 'phpdoc_annotation_without_dot' => true,
  180. 'phpdoc_indent' => true,
  181. 'phpdoc_no_access' => true,
  182. 'phpdoc_no_empty_return' => true,
  183. 'phpdoc_no_package' => true,
  184. 'phpdoc_order' => true,
  185. 'phpdoc_return_self_reference' => true,
  186. 'phpdoc_scalar' => true,
  187. 'phpdoc_separation' => true,
  188. 'phpdoc_single_line_var_spacing' => true,
  189. 'phpdoc_summary' => true,
  190. 'phpdoc_to_comment' => true,
  191. 'phpdoc_trim' => true,
  192. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  193. 'phpdoc_types' => ['groups' => ['simple', 'meta']],
  194. 'phpdoc_types_order' => true,
  195. 'phpdoc_var_without_name' => true,
  196. 'pow_to_exponentiation' => true,
  197. 'protected_to_private' => true,
  198. 'return_assignment' => true,
  199. 'return_type_declaration' => ['space_before' => 'none'],
  200. 'self_accessor' => true,
  201. 'self_static_accessor' => true,
  202. 'semicolon_after_instruction' => true,
  203. 'set_type_to_cast' => true,
  204. 'short_scalar_cast' => true,
  205. 'simple_to_complex_string_variable' => true,
  206. 'simplified_null_return' => false,
  207. 'single_blank_line_at_eof' => true,
  208. 'single_import_per_statement' => true,
  209. 'single_line_after_imports' => true,
  210. 'single_quote' => true,
  211. 'standardize_not_equals' => true,
  212. 'strict_param' => true,
  213. 'ternary_to_null_coalescing' => true,
  214. 'trailing_comma_in_multiline_array' => true,
  215. 'trim_array_spaces' => true,
  216. 'unary_operator_spaces' => true,
  217. 'visibility_required' => [
  218. 'elements' => [
  219. 'const',
  220. 'method',
  221. 'property',
  222. ],
  223. ],
  224. 'void_return' => true,
  225. 'whitespace_after_comma_in_array' => true,
  226. ]);