.php-cs-fixer.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. $header = <<<'EOF'
  12. This file is part of Hyperf.
  13. @link https://www.hyperf.io
  14. @document https://hyperf.wiki
  15. @contact group@hyperf.io
  16. @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  17. EOF;
  18. return (new PhpCsFixer\Config())
  19. ->setRiskyAllowed(true)
  20. ->setRules([
  21. '@PSR2' => true,
  22. '@Symfony' => true,
  23. '@DoctrineAnnotation' => true,
  24. '@PhpCsFixer' => true,
  25. 'header_comment' => [
  26. 'comment_type' => 'PHPDoc',
  27. 'header' => $header,
  28. 'separate' => 'none',
  29. 'location' => 'after_declare_strict',
  30. ],
  31. 'array_syntax' => [
  32. 'syntax' => 'short',
  33. ],
  34. 'list_syntax' => [
  35. 'syntax' => 'short',
  36. ],
  37. 'concat_space' => [
  38. 'spacing' => 'one',
  39. ],
  40. 'global_namespace_import' => [
  41. 'import_classes' => true,
  42. 'import_constants' => true,
  43. 'import_functions' => null,
  44. ],
  45. 'blank_line_before_statement' => [
  46. 'statements' => [
  47. 'declare',
  48. ],
  49. ],
  50. 'general_phpdoc_annotation_remove' => [
  51. 'annotations' => [
  52. 'author',
  53. ],
  54. ],
  55. 'ordered_imports' => [
  56. 'imports_order' => [
  57. 'class', 'function', 'const',
  58. ],
  59. 'sort_algorithm' => 'alpha',
  60. ],
  61. 'single_line_comment_style' => [
  62. 'comment_types' => [
  63. ],
  64. ],
  65. 'yoda_style' => [
  66. 'always_move_variable' => false,
  67. 'equal' => false,
  68. 'identical' => false,
  69. ],
  70. 'phpdoc_align' => [
  71. 'align' => 'left',
  72. ],
  73. 'multiline_whitespace_before_semicolons' => [
  74. 'strategy' => 'no_multi_line',
  75. ],
  76. 'constant_case' => [
  77. 'case' => 'lower',
  78. ],
  79. 'class_attributes_separation' => true,
  80. 'combine_consecutive_unsets' => true,
  81. 'declare_strict_types' => true,
  82. 'linebreak_after_opening_tag' => true,
  83. 'lowercase_static_reference' => true,
  84. 'no_useless_else' => true,
  85. 'no_unused_imports' => true,
  86. 'not_operator_with_successor_space' => true,
  87. 'not_operator_with_space' => false,
  88. 'ordered_class_elements' => true,
  89. 'php_unit_strict' => false,
  90. 'phpdoc_separation' => false,
  91. 'single_quote' => true,
  92. 'standardize_not_equals' => true,
  93. 'multiline_comment_opening_closing' => true,
  94. 'single_line_empty_body' => false,
  95. ])
  96. ->setFinder(
  97. PhpCsFixer\Finder::create()
  98. ->exclude('public')
  99. ->exclude('runtime')
  100. ->exclude('vendor')
  101. ->in(__DIR__)
  102. )
  103. ->setUsingCache(false);