.php_cs.dist 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. require __DIR__ . '/tools/php-cs-fixer.d/PhpdocSingleLineVarFixer.php';
  3. return PhpCsFixer\Config::create()
  4. ->registerCustomFixers([
  5. new \PharIo\CSFixer\PhpdocSingleLineVarFixer()
  6. ])
  7. ->setRiskyAllowed(true)
  8. ->setRules(
  9. [
  10. 'PharIo/phpdoc_single_line_var_fixer' => true,
  11. 'align_multiline_comment' => true,
  12. 'array_indentation' => true,
  13. 'array_syntax' => ['syntax' => 'short'],
  14. 'binary_operator_spaces' => [
  15. 'operators' => [
  16. '=' => 'align_single_space_minimal',
  17. '=>' => 'align',
  18. ],
  19. ],
  20. 'blank_line_after_namespace' => true,
  21. 'blank_line_after_opening_tag' => false,
  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' => [
  44. 'allow_single_line_closure' => false,
  45. 'position_after_anonymous_constructs' => 'same',
  46. 'position_after_control_structures' => 'same',
  47. 'position_after_functions_and_oop_constructs' => 'same'
  48. ],
  49. 'cast_spaces' => ['space' => 'none'],
  50. // This fixer removes the blank line at class start, no way to disable that, so we disable the fixer :(
  51. //'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
  52. 'combine_consecutive_issets' => true,
  53. 'combine_consecutive_unsets' => true,
  54. 'compact_nullable_typehint' => true,
  55. 'concat_space' => ['spacing' => 'one'],
  56. 'date_time_immutable' => true,
  57. 'declare_equal_normalize' => ['space' => 'single'],
  58. 'declare_strict_types' => true,
  59. 'dir_constant' => true,
  60. 'elseif' => true,
  61. 'encoding' => true,
  62. 'full_opening_tag' => true,
  63. 'fully_qualified_strict_types' => true,
  64. 'function_declaration' => [
  65. 'closure_function_spacing' => 'one'
  66. ],
  67. 'header_comment' => false,
  68. 'indentation_type' => true,
  69. 'is_null' => true,
  70. 'line_ending' => true,
  71. 'list_syntax' => ['syntax' => 'short'],
  72. 'logical_operators' => true,
  73. 'lowercase_cast' => true,
  74. 'lowercase_constants' => true,
  75. 'lowercase_keywords' => true,
  76. 'lowercase_static_reference' => true,
  77. 'magic_constant_casing' => true,
  78. 'method_argument_space' => ['ensure_fully_multiline' => true],
  79. 'modernize_types_casting' => true,
  80. 'multiline_comment_opening_closing' => true,
  81. 'multiline_whitespace_before_semicolons' => true,
  82. 'native_constant_invocation' => true,
  83. 'native_function_casing' => true,
  84. 'native_function_invocation' => true,
  85. 'new_with_braces' => false,
  86. 'no_alias_functions' => true,
  87. 'no_alternative_syntax' => true,
  88. 'no_blank_lines_after_class_opening' => false,
  89. 'no_blank_lines_after_phpdoc' => true,
  90. 'no_blank_lines_before_namespace' => true,
  91. 'no_closing_tag' => true,
  92. 'no_empty_comment' => true,
  93. 'no_empty_phpdoc' => true,
  94. 'no_empty_statement' => true,
  95. 'no_extra_blank_lines' => true,
  96. 'no_homoglyph_names' => true,
  97. 'no_leading_import_slash' => true,
  98. 'no_leading_namespace_whitespace' => true,
  99. 'no_mixed_echo_print' => ['use' => 'print'],
  100. 'no_multiline_whitespace_around_double_arrow' => true,
  101. 'no_null_property_initialization' => true,
  102. 'no_php4_constructor' => true,
  103. 'no_short_bool_cast' => true,
  104. 'no_short_echo_tag' => true,
  105. 'no_singleline_whitespace_before_semicolons' => true,
  106. 'no_spaces_after_function_name' => true,
  107. 'no_spaces_inside_parenthesis' => true,
  108. 'no_superfluous_elseif' => true,
  109. 'no_superfluous_phpdoc_tags' => true,
  110. 'no_trailing_comma_in_list_call' => true,
  111. 'no_trailing_comma_in_singleline_array' => true,
  112. 'no_trailing_whitespace' => true,
  113. 'no_trailing_whitespace_in_comment' => true,
  114. 'no_unneeded_control_parentheses' => false,
  115. 'no_unneeded_curly_braces' => false,
  116. 'no_unneeded_final_method' => true,
  117. 'no_unreachable_default_argument_value' => true,
  118. 'no_unset_on_property' => true,
  119. 'no_unused_imports' => true,
  120. 'no_useless_else' => true,
  121. 'no_useless_return' => true,
  122. 'no_whitespace_before_comma_in_array' => true,
  123. 'no_whitespace_in_blank_line' => true,
  124. 'non_printable_character' => true,
  125. 'normalize_index_brace' => true,
  126. 'object_operator_without_whitespace' => true,
  127. 'ordered_class_elements' => [
  128. 'order' => [
  129. 'use_trait',
  130. 'constant_public',
  131. 'constant_protected',
  132. 'constant_private',
  133. 'property_public_static',
  134. 'property_protected_static',
  135. 'property_private_static',
  136. 'property_public',
  137. 'property_protected',
  138. 'property_private',
  139. 'method_public_static',
  140. 'construct',
  141. 'destruct',
  142. 'magic',
  143. 'phpunit',
  144. 'method_public',
  145. 'method_protected',
  146. 'method_private',
  147. 'method_protected_static',
  148. 'method_private_static',
  149. ],
  150. ],
  151. 'ordered_imports' => true,
  152. 'phpdoc_add_missing_param_annotation' => true,
  153. 'phpdoc_align' => true,
  154. 'phpdoc_annotation_without_dot' => true,
  155. 'phpdoc_indent' => true,
  156. 'phpdoc_no_access' => true,
  157. 'phpdoc_no_empty_return' => true,
  158. 'phpdoc_no_package' => true,
  159. 'phpdoc_order' => true,
  160. 'phpdoc_return_self_reference' => true,
  161. 'phpdoc_scalar' => true,
  162. 'phpdoc_separation' => true,
  163. 'phpdoc_single_line_var_spacing' => true,
  164. 'phpdoc_to_comment' => false,
  165. 'phpdoc_trim' => true,
  166. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  167. 'phpdoc_types' => ['groups' => ['simple', 'meta']],
  168. 'phpdoc_types_order' => true,
  169. 'phpdoc_to_return_type' => true,
  170. 'phpdoc_var_without_name' => true,
  171. 'pow_to_exponentiation' => true,
  172. 'protected_to_private' => true,
  173. 'return_assignment' => true,
  174. 'return_type_declaration' => ['space_before' => 'none'],
  175. 'self_accessor' => false,
  176. 'semicolon_after_instruction' => true,
  177. 'set_type_to_cast' => true,
  178. 'short_scalar_cast' => true,
  179. 'simplified_null_return' => true,
  180. 'single_blank_line_at_eof' => true,
  181. 'single_import_per_statement' => true,
  182. 'single_line_after_imports' => true,
  183. 'single_quote' => true,
  184. 'standardize_not_equals' => true,
  185. 'ternary_to_null_coalescing' => true,
  186. 'trailing_comma_in_multiline_array' => false,
  187. 'trim_array_spaces' => true,
  188. 'unary_operator_spaces' => true,
  189. 'visibility_required' => [
  190. 'elements' => [
  191. 'const',
  192. 'method',
  193. 'property',
  194. ],
  195. ],
  196. 'void_return' => true,
  197. 'whitespace_after_comma_in_array' => true,
  198. 'yoda_style' => false
  199. ]
  200. )
  201. ->setFinder(
  202. PhpCsFixer\Finder::create()
  203. ->files()
  204. ->in(__DIR__ . '/src')
  205. ->in(__DIR__ . '/tests')
  206. ->notName('*.phpt')
  207. ->notName('autoload.php')
  208. );