.php-cs-fixer.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. use PhpCsFixer\Config;
  3. use PhpCsFixer\Finder;
  4. $rules = [
  5. 'array_syntax' => ['syntax' => 'short'],
  6. 'binary_operator_spaces' => [
  7. 'default' => 'single_space',
  8. 'operators' => [
  9. '=>' => null,
  10. '|' => 'no_space',
  11. ]
  12. ],
  13. 'blank_line_after_namespace' => true,
  14. 'blank_line_after_opening_tag' => true,
  15. 'no_superfluous_phpdoc_tags' => true,
  16. 'blank_line_before_statement' => [
  17. 'statements' => ['return']
  18. ],
  19. 'braces' => true,
  20. 'cast_spaces' => true,
  21. 'class_definition' => true,
  22. 'concat_space' => [
  23. 'spacing' => 'one'
  24. ],
  25. 'declare_equal_normalize' => true,
  26. 'elseif' => true,
  27. 'encoding' => true,
  28. 'full_opening_tag' => true,
  29. 'declare_strict_types' => true,
  30. 'fully_qualified_strict_types' => true, // added by Shift
  31. 'function_declaration' => true,
  32. 'function_typehint_space' => true,
  33. 'heredoc_to_nowdoc' => true,
  34. 'include' => true,
  35. 'increment_style' => ['style' => 'post'],
  36. 'indentation_type' => true,
  37. 'linebreak_after_opening_tag' => true,
  38. 'line_ending' => true,
  39. 'lowercase_cast' => true,
  40. 'constant_case' => true,
  41. 'lowercase_keywords' => true,
  42. 'lowercase_static_reference' => true, // added from Symfony
  43. 'magic_method_casing' => true, // added from Symfony
  44. 'magic_constant_casing' => true,
  45. 'method_argument_space' => true,
  46. 'native_function_casing' => true,
  47. 'no_alias_functions' => true,
  48. 'no_extra_blank_lines' => [
  49. 'tokens' => [
  50. 'extra',
  51. 'throw',
  52. 'use',
  53. 'use_trait',
  54. ]
  55. ],
  56. 'no_blank_lines_after_class_opening' => true,
  57. 'no_blank_lines_after_phpdoc' => true,
  58. 'no_closing_tag' => true,
  59. 'no_empty_phpdoc' => true,
  60. 'no_empty_statement' => true,
  61. 'no_leading_import_slash' => true,
  62. 'no_leading_namespace_whitespace' => true,
  63. 'no_mixed_echo_print' => [
  64. 'use' => 'echo'
  65. ],
  66. 'no_multiline_whitespace_around_double_arrow' => true,
  67. 'multiline_whitespace_before_semicolons' => [
  68. 'strategy' => 'no_multi_line'
  69. ],
  70. 'no_short_bool_cast' => true,
  71. 'no_singleline_whitespace_before_semicolons' => true,
  72. 'no_spaces_after_function_name' => true,
  73. 'no_spaces_around_offset' => true,
  74. 'no_spaces_inside_parenthesis' => true,
  75. 'no_trailing_comma_in_list_call' => true,
  76. 'no_trailing_comma_in_singleline_array' => true,
  77. 'no_trailing_whitespace' => true,
  78. 'no_trailing_whitespace_in_comment' => true,
  79. 'no_unneeded_control_parentheses' => true,
  80. 'no_unreachable_default_argument_value' => true,
  81. 'no_useless_return' => true,
  82. 'no_whitespace_before_comma_in_array' => true,
  83. 'no_whitespace_in_blank_line' => true,
  84. 'normalize_index_brace' => true,
  85. 'not_operator_with_successor_space' => true,
  86. 'object_operator_without_whitespace' => true,
  87. 'ordered_imports' => ['sort_algorithm' => 'alpha'],
  88. 'phpdoc_indent' => true,
  89. 'general_phpdoc_tag_rename' => true,
  90. 'phpdoc_no_access' => true,
  91. 'phpdoc_no_package' => true,
  92. 'phpdoc_no_useless_inheritdoc' => true,
  93. 'phpdoc_scalar' => true,
  94. 'phpdoc_single_line_var_spacing' => true,
  95. 'phpdoc_summary' => true,
  96. 'phpdoc_to_comment' => false,
  97. 'phpdoc_trim' => true,
  98. 'phpdoc_types' => true,
  99. 'phpdoc_var_without_name' => true,
  100. 'psr_autoloading' => true,
  101. 'self_accessor' => true,
  102. 'short_scalar_cast' => true,
  103. 'simplified_null_return' => false, // disabled by Shift
  104. 'single_blank_line_at_eof' => true,
  105. 'single_blank_line_before_namespace' => true,
  106. 'single_class_element_per_statement' => true,
  107. 'single_import_per_statement' => true,
  108. 'single_line_after_imports' => true,
  109. 'no_unused_imports' => true,
  110. 'single_line_comment_style' => [
  111. 'comment_types' => ['hash']
  112. ],
  113. 'single_quote' => true,
  114. 'space_after_semicolon' => true,
  115. 'standardize_not_equals' => true,
  116. 'switch_case_semicolon_to_colon' => true,
  117. 'switch_case_space' => true,
  118. 'ternary_operator_spaces' => true,
  119. 'trailing_comma_in_multiline' => true,
  120. 'trim_array_spaces' => true,
  121. 'unary_operator_spaces' => true,
  122. 'whitespace_after_comma_in_array' => true,
  123. ];
  124. $project_path = getcwd();
  125. $finder = Finder::create()
  126. ->in([
  127. $project_path . '/src',
  128. ])
  129. ->name('*.php')
  130. ->notName('*.blade.php')
  131. ->ignoreDotFiles(true)
  132. ->ignoreVCS(true);
  133. return (new Config())
  134. ->setFinder($finder)
  135. ->setRules($rules)
  136. ->setRiskyAllowed(true)
  137. ->setUsingCache(true);