.php_cs.dist 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. $header = <<<'EOF'
  3. This file is part of sebastian/environment.
  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. return PhpCsFixer\Config::create()
  9. ->setRiskyAllowed(true)
  10. ->setRules(
  11. [
  12. 'align_multiline_comment' => true,
  13. 'array_indentation' => true,
  14. 'array_syntax' => ['syntax' => 'short'],
  15. 'binary_operator_spaces' => [
  16. 'operators' => [
  17. '=' => 'align',
  18. '=>' => 'align',
  19. ],
  20. ],
  21. 'blank_line_after_namespace' => true,
  22. 'blank_line_before_statement' => [
  23. 'statements' => [
  24. 'break',
  25. 'continue',
  26. 'declare',
  27. 'do',
  28. 'for',
  29. 'foreach',
  30. 'if',
  31. 'include',
  32. 'include_once',
  33. 'require',
  34. 'require_once',
  35. 'return',
  36. 'switch',
  37. 'throw',
  38. 'try',
  39. 'while',
  40. 'yield',
  41. ],
  42. ],
  43. 'braces' => true,
  44. 'cast_spaces' => true,
  45. 'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
  46. 'combine_consecutive_issets' => true,
  47. 'combine_consecutive_unsets' => true,
  48. 'combine_nested_dirname' => true,
  49. 'compact_nullable_typehint' => true,
  50. 'concat_space' => ['spacing' => 'one'],
  51. 'declare_equal_normalize' => ['space' => 'none'],
  52. 'declare_strict_types' => true,
  53. 'dir_constant' => true,
  54. 'elseif' => true,
  55. 'encoding' => true,
  56. 'full_opening_tag' => true,
  57. 'function_declaration' => true,
  58. 'header_comment' => ['header' => $header, 'separate' => 'none'],
  59. 'indentation_type' => true,
  60. 'is_null' => true,
  61. 'line_ending' => true,
  62. 'list_syntax' => ['syntax' => 'short'],
  63. 'logical_operators' => true,
  64. 'lowercase_cast' => true,
  65. 'lowercase_constants' => true,
  66. 'lowercase_keywords' => true,
  67. 'lowercase_static_reference' => true,
  68. 'magic_constant_casing' => true,
  69. 'method_argument_space' => ['ensure_fully_multiline' => true],
  70. 'modernize_types_casting' => true,
  71. 'multiline_comment_opening_closing' => true,
  72. 'multiline_whitespace_before_semicolons' => true,
  73. 'native_constant_invocation' => true,
  74. 'native_function_casing' => true,
  75. 'native_function_invocation' => true,
  76. 'new_with_braces' => false,
  77. 'no_alias_functions' => true,
  78. 'no_alternative_syntax' => true,
  79. 'no_blank_lines_after_class_opening' => true,
  80. 'no_blank_lines_after_phpdoc' => true,
  81. 'no_blank_lines_before_namespace' => true,
  82. 'no_closing_tag' => true,
  83. 'no_empty_comment' => true,
  84. 'no_empty_phpdoc' => true,
  85. 'no_empty_statement' => true,
  86. 'no_extra_blank_lines' => true,
  87. 'no_homoglyph_names' => true,
  88. 'no_leading_import_slash' => true,
  89. 'no_leading_namespace_whitespace' => true,
  90. 'no_mixed_echo_print' => ['use' => 'print'],
  91. 'no_multiline_whitespace_around_double_arrow' => true,
  92. 'no_null_property_initialization' => true,
  93. 'no_php4_constructor' => true,
  94. 'no_short_bool_cast' => true,
  95. 'no_short_echo_tag' => true,
  96. 'no_singleline_whitespace_before_semicolons' => true,
  97. 'no_spaces_after_function_name' => true,
  98. 'no_spaces_inside_parenthesis' => true,
  99. 'no_superfluous_elseif' => true,
  100. 'no_superfluous_phpdoc_tags' => true,
  101. 'no_trailing_comma_in_list_call' => true,
  102. 'no_trailing_comma_in_singleline_array' => true,
  103. 'no_trailing_whitespace' => true,
  104. 'no_trailing_whitespace_in_comment' => true,
  105. 'no_unneeded_control_parentheses' => true,
  106. 'no_unneeded_curly_braces' => true,
  107. 'no_unneeded_final_method' => true,
  108. 'no_unreachable_default_argument_value' => true,
  109. 'no_unset_on_property' => true,
  110. 'no_unused_imports' => true,
  111. 'no_useless_else' => true,
  112. 'no_useless_return' => true,
  113. 'no_whitespace_before_comma_in_array' => true,
  114. 'no_whitespace_in_blank_line' => true,
  115. 'non_printable_character' => true,
  116. 'normalize_index_brace' => true,
  117. 'object_operator_without_whitespace' => true,
  118. 'ordered_class_elements' => [
  119. 'order' => [
  120. 'use_trait',
  121. 'constant_public',
  122. 'constant_protected',
  123. 'constant_private',
  124. 'property_public_static',
  125. 'property_protected_static',
  126. 'property_private_static',
  127. 'property_public',
  128. 'property_protected',
  129. 'property_private',
  130. 'method_public_static',
  131. 'construct',
  132. 'destruct',
  133. 'magic',
  134. 'phpunit',
  135. 'method_public',
  136. 'method_protected',
  137. 'method_private',
  138. 'method_protected_static',
  139. 'method_private_static',
  140. ],
  141. ],
  142. 'ordered_imports' => true,
  143. 'phpdoc_add_missing_param_annotation' => true,
  144. 'phpdoc_align' => true,
  145. 'phpdoc_annotation_without_dot' => true,
  146. 'phpdoc_indent' => true,
  147. 'phpdoc_no_access' => true,
  148. 'phpdoc_no_empty_return' => true,
  149. 'phpdoc_no_package' => true,
  150. 'phpdoc_order' => true,
  151. 'phpdoc_return_self_reference' => true,
  152. 'phpdoc_scalar' => true,
  153. 'phpdoc_separation' => true,
  154. 'phpdoc_single_line_var_spacing' => true,
  155. 'phpdoc_to_comment' => true,
  156. 'phpdoc_trim' => true,
  157. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  158. 'phpdoc_types' => true,
  159. 'phpdoc_types_order' => true,
  160. 'phpdoc_var_without_name' => true,
  161. 'pow_to_exponentiation' => true,
  162. 'protected_to_private' => true,
  163. 'random_api_migration' => true,
  164. 'return_assignment' => true,
  165. 'return_type_declaration' => ['space_before' => 'none'],
  166. 'self_accessor' => true,
  167. 'semicolon_after_instruction' => true,
  168. 'set_type_to_cast' => true,
  169. 'short_scalar_cast' => true,
  170. 'simplified_null_return' => true,
  171. 'single_blank_line_at_eof' => true,
  172. 'single_import_per_statement' => true,
  173. 'single_line_after_imports' => true,
  174. 'single_quote' => true,
  175. 'standardize_not_equals' => true,
  176. 'ternary_to_null_coalescing' => true,
  177. 'trailing_comma_in_multiline_array' => true,
  178. 'trim_array_spaces' => true,
  179. 'unary_operator_spaces' => true,
  180. 'visibility_required' => [
  181. 'elements' => [
  182. 'const',
  183. 'method',
  184. 'property',
  185. ],
  186. ],
  187. 'void_return' => true,
  188. 'whitespace_after_comma_in_array' => true,
  189. ]
  190. )
  191. ->setFinder(
  192. PhpCsFixer\Finder::create()
  193. ->files()
  194. ->in(__DIR__ . '/src')
  195. ->in(__DIR__ . '/tests')
  196. );