.php-cs-fixer.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <?php
  2. declare(strict_types = 1);
  3. /*
  4. * This document has been generated with
  5. * https://mlocati.github.io/php-cs-fixer-configurator/#version:3.2.1|configurator
  6. * you can change this configuration by importing this file.
  7. */
  8. $config = new PhpCsFixer\Config();
  9. return $config
  10. ->setRiskyAllowed(true)
  11. ->setRules([
  12. // Each line of multi-line DocComments must have an asterisk [PSR-5] and must be aligned with the first one.
  13. 'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
  14. // Each element of an array must be indented exactly once.
  15. 'array_indentation' => true,
  16. // Converts simple usages of `array_push($x, $y);` to `$x[] = $y;`.
  17. 'array_push' => true,
  18. // PHP arrays should be declared using the configured syntax.
  19. 'array_syntax' => ['syntax' => 'short'],
  20. // Use the null coalescing assignment operator `??=` where possible.
  21. 'assign_null_coalescing_to_coalesce_equal' => true,
  22. // Binary operators should be surrounded by space as configured.
  23. 'binary_operator_spaces' => ['default' => 'align_single_space_minimal', 'operators' => ['??' => 'align']],
  24. // There MUST be one blank line after the namespace declaration.
  25. 'blank_line_after_namespace' => true,
  26. // Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.
  27. 'blank_line_after_opening_tag' => true,
  28. // The body of each structure MUST be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented.
  29. 'braces' => ['allow_single_line_anonymous_class_with_empty_body' => true, 'allow_single_line_closure' => true, 'position_after_functions_and_oop_constructs' => 'next'],
  30. // A single space or none should be between cast and variable.
  31. 'cast_spaces' => true,
  32. // Whitespace around the keywords of a class, trait or interfaces definition should be one space.
  33. 'class_definition' => ['single_item_single_line' => true, 'single_line' => true],
  34. // Using `isset($var) &&` multiple times should be done in one call.
  35. 'combine_consecutive_issets' => true,
  36. // Calling `unset` on multiple items should be done in one call.
  37. 'combine_consecutive_unsets' => true,
  38. // Replace multiple nested calls of `dirname` by only one call with second `$level` parameter. Requires PHP >= 7.0.
  39. 'combine_nested_dirname' => true,
  40. // Comments with annotation should be docblock when used on structural elements.
  41. 'comment_to_phpdoc' => false,
  42. // Remove extra spaces in a nullable typehint.
  43. 'compact_nullable_typehint' => true,
  44. // Concatenation should be spaced according configuration.
  45. 'concat_space' => ['spacing' => 'one'],
  46. // The PHP constants `true`, `false`, and `null` MUST be written using the correct casing.
  47. 'constant_case' => true,
  48. // Equal sign in declare statement should be surrounded by spaces or not following configuration.
  49. 'declare_equal_normalize' => ['space' => 'single'],
  50. // There must not be spaces around `declare` statement parentheses.
  51. 'declare_parentheses' => true,
  52. // Force strict types declaration in all files. Requires PHP >= 7.0.
  53. 'declare_strict_types' => true,
  54. // Replaces `dirname(__FILE__)` expression with equivalent `__DIR__` constant.
  55. 'dir_constant' => true,
  56. // Replaces short-echo `<?=` with long format `<?php echo`/`<?php print` syntax, or vice-versa.
  57. 'echo_tag_syntax' => true,
  58. // The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.
  59. 'elseif' => true,
  60. // Empty loop-body must be in configured style.
  61. 'empty_loop_body' => true,
  62. // Empty loop-condition must be in configured style.
  63. 'empty_loop_condition' => true,
  64. // PHP code MUST use only UTF-8 without BOM (remove BOM).
  65. 'encoding' => true,
  66. // Replace deprecated `ereg` regular expression functions with `preg`.
  67. 'ereg_to_preg' => true,
  68. // Escape implicit backslashes in strings and heredocs to ease the understanding of which are special chars interpreted by PHP and which not.
  69. 'escape_implicit_backslashes' => true,
  70. // Add curly braces to indirect variables to make them clear to understand. Requires PHP >= 7.0.
  71. 'explicit_indirect_variable' => true,
  72. // Converts implicit variables into explicit ones in double-quoted strings or heredoc syntax.
  73. 'explicit_string_variable' => true,
  74. // PHP code must use the long `<?php` tags or short-echo `<?=` tags and not other tag variations.
  75. 'full_opening_tag' => true,
  76. // Transforms imported FQCN parameters and return types in function arguments to short version.
  77. 'fully_qualified_strict_types' => true,
  78. // Spaces should be properly placed in a function declaration.
  79. 'function_declaration' => ['closure_function_spacing' => 'one'],
  80. // Ensure single space between function's argument and its typehint.
  81. 'function_typehint_space' => true,
  82. // Imports or fully qualifies global classes/functions/constants.
  83. 'global_namespace_import' => true,
  84. // Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.
  85. 'heredoc_indentation' => true,
  86. // Convert `heredoc` to `nowdoc` where possible.
  87. 'heredoc_to_nowdoc' => true,
  88. // Function `implode` must be called with 2 arguments in the documented order.
  89. 'implode_call' => true,
  90. // Pre- or post-increment and decrement operators should be used if possible.
  91. 'increment_style' => true,
  92. // Code MUST use configured indentation type.
  93. 'indentation_type' => true,
  94. // Lambda must not import variables it doesn't use.
  95. 'lambda_not_used_import' => true,
  96. // All PHP files must use same line ending.
  97. 'line_ending' => true,
  98. // Ensure there is no code on the same line as the PHP open tag.
  99. 'linebreak_after_opening_tag' => true,
  100. // List (`array` destructuring) assignment should be declared using the configured syntax. Requires PHP >= 7.1.
  101. 'list_syntax' => ['syntax' => 'short'],
  102. // Use `&&` and `||` logical operators instead of `and` and `or`.
  103. 'logical_operators' => true,
  104. // Cast should be written in lower case.
  105. 'lowercase_cast' => true,
  106. // PHP keywords MUST be in lower case.
  107. 'lowercase_keywords' => true,
  108. // Class static references `self`, `static` and `parent` MUST be in lower case.
  109. 'lowercase_static_reference' => true,
  110. // Magic constants should be referred to using the correct casing.
  111. 'magic_constant_casing' => true,
  112. // Magic method definitions and calls must be using the correct casing.
  113. 'magic_method_casing' => true,
  114. // Replace non multibyte-safe functions with corresponding mb function.
  115. 'mb_str_functions' => true,
  116. // In method arguments and method call, there MUST NOT be a space before each comma and there MUST be one space after each comma. Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line.
  117. 'method_argument_space' => ['after_heredoc' => true, 'on_multiline' => 'ensure_fully_multiline'],
  118. // Method chaining MUST be properly indented. Method chaining with different levels of indentation is not supported.
  119. 'method_chaining_indentation' => true,
  120. // Replace `strpos()` calls with `str_starts_with()` or `str_contains()` if possible.
  121. 'modernize_strpos' => true,
  122. // Replaces `intval`, `floatval`, `doubleval`, `strval` and `boolval` function calls with according type casting operator.
  123. 'modernize_types_casting' => true,
  124. // 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.
  125. 'multiline_comment_opening_closing' => true,
  126. // Forbid multi-line whitespace before the closing semicolon or move the semicolon to the new line for chained calls.
  127. 'multiline_whitespace_before_semicolons' => true,
  128. // Add leading `\` before constant invocation of internal constant to speed up resolving. Constant name match is case-sensitive, except for `null`, `false` and `true`.
  129. 'native_constant_invocation' => true,
  130. // Function defined by PHP should be called using the correct casing.
  131. 'native_function_casing' => true,
  132. // Add leading `\` before function invocation to speed up resolving.
  133. 'native_function_invocation' => true,
  134. // Native type hints for functions should use the correct case.
  135. 'native_function_type_declaration_casing' => true,
  136. // Master language constructs shall be used instead of aliases.
  137. 'no_alias_language_construct_call' => true,
  138. // Replace control structure alternative syntax to use braces.
  139. 'no_alternative_syntax' => true,
  140. // There should be no empty lines after class opening brace.
  141. 'no_blank_lines_after_class_opening' => true,
  142. // There should not be blank lines between docblock and the documented element.
  143. 'no_blank_lines_after_phpdoc' => true,
  144. // There must be a comment when fall-through is intentional in a non-empty case body.
  145. 'no_break_comment' => true,
  146. // The closing `? >` tag MUST be omitted from files containing only PHP.
  147. 'no_closing_tag' => true,
  148. // There should not be any empty comments.
  149. 'no_empty_comment' => true,
  150. // There should not be empty PHPDoc blocks.
  151. 'no_empty_phpdoc' => true,
  152. // Remove useless (semicolon) statements.
  153. 'no_empty_statement' => true,
  154. // Removes extra blank lines and/or blank lines following configuration.
  155. 'no_extra_blank_lines' => true,
  156. // Remove leading slashes in `use` clauses.
  157. 'no_leading_import_slash' => true,
  158. // The namespace declaration line shouldn't contain leading whitespace.
  159. 'no_leading_namespace_whitespace' => true,
  160. // Either language construct `print` or `echo` should be used.
  161. 'no_mixed_echo_print' => true,
  162. // Operator `=>` should not be surrounded by multi-line whitespaces.
  163. 'no_multiline_whitespace_around_double_arrow' => true,
  164. // Properties MUST not be explicitly initialized with `null` except when they have a type declaration (PHP 7.4).
  165. 'no_null_property_initialization' => true,
  166. // Short cast `bool` using double exclamation mark should not be used.
  167. 'no_short_bool_cast' => true,
  168. // Single-line whitespace before closing semicolon are prohibited.
  169. 'no_singleline_whitespace_before_semicolons' => true,
  170. // There must be no space around double colons (also called Scope Resolution Operator or Paamayim Nekudotayim).
  171. 'no_space_around_double_colon' => true,
  172. // When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis.
  173. 'no_spaces_after_function_name' => true,
  174. // There MUST NOT be spaces around offset braces.
  175. 'no_spaces_around_offset' => true,
  176. // There MUST NOT be a space after the opening parenthesis. There MUST NOT be a space before the closing parenthesis.
  177. 'no_spaces_inside_parenthesis' => true,
  178. // Removes `@param`, `@return` and `@var` tags that don't provide any useful information.
  179. 'no_superfluous_phpdoc_tags' => true,
  180. // Remove trailing commas in list function calls.
  181. 'no_trailing_comma_in_list_call' => true,
  182. // PHP single-line arrays should not have trailing comma.
  183. 'no_trailing_comma_in_singleline_array' => true,
  184. // Remove trailing whitespace at the end of non-blank lines.
  185. 'no_trailing_whitespace' => true,
  186. // There MUST be no trailing spaces inside comment or PHPDoc.
  187. 'no_trailing_whitespace_in_comment' => true,
  188. // Removes unneeded parentheses around control statements.
  189. 'no_unneeded_control_parentheses' => true,
  190. // Removes unneeded curly braces that are superfluous and aren't part of a control structure's body.
  191. 'no_unneeded_curly_braces' => true,
  192. // In function arguments there must not be arguments with default values before non-default ones.
  193. 'no_unreachable_default_argument_value' => true,
  194. // Variables must be set `null` instead of using `(unset)` casting.
  195. 'no_unset_cast' => true,
  196. // Unused `use` statements must be removed.
  197. 'no_unused_imports' => true,
  198. // There should not be an empty `return` statement at the end of a function.
  199. 'no_useless_return' => true,
  200. // In array declaration, there MUST NOT be a whitespace before each comma.
  201. 'no_whitespace_before_comma_in_array' => true,
  202. // Remove trailing whitespace at the end of blank lines.
  203. 'no_whitespace_in_blank_line' => true,
  204. // Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.
  205. 'non_printable_character' => true,
  206. // Array index should always be written by using square braces.
  207. 'normalize_index_brace' => true,
  208. // Adds or removes `?` before type declarations for parameters with a default `null` value.
  209. 'nullable_type_declaration_for_default_null_value' => true,
  210. // There should not be space before or after object operators `->` and `?->`.
  211. 'object_operator_without_whitespace' => true,
  212. // Operators - when multiline - must always be at the beginning or at the end of the line.
  213. 'operator_linebreak' => true,
  214. // Ordering `use` statements.
  215. 'ordered_imports' => true,
  216. // PHPUnit assertion method calls like `->assertSame(true, $foo)` should be written with dedicated method like `->assertTrue($foo)`.
  217. 'php_unit_construct' => true,
  218. // PHPUnit assertions like `assertInternalType`, `assertFileExists`, should be used over `assertTrue`.
  219. 'php_unit_dedicate_assert' => true,
  220. // PHPUnit assertions like `assertIsArray` should be used over `assertInternalType`.
  221. 'php_unit_dedicate_assert_internal_type' => true,
  222. // Usages of `->setExpectedException*` methods MUST be replaced by `->expectException*` methods.
  223. 'php_unit_expectation' => true,
  224. // PHPUnit annotations should be a FQCNs including a root namespace.
  225. 'php_unit_fqcn_annotation' => true,
  226. // Enforce camel (or snake) case for PHPUnit test methods, following configuration.
  227. 'php_unit_method_casing' => true,
  228. // Usage of PHPUnit's mock e.g. `->will($this->returnValue(..))` must be replaced by its shorter equivalent such as `->willReturn(...)`.
  229. 'php_unit_mock_short_will_return' => true,
  230. // PHPUnit classes MUST be used in namespaced version, e.g. `\PHPUnit\Framework\TestCase` instead of `\PHPUnit_Framework_TestCase`.
  231. 'php_unit_namespaced' => true,
  232. // Usages of `@expectedException*` annotations MUST be replaced by `->setExpectedException*` methods.
  233. 'php_unit_no_expectation_annotation' => true,
  234. // Changes the visibility of the `setUp()` and `tearDown()` functions of PHPUnit to `protected`, to match the PHPUnit TestCase.
  235. 'php_unit_set_up_tear_down_visibility' => true,
  236. // PHPUnit methods like `assertSame` should be used instead of `assertEquals`.
  237. 'php_unit_strict' => true,
  238. // Calls to `PHPUnit\Framework\TestCase` static methods must all be of the same type, either `$this->`, `self::` or `static::`.
  239. 'php_unit_test_case_static_method_calls' => true,
  240. // PHPDoc should contain `@param` for all params.
  241. 'phpdoc_add_missing_param_annotation' => true,
  242. // All items of the given phpdoc tags must be either left-aligned or (by default) aligned vertically.
  243. 'phpdoc_align' => true,
  244. // PHPDoc annotation descriptions should not be a sentence.
  245. 'phpdoc_annotation_without_dot' => true,
  246. // Docblocks should have the same indentation as the documented subject.
  247. 'phpdoc_indent' => true,
  248. // Fixes PHPDoc inline tags.
  249. 'phpdoc_inline_tag_normalizer' => true,
  250. // Changes doc blocks from single to multi line, or reversed. Works for class constants, properties and methods only.
  251. 'phpdoc_line_span' => true,
  252. // `@access` annotations should be omitted from PHPDoc.
  253. 'phpdoc_no_access' => true,
  254. // No alias PHPDoc tags should be used.
  255. 'phpdoc_no_alias_tag' => true,
  256. // `@return void` and `@return null` annotations should be omitted from PHPDoc.
  257. 'phpdoc_no_empty_return' => true,
  258. // Classy that does not inherit must not have `@inheritdoc` tags.
  259. 'phpdoc_no_useless_inheritdoc' => true,
  260. // Annotations in PHPDoc should be ordered so that `@param` annotations come first, then `@throws` annotations, then `@return` annotations.
  261. 'phpdoc_order' => true,
  262. // Order phpdoc tags by value.
  263. 'phpdoc_order_by_value' => ['annotations' => ['covers', 'throws']],
  264. // The type of `@return` annotations of methods returning a reference to itself must the configured one.
  265. 'phpdoc_return_self_reference' => true,
  266. // Scalar types should always be written in the same form. `int` not `integer`, `bool` not `boolean`, `float` not `real` or `double`.
  267. 'phpdoc_scalar' => true,
  268. // 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.
  269. 'phpdoc_separation' => true,
  270. // Single line `@var` PHPDoc should have proper spacing.
  271. 'phpdoc_single_line_var_spacing' => true,
  272. // Fixes casing of PHPDoc tags.
  273. 'phpdoc_tag_casing' => true,
  274. // Would be neat, but breaks cases where the parents don't have annotations
  275. // // EXPERIMENTAL: Takes `@param` annotations of non-mixed types and adjusts accordingly the function signature. Requires PHP >= 7.0.
  276. // 'phpdoc_to_param_type' => true,
  277. // // EXPERIMENTAL: Takes `@var` annotation of non-mixed types and adjusts accordingly the property signature. Requires PHP >= 7.4.
  278. // 'phpdoc_to_property_type' => true,
  279. // // EXPERIMENTAL: Takes `@return` annotation of non-mixed types and adjusts accordingly the function signature. Requires PHP >= 7.0.
  280. // 'phpdoc_to_return_type' => true,
  281. // PHPDoc should start and end with content, excluding the very first and last line of the docblocks.
  282. 'phpdoc_trim' => true,
  283. // Removes extra blank lines after summary and after description in PHPDoc.
  284. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  285. // The correct case must be used for standard PHP types in PHPDoc.
  286. 'phpdoc_types' => true,
  287. // Sorts PHPDoc types.
  288. 'phpdoc_types_order' => true,
  289. // `@var` and `@type` annotations must have type and name in the correct order.
  290. 'phpdoc_var_annotation_correct_order' => true,
  291. // Converts `pow` to the `**` operator.
  292. 'pow_to_exponentiation' => true,
  293. // Replaces `rand`, `srand`, `getrandmax` functions calls with their `mt_*` analogs or `random_int`.
  294. 'random_api_migration' => true,
  295. // Callables must be called without using `call_user_func*` when possible.
  296. 'regular_callable_call' => true,
  297. // Local, dynamic and directly referenced variables should not be assigned and directly returned by a function or method.
  298. 'return_assignment' => true,
  299. // There should be one or no space before colon, and one space after it in return type declarations, according to configuration.
  300. 'return_type_declaration' => true,
  301. // Inside class or interface element `self` should be preferred to the class name itself.
  302. 'self_accessor' => true,
  303. // Instructions must be terminated with a semicolon.
  304. 'semicolon_after_instruction' => true,
  305. // Cast shall be used, not `settype`.
  306. 'set_type_to_cast' => true,
  307. // Cast `(boolean)` and `(integer)` should be written as `(bool)` and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as `(string)`.
  308. 'short_scalar_cast' => true,
  309. // Converts explicit variables in double-quoted strings and heredoc syntax from simple to complex format (`${` to `{$`).
  310. 'simple_to_complex_string_variable' => true,
  311. // Simplify `if` control structures that return the boolean result of their condition.
  312. 'simplified_if_return' => true,
  313. // A return statement wishing to return `void` should not return `null`.
  314. 'simplified_null_return' => true,
  315. // A PHP file without end tag must always end with a single empty line feed.
  316. 'single_blank_line_at_eof' => true,
  317. // There should be exactly one blank line before a namespace declaration.
  318. 'single_blank_line_before_namespace' => true,
  319. // There MUST NOT be more than one property or constant declared per statement.
  320. 'single_class_element_per_statement' => true,
  321. // There MUST be one use keyword per declaration.
  322. 'single_import_per_statement' => true,
  323. // Each namespace use MUST go on its own line and there MUST be one blank line after the use statements block.
  324. 'single_line_after_imports' => true,
  325. // Single-line comments and multi-line comments with only one line of actual content should use the `//` syntax.
  326. 'single_line_comment_style' => true,
  327. // Convert double quotes to single quotes for simple strings.
  328. 'single_quote' => true,
  329. // Ensures a single space after language constructs.
  330. 'single_space_after_construct' => true,
  331. // Each trait `use` must be done as single statement.
  332. 'single_trait_insert_per_statement' => true,
  333. // Fix whitespace after a semicolon.
  334. 'space_after_semicolon' => true,
  335. // Increment and decrement operators should be used if possible.
  336. 'standardize_increment' => true,
  337. // Replace all `<>` with `!=`.
  338. 'standardize_not_equals' => true,
  339. // String tests for empty must be done against `''`, not with `strlen`.
  340. 'string_length_to_empty' => true,
  341. // A case should be followed by a colon and not a semicolon.
  342. 'switch_case_semicolon_to_colon' => true,
  343. // Removes extra spaces between colon and case value.
  344. 'switch_case_space' => true,
  345. // Switch case must not be ended with `continue` but with `break`.
  346. 'switch_continue_to_break' => true,
  347. // Standardize spaces around ternary operator.
  348. 'ternary_operator_spaces' => true,
  349. // Use the Elvis operator `?:` where possible.
  350. 'ternary_to_elvis_operator' => true,
  351. // Use `null` coalescing operator `??` where possible. Requires PHP >= 7.0.
  352. 'ternary_to_null_coalescing' => true,
  353. // Multi-line arrays, arguments list and parameters list must have a trailing comma.
  354. 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'arrays', 'parameters']],
  355. // Arrays should be formatted like function/method arguments, without leading or trailing single line space.
  356. 'trim_array_spaces' => true,
  357. // A single space or none should be around union type operator.
  358. 'types_spaces' => true,
  359. // Unary operators should be placed adjacent to their operands.
  360. 'unary_operator_spaces' => true,
  361. // Anonymous functions with one-liner return statement must use arrow functions.
  362. 'use_arrow_functions' => true,
  363. // 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.
  364. 'visibility_required' => true,
  365. // In array declaration, there MUST be a whitespace after each comma.
  366. 'whitespace_after_comma_in_array' => true,
  367. ])
  368. ->setFinder(
  369. PhpCsFixer\Finder::create()
  370. ->exclude('vendor')
  371. ->exclude('var')
  372. ->exclude('docker')
  373. ->exclude('src/Entity')
  374. ->notPath('src/Core/DB/DefaultSettings.php')
  375. ->in(__DIR__),
  376. );