.php_cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /*
  3. * This document has been generated with
  4. * https://mlocati.github.io/php-cs-fixer-configurator/#version:2.16.1|configurator
  5. * you can change this configuration by importing this file.
  6. */
  7. return PhpCsFixer\Config::create()
  8. ->setRiskyAllowed(true)
  9. ->setRules([
  10. // Each line of multi-line DocComments must have an asterisk [PSR-5] and must be aligned with the first one.
  11. 'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
  12. // PHP arrays should be declared using the configured syntax.
  13. 'array_syntax' => ['syntax' => 'short'],
  14. // Binary operators should be surrounded by space as configured.
  15. 'binary_operator_spaces' => [
  16. 'default' => 'align_single_space_minimal',
  17. 'operators' => ['??' => 'align'],
  18. ],
  19. // There MUST be one blank line after the namespace declaration.
  20. 'blank_line_after_namespace' => true,
  21. // Each element of an array must be indented exactly once.
  22. 'array_indentation' => true,
  23. // Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.
  24. 'blank_line_after_opening_tag' => false,
  25. // The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented.
  26. 'braces' => ['allow_single_line_closure' => true, 'position_after_functions_and_oop_constructs' => 'next',
  27. // 'allow_single_line_functions' => true, // Awaiting PR merge...
  28. ],
  29. // A single space or none should be between cast and variable.
  30. 'cast_spaces' => true,
  31. // Class, trait and interface elements must be separated with one blank line.
  32. 'class_attributes_separation' => false,
  33. // Whitespace around the keywords of a class, trait or interfaces definition should be one space.
  34. 'class_definition' => ['single_item_single_line' => true, 'single_line' => true],
  35. // Using `isset($var) &&` multiple times should be done in one call.
  36. 'combine_consecutive_issets' => true,
  37. // Calling `unset` on multiple items should be done in one call.
  38. 'combine_consecutive_unsets' => true,
  39. // Remove extra spaces in a nullable typehint.
  40. 'compact_nullable_typehint' => true,
  41. // Concatenation should be spaced according configuration.
  42. 'concat_space' => ['spacing' => 'one'],
  43. // The PHP constants `true`, `false`, and `null` MUST be written using the correct casing.
  44. 'constant_case' => true,
  45. // Equal sign in declare statement should be surrounded by spaces or not following configuration.
  46. 'declare_equal_normalize' => ['space' => 'single'],
  47. // Replaces `dirname(__FILE__)` expression with equivalent `__DIR__` constant.
  48. 'dir_constant' => true,
  49. // PHP code MUST use only UTF-8 without BOM (remove BOM).
  50. 'encoding' => true,
  51. // Replace deprecated `ereg` regular expression functions with `preg`.
  52. 'ereg_to_preg' => true,
  53. // Escape implicit backslashes in strings and heredocs to ease the understanding of which are special chars interpreted by PHP and which not.
  54. 'escape_implicit_backslashes' => true,
  55. // Add curly braces to indirect variables to make them clear to understand. Requires PHP >= 7.0.
  56. 'explicit_indirect_variable' => true,
  57. // Converts implicit variables into explicit ones in double-quoted strings or heredoc syntax.
  58. 'explicit_string_variable' => true,
  59. // PHP code must use the long `<?php` tags or short-echo `<?=` tags and not other tag variations.
  60. 'full_opening_tag' => true,
  61. // Transforms imported FQCN parameters and return types in function arguments to short version.
  62. 'fully_qualified_strict_types' => true,
  63. // Spaces should be properly placed in a function declaration.
  64. 'function_declaration' => ['closure_function_spacing' => 'one'],
  65. // Ensure single space between function's argument and its typehint.
  66. 'function_typehint_space' => true,
  67. // Pre- or post-increment and decrement operators should be used if possible.
  68. 'increment_style' => true,
  69. // Code MUST use configured indentation type.
  70. 'indentation_type' => true,
  71. // All PHP files must use same line ending.
  72. 'line_ending' => true,
  73. // Use `&&` and `||` logical operators instead of `and` and `or`.
  74. 'logical_operators' => true,
  75. // PHP keywords MUST be in lower case.
  76. 'lowercase_keywords' => true,
  77. // Class static references `self`, `static` and `parent` MUST be in lower case.
  78. 'lowercase_static_reference' => true,
  79. // Magic constants should be referred to using the correct casing.
  80. 'magic_constant_casing' => true,
  81. // Magic method definitions and calls must be using the correct casing.
  82. 'magic_method_casing' => true,
  83. // Replaces `intval`, `floatval`, `doubleval`, `strval` and `boolval` function calls with according type casting operator.
  84. 'modernize_types_casting' => true,
  85. // DocBlocks must start with two asterisks, multiline comments must start with a single asterisk, after the opening slash. Both must end with a single asterisk before the closing slash.
  86. 'multiline_comment_opening_closing' => true,
  87. // Forbid multi-line whitespace before the closing semicolon or move the semicolon to the new line for chained calls.
  88. 'multiline_whitespace_before_semicolons' => true,
  89. // Add leading `\` before constant invocation of internal constant to speed up resolving. Constant name match is case-sensitive, except for `null`, `false` and `true`.
  90. 'native_constant_invocation' => false,
  91. // Function defined by PHP should be called using the correct casing.
  92. 'native_function_casing' => true,
  93. // Add leading `\` before function invocation to speed up resolving.
  94. 'native_function_invocation' => false,
  95. // Native type hints for functions should use the correct case.
  96. 'native_function_type_declaration_casing' => true,
  97. // There should be no empty lines after class opening brace.
  98. 'no_blank_lines_after_class_opening' => true,
  99. // There should not be blank lines between docblock and the documented element.
  100. 'no_blank_lines_after_phpdoc' => true,
  101. // There must be a comment when fall-through is intentional in a non-empty case body.
  102. 'no_break_comment' => true,
  103. // The closing `? >` tag MUST be omitted from files containing only PHP.
  104. 'no_closing_tag' => true,
  105. // There should not be any empty comments.
  106. 'no_empty_comment' => true,
  107. // There should not be empty PHPDoc blocks.
  108. 'no_empty_phpdoc' => true,
  109. // Remove useless semicolon statements.
  110. 'no_empty_statement' => true,
  111. // Removes extra blank lines and/or blank lines following configuration.
  112. 'no_extra_blank_lines' => true,
  113. // Remove leading slashes in `use` clauses.
  114. 'no_leading_import_slash' => true,
  115. // The namespace declaration line shouldn't contain leading whitespace.
  116. 'no_leading_namespace_whitespace' => true,
  117. // Either language construct `print` or `echo` should be used.
  118. 'no_mixed_echo_print' => true,
  119. // Operator `=>` should not be surrounded by multi-line whitespaces.
  120. 'no_multiline_whitespace_around_double_arrow' => true,
  121. // Properties MUST not be explicitly initialized with `null` except when they have a type declaration (PHP 7.4).
  122. 'no_null_property_initialization' => true,
  123. // Short cast `bool` using double exclamation mark should not be used.
  124. 'no_short_bool_cast' => true,
  125. // Replace short-echo `<?=` with long format `<?php echo` syntax.
  126. 'no_short_echo_tag' => true,
  127. // Single-line whitespace before closing semicolon are prohibited.
  128. 'no_singleline_whitespace_before_semicolons' => true,
  129. // When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis.
  130. 'no_spaces_after_function_name' => true,
  131. // There MUST NOT be spaces around offset braces.
  132. 'no_spaces_around_offset' => true,
  133. // There MUST NOT be a space after the opening parenthesis. There MUST NOT be a space before the closing parenthesis.
  134. 'no_spaces_inside_parenthesis' => true,
  135. // Replaces superfluous `elseif` with `if`.
  136. 'no_superfluous_elseif' => false,
  137. // Remove trailing commas in list function calls.
  138. 'no_trailing_comma_in_list_call' => true,
  139. // PHP single-line arrays should not have trailing comma.
  140. 'no_trailing_comma_in_singleline_array' => true,
  141. // Remove trailing whitespace at the end of non-blank lines.
  142. 'no_trailing_whitespace' => true,
  143. // There MUST be no trailing spaces inside comment or PHPDoc.
  144. 'no_trailing_whitespace_in_comment' => true,
  145. // Removes unneeded parentheses around control statements.
  146. 'no_unneeded_control_parentheses' => true,
  147. // Removes unneeded curly braces that are superfluous and aren't part of a control structure's body.
  148. 'no_unneeded_curly_braces' => true,
  149. // In function arguments there must not be arguments with default values before non-default ones.
  150. 'no_unreachable_default_argument_value' => true,
  151. // Variables must be set `null` instead of using `(unset)` casting.
  152. 'no_unset_cast' => false,
  153. // Properties should be set to `null` instead of using `unset`.
  154. 'no_unset_on_property' => true,
  155. // Unused `use` statements must be removed.
  156. 'no_unused_imports' => true,
  157. // There should not be useless `else` cases.
  158. 'no_useless_else' => false,
  159. // There should not be an empty `return` statement at the end of a function.
  160. 'no_useless_return' => true,
  161. // In array declaration, there MUST NOT be a whitespace before each comma.
  162. 'no_whitespace_before_comma_in_array' => true,
  163. // Remove trailing whitespace at the end of blank lines.
  164. 'no_whitespace_in_blank_line' => true,
  165. // Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.
  166. 'non_printable_character' => true,
  167. // Array index should always be written by using square braces.
  168. 'normalize_index_brace' => true,
  169. // There should not be space before or after object `T_OBJECT_OPERATOR` `->`.
  170. 'object_operator_without_whitespace' => true,
  171. // Ordering `use` statements.
  172. 'ordered_imports' => true,
  173. // Orders the elements of classes/interfaces/traits.
  174. 'ordered_class_elements' => false,
  175. // PHPUnit assertion method calls like `->assertSame(true, $foo)` should be written with dedicated method like `->assertTrue($foo)`.
  176. 'php_unit_construct' => true,
  177. // PHPUnit annotations should be a FQCNs including a root namespace.
  178. 'php_unit_fqcn_annotation' => true,
  179. // Enforce camel (or snake) case for PHPUnit test methods, following configuration.
  180. 'php_unit_method_casing' => true,
  181. // Usage of PHPUnit's mock e.g. `->will($this->returnValue(..))` must be replaced by its shorter equivalent such as `->willReturn(...)`.
  182. 'php_unit_mock_short_will_return' => true,
  183. // Order `@covers` annotation of PHPUnit tests.
  184. 'php_unit_ordered_covers' => true,
  185. // Changes the visibility of the `setUp()` and `tearDown()` functions of PHPUnit to `protected`, to match the PHPUnit TestCase.
  186. 'php_unit_set_up_tear_down_visibility' => true,
  187. // PHPUnit methods like `assertSame` should be used instead of `assertEquals`.
  188. 'php_unit_strict' => true,
  189. // Calls to `PHPUnit\Framework\TestCase` static methods must all be of the same type, either `$this->`, `self::` or `static::`.
  190. 'php_unit_test_case_static_method_calls' => true,
  191. // PHPDoc should contain `@param` for all params.
  192. 'phpdoc_add_missing_param_annotation' => true,
  193. // All items of the given phpdoc tags must be either left-aligned or (by default) aligned vertically.
  194. 'phpdoc_align' => true,
  195. // Docblocks should have the same indentation as the documented subject.
  196. 'phpdoc_indent' => true,
  197. // Fix PHPDoc inline tags, make `@inheritdoc` always inline.
  198. 'phpdoc_inline_tag' => true,
  199. // `@access` annotations should be omitted from PHPDoc.
  200. 'phpdoc_no_access' => true,
  201. // No alias PHPDoc tags should be used.
  202. 'phpdoc_no_alias_tag' => true,
  203. // Annotations in PHPDoc should be ordered so that `@param` annotations come first, then `@throws` annotations, then `@return` annotations.
  204. 'phpdoc_order' => true,
  205. // The type of `@return` annotations of methods returning a reference to itself must the configured one.
  206. 'phpdoc_return_self_reference' => true,
  207. // Scalar types should always be written in the same form. `int` not `integer`, `bool` not `boolean`, `float` not `real` or `double`.
  208. 'phpdoc_scalar' => true,
  209. // Annotations in PHPDoc should be grouped together so that annotations of the same type immediately follow each other, and annotations of a different type are separated by a single blank line.
  210. 'phpdoc_separation' => true,
  211. // Single line `@var` PHPDoc should have proper spacing.
  212. 'phpdoc_single_line_var_spacing' => false,
  213. // Removes extra blank lines after summary and after description in PHPDoc.
  214. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  215. // The correct case must be used for standard PHP types in PHPDoc.
  216. 'phpdoc_types' => true,
  217. // Sorts PHPDoc types.
  218. 'phpdoc_types_order' => true,
  219. // `@var` and `@type` annotations must have type and name in the correct order.
  220. 'phpdoc_var_annotation_correct_order' => true,
  221. // Class names should match the file name.
  222. 'psr4' => true,
  223. // There should be one or no space before colon, and one space after it in return type declarations, according to configuration.
  224. 'return_type_declaration' => true,
  225. // Inside class or interface element `self` should be preferred to the class name itself.
  226. 'self_accessor' => true,
  227. // Instructions must be terminated with a semicolon.
  228. 'semicolon_after_instruction' => true,
  229. // Cast shall be used, not `settype`.
  230. 'set_type_to_cast' => true,
  231. // Cast `(boolean)` and `(integer)` should be written as `(bool)` and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as `(string)`.
  232. 'short_scalar_cast' => true,
  233. // Converts explicit variables in double-quoted strings and heredoc syntax from simple to complex format (`${` to `{$`).
  234. 'simple_to_complex_string_variable' => true,
  235. // There should be exactly one blank line before a namespace declaration.
  236. 'single_blank_line_before_namespace' => true,
  237. // There MUST be one use keyword per declaration.
  238. 'single_import_per_statement' => true,
  239. // There MUST NOT be more than one property or constant declared per statement.
  240. 'single_class_element_per_statement' => true,
  241. // Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.
  242. 'single_line_after_imports' => true,
  243. // Single-line comments and multi-line comments with only one line of actual content should use the `//` syntax.
  244. 'single_line_comment_style' => true,
  245. // Convert double quotes to single quotes for simple strings.
  246. 'single_quote' => true,
  247. // Each trait `use` must be done as single statement.
  248. 'single_trait_insert_per_statement' => true,
  249. // Fix whitespace after a semicolon.
  250. 'space_after_semicolon' => true,
  251. // Increment and decrement operators should be used if possible.
  252. 'standardize_increment' => true,
  253. // Replace all `<>` with `!=`.
  254. 'standardize_not_equals' => true,
  255. // A case should be followed by a colon and not a semicolon.
  256. 'switch_case_semicolon_to_colon' => true,
  257. // Removes extra spaces between colon and case value.
  258. 'switch_case_space' => true,
  259. // Standardize spaces around ternary operator.
  260. 'ternary_operator_spaces' => true,
  261. // PHP multi-line arrays should have a trailing comma.
  262. 'trailing_comma_in_multiline_array' => true,
  263. // Unary operators should be placed adjacent to their operands.
  264. 'unary_operator_spaces' => true,
  265. // Visibility MUST be declared on all properties and methods; `abstract` and `final` MUST be declared before the visibility; `static` MUST be declared after the visibility.
  266. 'visibility_required' => true,
  267. // In array declaration, there MUST be a whitespace after each comma.
  268. 'whitespace_after_comma_in_array' => true,
  269. ])
  270. ->setFinder(PhpCsFixer\Finder::create()
  271. ->exclude('vendor')
  272. ->exclude('var')
  273. ->exclude('docker')
  274. ->exclude('src/Entity')
  275. ->notPath('src/Core/DB/DefaultSettings.php')
  276. ->in(__DIR__)
  277. );