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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <?php declare(strict_types=1);
  2. $header = <<<'EOF'
  3. This file is part of phpunit/php-code-coverage.
  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/tests')
  12. ;
  13. $config = new PhpCsFixer\Config;
  14. $config->setFinder($finder)
  15. ->setRiskyAllowed(true)
  16. ->setRules([
  17. 'align_multiline_comment' => true,
  18. 'array_indentation' => true,
  19. 'array_push' => true,
  20. 'array_syntax' => ['syntax' => 'short'],
  21. 'backtick_to_shell_exec' => true,
  22. 'binary_operator_spaces' => [
  23. 'operators' => [
  24. '=' => 'align_single_space_minimal',
  25. '=>' => 'align_single_space_minimal',
  26. ],
  27. ],
  28. 'blank_line_after_namespace' => true,
  29. 'blank_line_before_statement' => [
  30. 'statements' => [
  31. 'break',
  32. 'case',
  33. 'continue',
  34. 'declare',
  35. 'default',
  36. 'do',
  37. 'exit',
  38. 'for',
  39. 'foreach',
  40. 'goto',
  41. 'if',
  42. 'include',
  43. 'include_once',
  44. 'phpdoc',
  45. 'require',
  46. 'require_once',
  47. 'return',
  48. 'switch',
  49. 'throw',
  50. 'try',
  51. 'while',
  52. 'yield',
  53. 'yield_from',
  54. ],
  55. ],
  56. 'cast_spaces' => true,
  57. 'class_attributes_separation' => [
  58. 'elements' => [
  59. 'const' => 'none',
  60. 'method' => 'one',
  61. 'property' => 'only_if_meta'
  62. ]
  63. ],
  64. 'class_definition' => true,
  65. 'clean_namespace' => true,
  66. 'combine_consecutive_issets' => true,
  67. 'combine_consecutive_unsets' => true,
  68. 'combine_nested_dirname' => true,
  69. 'compact_nullable_typehint' => true,
  70. 'concat_space' => ['spacing' => 'one'],
  71. 'constant_case' => true,
  72. 'control_structure_braces' => true,
  73. 'control_structure_continuation_position' => true,
  74. 'curly_braces_position' => [
  75. 'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
  76. 'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
  77. ],
  78. 'declare_equal_normalize' => ['space' => 'none'],
  79. 'declare_parentheses' => true,
  80. 'declare_strict_types' => true,
  81. 'dir_constant' => true,
  82. 'echo_tag_syntax' => true,
  83. 'elseif' => true,
  84. 'encoding' => true,
  85. 'ereg_to_preg' => true,
  86. 'explicit_indirect_variable' => true,
  87. 'explicit_string_variable' => true,
  88. 'fopen_flag_order' => true,
  89. 'full_opening_tag' => true,
  90. 'fully_qualified_strict_types' => true,
  91. 'function_declaration' => true,
  92. 'function_to_constant' => true,
  93. 'function_typehint_space' => true,
  94. 'global_namespace_import' => [
  95. 'import_classes' => true,
  96. 'import_constants' => true,
  97. 'import_functions' => true,
  98. ],
  99. 'header_comment' => ['header' => $header, 'separate' => 'none'],
  100. 'heredoc_to_nowdoc' => true,
  101. 'implode_call' => true,
  102. 'include' => true,
  103. 'increment_style' => [
  104. 'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST,
  105. ],
  106. 'indentation_type' => true,
  107. 'is_null' => true,
  108. 'lambda_not_used_import' => true,
  109. 'line_ending' => true,
  110. 'list_syntax' => ['syntax' => 'short'],
  111. 'logical_operators' => true,
  112. 'lowercase_cast' => true,
  113. 'lowercase_keywords' => true,
  114. 'lowercase_static_reference' => true,
  115. 'magic_constant_casing' => true,
  116. 'magic_method_casing' => true,
  117. 'method_argument_space' => [
  118. 'on_multiline' => 'ensure_fully_multiline',
  119. ],
  120. 'modernize_types_casting' => true,
  121. 'multiline_comment_opening_closing' => true,
  122. 'multiline_whitespace_before_semicolons' => true,
  123. 'native_constant_invocation' => false,
  124. 'native_function_casing' => false,
  125. 'native_function_invocation' => [
  126. 'include' => [
  127. '@internal',
  128. ],
  129. ],
  130. 'native_function_type_declaration_casing' => true,
  131. 'new_with_braces' => [
  132. 'named_class' => false,
  133. 'anonymous_class' => false,
  134. ],
  135. 'no_alias_functions' => true,
  136. 'no_alias_language_construct_call' => true,
  137. 'no_alternative_syntax' => true,
  138. 'no_binary_string' => true,
  139. 'no_blank_lines_after_class_opening' => true,
  140. 'no_blank_lines_after_phpdoc' => true,
  141. 'no_blank_lines_before_namespace' => true,
  142. 'no_break_comment' => true,
  143. 'no_closing_tag' => true,
  144. 'no_empty_comment' => true,
  145. 'no_empty_phpdoc' => true,
  146. 'no_empty_statement' => true,
  147. 'no_extra_blank_lines' => true,
  148. 'no_homoglyph_names' => true,
  149. 'no_leading_import_slash' => true,
  150. 'no_leading_namespace_whitespace' => true,
  151. 'no_mixed_echo_print' => ['use' => 'print'],
  152. 'no_multiple_statements_per_line' => true,
  153. 'no_multiline_whitespace_around_double_arrow' => true,
  154. 'no_null_property_initialization' => true,
  155. 'no_php4_constructor' => true,
  156. 'no_short_bool_cast' => true,
  157. 'no_singleline_whitespace_before_semicolons' => true,
  158. 'no_spaces_after_function_name' => true,
  159. 'no_spaces_around_offset' => true,
  160. 'no_spaces_inside_parenthesis' => true,
  161. 'no_superfluous_elseif' => true,
  162. 'no_superfluous_phpdoc_tags' => [
  163. 'allow_mixed' => true,
  164. ],
  165. 'no_trailing_comma_in_singleline' => true,
  166. 'no_trailing_whitespace' => true,
  167. 'no_trailing_whitespace_in_comment' => true,
  168. 'no_trailing_whitespace_in_string' => true,
  169. 'no_unneeded_control_parentheses' => true,
  170. 'no_unneeded_curly_braces' => true,
  171. 'no_unneeded_final_method' => true,
  172. 'no_unneeded_import_alias' => true,
  173. 'no_unreachable_default_argument_value' => true,
  174. 'no_unset_cast' => true,
  175. 'no_unset_on_property' => true,
  176. 'no_unused_imports' => true,
  177. 'no_useless_else' => true,
  178. 'no_useless_return' => true,
  179. 'no_useless_sprintf' => true,
  180. 'no_whitespace_before_comma_in_array' => true,
  181. 'no_whitespace_in_blank_line' => true,
  182. 'non_printable_character' => true,
  183. 'normalize_index_brace' => true,
  184. 'object_operator_without_whitespace' => true,
  185. 'operator_linebreak' => [
  186. 'only_booleans' => true,
  187. 'position' => 'end',
  188. ],
  189. 'ordered_class_elements' => [
  190. 'order' => [
  191. 'use_trait',
  192. 'constant_public',
  193. 'constant_protected',
  194. 'constant_private',
  195. 'property_public_static',
  196. 'property_protected_static',
  197. 'property_private_static',
  198. 'property_public',
  199. 'property_protected',
  200. 'property_private',
  201. 'method_public_static',
  202. 'construct',
  203. 'destruct',
  204. 'magic',
  205. 'phpunit',
  206. 'method_public',
  207. 'method_protected',
  208. 'method_private',
  209. 'method_protected_static',
  210. 'method_private_static',
  211. ],
  212. ],
  213. 'ordered_imports' => [
  214. 'imports_order' => [
  215. PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
  216. PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
  217. PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
  218. ]
  219. ],
  220. 'ordered_interfaces' => [
  221. 'direction' => 'ascend',
  222. 'order' => 'alpha',
  223. ],
  224. 'ordered_traits' => true,
  225. 'php_unit_set_up_tear_down_visibility' => true,
  226. 'php_unit_test_case_static_method_calls' => [
  227. 'call_type' => 'this',
  228. ],
  229. 'phpdoc_add_missing_param_annotation' => false,
  230. 'phpdoc_align' => true,
  231. 'phpdoc_annotation_without_dot' => true,
  232. 'phpdoc_indent' => true,
  233. 'phpdoc_inline_tag_normalizer' => true,
  234. 'phpdoc_no_access' => true,
  235. 'phpdoc_no_alias_tag' => true,
  236. 'phpdoc_no_empty_return' => true,
  237. 'phpdoc_no_package' => true,
  238. 'phpdoc_no_useless_inheritdoc' => true,
  239. 'phpdoc_order' => true,
  240. 'phpdoc_order_by_value' => [
  241. 'annotations' => [
  242. 'covers',
  243. 'dataProvider',
  244. 'throws',
  245. 'uses',
  246. ],
  247. ],
  248. 'phpdoc_return_self_reference' => true,
  249. 'phpdoc_scalar' => true,
  250. 'phpdoc_separation' => true,
  251. 'phpdoc_single_line_var_spacing' => true,
  252. 'phpdoc_summary' => true,
  253. 'phpdoc_tag_casing' => true,
  254. 'phpdoc_tag_type' => true,
  255. 'phpdoc_to_comment' => true,
  256. 'phpdoc_trim' => true,
  257. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  258. 'phpdoc_types' => ['groups' => ['simple', 'meta']],
  259. 'phpdoc_types_order' => true,
  260. 'phpdoc_var_annotation_correct_order' => true,
  261. 'phpdoc_var_without_name' => true,
  262. 'pow_to_exponentiation' => true,
  263. 'protected_to_private' => true,
  264. 'return_assignment' => true,
  265. 'return_type_declaration' => ['space_before' => 'none'],
  266. 'self_accessor' => true,
  267. 'self_static_accessor' => true,
  268. 'semicolon_after_instruction' => true,
  269. 'set_type_to_cast' => true,
  270. 'short_scalar_cast' => true,
  271. 'simple_to_complex_string_variable' => true,
  272. 'simplified_null_return' => false,
  273. 'single_blank_line_at_eof' => true,
  274. 'single_class_element_per_statement' => true,
  275. 'single_import_per_statement' => true,
  276. 'single_line_after_imports' => true,
  277. 'single_quote' => true,
  278. 'single_space_around_construct' => true,
  279. 'single_trait_insert_per_statement' => true,
  280. 'space_after_semicolon' => true,
  281. 'standardize_increment' => true,
  282. 'standardize_not_equals' => true,
  283. 'statement_indentation' => true,
  284. 'static_lambda' => true,
  285. 'strict_param' => true,
  286. 'string_line_ending' => true,
  287. 'switch_case_semicolon_to_colon' => true,
  288. 'switch_case_space' => true,
  289. 'switch_continue_to_break' => true,
  290. 'ternary_operator_spaces' => true,
  291. 'ternary_to_elvis_operator' => true,
  292. 'ternary_to_null_coalescing' => true,
  293. 'trailing_comma_in_multiline' => [
  294. 'elements' => [
  295. 'arrays'
  296. ]
  297. ],
  298. 'trim_array_spaces' => true,
  299. 'types_spaces' => [
  300. 'space' => 'none',
  301. ],
  302. 'unary_operator_spaces' => true,
  303. 'visibility_required' => [
  304. 'elements' => [
  305. 'const',
  306. 'method',
  307. 'property',
  308. ],
  309. ],
  310. 'void_return' => true,
  311. 'whitespace_after_comma_in_array' => true,
  312. ]);
  313. return $config;