.php_cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. use PhpCsFixer\Config;
  3. use PhpCsFixer\Finder;
  4. require __DIR__.'/vendor/autoload.php';
  5. $fixers = [
  6. // PHP arrays should be declared using the short syntax
  7. 'array_syntax' => ['syntax' => 'short'],
  8. // There MUST be one blank line after the namespace declaration
  9. 'blank_line_after_namespace' => true,
  10. // Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line
  11. 'blank_line_after_opening_tag' => true,
  12. // An empty line feed should precede a return statement
  13. 'blank_line_before_return' => true,
  14. // The body of each structure MUST be enclosed by braces
  15. // Braces should be properly placed
  16. // Body of braces should be properly indented
  17. 'braces' => true,
  18. // A single space should be between cast and variable
  19. 'cast_spaces' => true,
  20. // Whitespace around the key words of a class, trait or interfaces definition should be one space
  21. 'class_definition' => true,
  22. // The keyword elseif should be used instead of else if so that all control keywords look like single words
  23. 'elseif' => true,
  24. // PHP code MUST use only UTF-8 without BOM (remove BOM)
  25. 'encoding' => true,
  26. // PHP code must use the long <?php tags or short-echo <?= tags and not other tag variations
  27. 'full_opening_tag' => true,
  28. // Spaces should be properly placed in a function declaration
  29. 'function_declaration' => true,
  30. // Add missing space between function's argument and its typehint
  31. 'function_typehint_space' => true,
  32. // Include/Require and file path should be divided with a single space
  33. // File path should not be placed under brackets
  34. 'include' => true,
  35. // Code MUST use configured indentation type
  36. 'indentation_type' => true,
  37. // All PHP files must use same line ending
  38. 'line_ending' => true,
  39. // The PHP constants true, false, and null MUST be in lower case
  40. 'lowercase_constants' => true,
  41. // PHP keywords MUST be in lower case
  42. 'lowercase_keywords' => true,
  43. // In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after each comma
  44. 'method_argument_space' => true,
  45. // Methods must be separated with one blank line
  46. 'method_separation' => true,
  47. // There should be no empty lines after class opening brace
  48. 'no_blank_lines_after_class_opening' => true,
  49. // There should not be blank lines between docblock and the documented element
  50. 'no_blank_lines_after_phpdoc' => true,
  51. // The closing PHP tag MUST be omitted from files containing only PHP
  52. 'no_closing_tag' => true,
  53. // Remove leading slashes in use clauses
  54. 'no_leading_import_slash' => true,
  55. // The namespace declaration line shouldn't contain leading whitespace
  56. 'no_leading_namespace_whitespace' => true,
  57. // Multi-line whitespace before closing semicolon are prohibited
  58. 'no_multiline_whitespace_before_semicolons' => true,
  59. // Single-line whitespace before closing semicolon are prohibited
  60. 'no_singleline_whitespace_before_semicolons' => true,
  61. // There MUST NOT be a space after the opening parenthesis
  62. // There MUST NOT be a space before the closing parenthesis
  63. 'no_spaces_inside_parenthesis' => true,
  64. // Remove trailing commas in list function calls
  65. 'no_trailing_comma_in_list_call' => true,
  66. // PHP single-line arrays should not have trailing comma
  67. 'no_trailing_comma_in_singleline_array' => true,
  68. // Remove trailing commas in list function calls
  69. 'no_trailing_whitespace' => true,
  70. // Unused use statements must be removed
  71. 'no_unused_imports' => true,
  72. // Remove trailing whitespace at the end of blank lines
  73. 'no_whitespace_in_blank_line' => true,
  74. // All instances created with new keyword must be followed by braces
  75. 'new_with_braces' => true,
  76. // There should not be space before or after object T_OBJECT_OPERATOR ->
  77. 'object_operator_without_whitespace' => true,
  78. // Ordering use statements
  79. 'ordered_imports' => true,
  80. // All items of the given phpdoc tags must be aligned vertically
  81. // defaults to ['param', 'return', 'throws', 'type', 'var']
  82. // 'phpdoc_align' => true,
  83. // Docblocks should have the same indentation as the documented subject
  84. 'phpdoc_indent' => true,
  85. // Fix PHPDoc inline tags, make inheritdoc always inline
  86. 'phpdoc_inline_tag' => true,
  87. // @access annotations should be omitted from phpdocs
  88. 'phpdoc_no_access' => true,
  89. // @return void and @return null annotations should be omitted from phpdocs
  90. 'phpdoc_no_empty_return' => true,
  91. // @package and @subpackage annotations should be omitted from phpdocs
  92. 'phpdoc_no_package' => true,
  93. // Scalar types should always be written in the same form
  94. // int not integer, bool not boolean, float not real or double
  95. 'phpdoc_scalar' => true,
  96. // Annotations in phpdocs should be grouped together so that annotations of the same type immediately follow each other,
  97. // and annotations of a different type are separated by a single blank line
  98. 'phpdoc_separation' => true,
  99. // Phpdocs summary should end in either a full stop, exclamation mark, or question mark
  100. 'phpdoc_summary' => true,
  101. // Docblocks should only be used on structural elements
  102. 'phpdoc_to_comment' => true,
  103. // Phpdocs should start and end with content, excluding the very first and last line of the docblocks
  104. 'phpdoc_trim' => true,
  105. // @var and @type annotations should not contain the variable name
  106. 'phpdoc_var_without_name' => true,
  107. // Pre incrementation/decrementation should be used if possible
  108. 'pre_increment' => true,
  109. // A PHP file without end tag must always end with a single empty line feed
  110. 'single_blank_line_at_eof' => true,
  111. // There should be exactly one blank line before a namespace declaration
  112. 'single_blank_line_before_namespace' => true,
  113. // There MUST be one use keyword per declaration
  114. 'single_import_per_statement' => true,
  115. // Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block
  116. 'single_line_after_imports' => true,
  117. // Single-line comments and multi-line comments with only one line of actual content should use the // syntax
  118. 'single_line_comment_style' => true,
  119. // Convert double quotes to single quotes for simple strings
  120. 'single_quote' => true,
  121. // Replace all <> with !=
  122. 'standardize_not_equals' => true,
  123. // Standardize spaces around ternary operator
  124. 'ternary_operator_spaces' => true,
  125. // PHP multi-line arrays should have a trailing comma
  126. 'trailing_comma_in_multiline_array' => true,
  127. // Unary operators should be placed adjacent to their operands
  128. 'unary_operator_spaces' => true,
  129. // Visibility MUST be declared on all properties and methods;
  130. // abstract and final MUST be declared before the visibility;
  131. // static MUST be declared after the visibility
  132. 'visibility_required' => true,
  133. ];
  134. $finder = Finder::create();
  135. $finder->files()->in([
  136. 'src',
  137. ]);
  138. $config = Config::create()
  139. ->setRules($fixers)
  140. ->setFinder($finder)
  141. ->setUsingCache(true);
  142. return $config;