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

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