.php_cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509
  1. <?php
  2. /**
  3. * PHP Code Style Fixer (config created for version 2.16.3 (Yellow Bird)).
  4. *
  5. * Use one of the following console commands to just see the
  6. * changes that will be made.
  7. * - `php-cs-fixer fix --config='.php_cs' --diff-format udiff --dry-run`
  8. * - `php '.php_cs'`
  9. *
  10. * Use one of the following console commands to fix PHP code:
  11. * - `php-cs-fixer fix --config='.php_cs' --diff-format udiff`
  12. * - `php '.php_cs' --force`
  13. *
  14. * @see https://cs.symfony.com/
  15. */
  16. $rules = [
  17. /*
  18. * Each line of multi-line DocComments must have an asterisk [PSR-5]
  19. * and must be aligned with the first one.
  20. */
  21. 'align_multiline_comment' => true,
  22. // Each element of an array must be indented exactly once.
  23. 'array_indentation' => true,
  24. // PHP arrays should be declared using the configured syntax.
  25. 'array_syntax' => [
  26. 'syntax' => 'short',
  27. ],
  28. /*
  29. * Converts backtick operators to `shell_exec` calls.
  30. *
  31. * Conversion is done only when it is non risky, so when special
  32. * chars like single-quotes, double-quotes and backticks are not
  33. * used inside the command.
  34. */
  35. 'backtick_to_shell_exec' => true,
  36. // Binary operators should be surrounded by space as configured.
  37. 'binary_operator_spaces' => true,
  38. // There MUST be one blank line after the namespace declaration.
  39. 'blank_line_after_namespace' => true,
  40. /*
  41. * Ensure there is no code on the same line as the PHP open tag and
  42. * it is followed by a blank line.
  43. */
  44. 'blank_line_after_opening_tag' => true,
  45. // An empty line feed must precede any configured statement.
  46. 'blank_line_before_statement' => [
  47. 'statements' => [
  48. 'continue',
  49. 'declare',
  50. 'return',
  51. 'throw',
  52. 'try',
  53. 'case',
  54. 'die',
  55. 'exit',
  56. 'do',
  57. 'foreach',
  58. 'goto',
  59. 'if',
  60. 'while',
  61. ],
  62. ],
  63. /*
  64. * The body of each structure MUST be enclosed by braces. Braces
  65. * should be properly placed. Body of braces should be properly
  66. * indented.
  67. */
  68. 'braces' => [
  69. 'allow_single_line_closure' => true,
  70. ],
  71. // A single space or none should be between cast and variable.
  72. 'cast_spaces' => true,
  73. /*
  74. * Class, trait and interface elements must be separated with one
  75. * blank line.
  76. */
  77. 'class_attributes_separation' => true,
  78. /*
  79. * Whitespace around the keywords of a class, trait or interfaces
  80. * definition should be one space.
  81. */
  82. 'class_definition' => [
  83. 'single_item_single_line' => true,
  84. ],
  85. // Converts `::class` keywords to FQCN strings.
  86. 'class_keyword_remove' => false,
  87. // Using `isset($var) &&` multiple times should be done in one call.
  88. 'combine_consecutive_issets' => true,
  89. // Calling `unset` on multiple items should be done in one call.
  90. 'combine_consecutive_unsets' => true,
  91. /*
  92. * Replace multiple nested calls of `dirname` by only one call with
  93. * second `$level` parameter. Requires PHP >= 7.0.
  94. *
  95. * Risky!
  96. * Risky when the function `dirname` is overridden.
  97. */
  98. 'combine_nested_dirname' => false,
  99. /*
  100. * Comments with annotation should be docblock when used on
  101. * structural elements.
  102. *
  103. * Risky!
  104. * Risky as new docblocks might mean more, e.g. a Doctrine entity
  105. * might have a new column in database.
  106. */
  107. 'comment_to_phpdoc' => [
  108. 'ignored_tags' => [
  109. 'noinspection',
  110. ],
  111. ],
  112. /*
  113. * Remove extra spaces in a nullable typehint.
  114. *
  115. * Rule is applied only in a PHP 7.1+ environment.
  116. */
  117. 'compact_nullable_typehint' => false,
  118. // Concatenation should be spaced according configuration.
  119. 'concat_space' => [
  120. 'spacing' => 'one',
  121. ],
  122. /*
  123. * The PHP constants `true`, `false`, and `null` MUST be written
  124. * using the correct casing.
  125. */
  126. 'constant_case' => true,
  127. /*
  128. * Class `DateTimeImmutable` should be used instead of `DateTime`.
  129. *
  130. * Risky!
  131. * Risky when the code relies on modifying `DateTime` objects or if
  132. * any of the `date_create*` functions are overridden.
  133. */
  134. 'date_time_immutable' => true,
  135. /*
  136. * Equal sign in declare statement should be surrounded by spaces or
  137. * not following configuration.
  138. */
  139. 'declare_equal_normalize' => true,
  140. /*
  141. * Force strict types declaration in all files. Requires PHP >= 7.0.
  142. *
  143. * Risky!
  144. * Forcing strict types will stop non strict code from working.
  145. */
  146. 'declare_strict_types' => false,
  147. /*
  148. * Replaces `dirname(__FILE__)` expression with equivalent `__DIR__`
  149. * constant.
  150. *
  151. * Risky!
  152. * Risky when the function `dirname` is overridden.
  153. */
  154. 'dir_constant' => true,
  155. /*
  156. * Doctrine annotations must use configured operator for assignment
  157. * in arrays.
  158. */
  159. 'doctrine_annotation_array_assignment' => true,
  160. /*
  161. * Doctrine annotations without arguments must use the configured
  162. * syntax.
  163. */
  164. 'doctrine_annotation_braces' => true,
  165. // Doctrine annotations must be indented with four spaces.
  166. 'doctrine_annotation_indentation' => true,
  167. /*
  168. * Fixes spaces in Doctrine annotations.
  169. *
  170. * There must not be any space around parentheses; commas must be
  171. * preceded by no space and followed by one space; there must be no
  172. * space around named arguments assignment operator; there must be
  173. * one space around array assignment operator.
  174. */
  175. 'doctrine_annotation_spaces' => true,
  176. /*
  177. * The keyword `elseif` should be used instead of `else if` so that
  178. * all control keywords look like single words.
  179. */
  180. 'elseif' => true,
  181. // PHP code MUST use only UTF-8 without BOM (remove BOM).
  182. 'encoding' => true,
  183. /*
  184. * Replace deprecated `ereg` regular expression functions with
  185. * `preg`.
  186. *
  187. * Risky!
  188. * Risky if the `ereg` function is overridden.
  189. */
  190. 'ereg_to_preg' => true,
  191. /*
  192. * Error control operator should be added to deprecation notices
  193. * and/or removed from other cases.
  194. *
  195. * Risky!
  196. * Risky because adding/removing `@` might cause changes to code
  197. * behaviour or if `trigger_error` function is overridden.
  198. */
  199. 'error_suppression' => [
  200. 'mute_deprecation_error' => true,
  201. 'noise_remaining_usages' => true,
  202. 'noise_remaining_usages_exclude' => [
  203. 'fclose',
  204. 'fopen',
  205. 'gzinflate',
  206. 'iconv',
  207. 'mime_content_type',
  208. 'rename',
  209. 'unlink',
  210. ],
  211. ],
  212. /*
  213. * Escape implicit backslashes in strings and heredocs to ease the
  214. * understanding of which are special chars interpreted by PHP and
  215. * which not.
  216. *
  217. * In PHP double-quoted strings and heredocs some chars like `n`,
  218. * `$` or `u` have special meanings if preceded by a backslash (and
  219. * some are special only if followed by other special chars), while
  220. * a backslash preceding other chars are interpreted like a plain
  221. * backslash. The precise list of those special chars is hard to
  222. * remember and to identify quickly: this fixer escapes backslashes
  223. * that do not start a special interpretation with the char after
  224. * them.
  225. * It is possible to fix also single-quoted strings: in this case
  226. * there is no special chars apart from single-quote and backslash
  227. * itself, so the fixer simply ensure that all backslashes are
  228. * escaped. Both single and double backslashes are allowed in
  229. * single-quoted strings, so the purpose in this context is mainly
  230. * to have a uniformed way to have them written all over the
  231. * codebase.
  232. */
  233. 'escape_implicit_backslashes' => true,
  234. /*
  235. * Add curly braces to indirect variables to make them clear to
  236. * understand. Requires PHP >= 7.0.
  237. */
  238. 'explicit_indirect_variable' => false,
  239. /*
  240. * Converts implicit variables into explicit ones in double-quoted
  241. * strings or heredoc syntax.
  242. *
  243. * The reasoning behind this rule is the following:
  244. * - When there are two valid ways of doing the same thing, using
  245. * both is confusing, there should be a coding standard to follow
  246. * - PHP manual marks `"$var"` syntax as implicit and `"${var}"`
  247. * syntax as explicit: explicit code should always be preferred
  248. * - Explicit syntax allows word concatenation inside strings, e.g.
  249. * `"${var}IsAVar"`, implicit doesn't
  250. * - Explicit syntax is easier to detect for IDE/editors and
  251. * therefore has colors/highlight with higher contrast, which is
  252. * easier to read
  253. * Backtick operator is skipped because it is harder to handle; you
  254. * can use `backtick_to_shell_exec` fixer to normalize backticks to
  255. * strings
  256. */
  257. 'explicit_string_variable' => true,
  258. /*
  259. * All classes must be final, except abstract ones and Doctrine
  260. * entities.
  261. *
  262. * No exception and no configuration are intentional. Beside
  263. * Doctrine entities and of course abstract classes, there is no
  264. * single reason not to declare all classes final. If you want to
  265. * subclass a class, mark the parent class as abstract and create
  266. * two child classes, one empty if necessary: you'll gain much more
  267. * fine grained type-hinting. If you need to mock a standalone
  268. * class, create an interface, or maybe it's a value-object that
  269. * shouldn't be mocked at all. If you need to extend a standalone
  270. * class, create an interface and use the Composite pattern. If you
  271. * aren't ready yet for serious OOP, go with
  272. * FinalInternalClassFixer, it's fine.
  273. *
  274. * Risky!
  275. * Risky when subclassing non-abstract classes.
  276. */
  277. 'final_class' => false,
  278. /*
  279. * Internal classes should be `final`.
  280. *
  281. * Risky!
  282. * Changing classes to `final` might cause code execution to break.
  283. */
  284. 'final_internal_class' => false,
  285. /*
  286. * All `public` methods of `abstract` classes should be `final`.
  287. *
  288. * Enforce API encapsulation in an inheritance architecture. If you
  289. * want to override a method, use the Template method pattern.
  290. *
  291. * Risky!
  292. * Risky when overriding `public` methods of `abstract` classes.
  293. */
  294. 'final_public_method_for_abstract_class' => false,
  295. // Converts `static` access to `self` access in `final` classes.
  296. 'final_static_access' => true,
  297. /*
  298. * Order the flags in `fopen` calls, `b` and `t` must be last.
  299. *
  300. * Risky!
  301. * Risky when the function `fopen` is overridden.
  302. */
  303. 'fopen_flag_order' => true,
  304. /*
  305. * The flags in `fopen` calls must omit `t`, and `b` must be omitted
  306. * or included consistently.
  307. *
  308. * Risky!
  309. * Risky when the function `fopen` is overridden.
  310. */
  311. 'fopen_flags' => [
  312. 'b_mode' => true,
  313. ],
  314. /*
  315. * PHP code must use the long `<?php` tags or short-echo `<?=` tags
  316. * and not other tag variations.
  317. */
  318. 'full_opening_tag' => true,
  319. /*
  320. * Transforms imported FQCN parameters and return types in function
  321. * arguments to short version.
  322. */
  323. 'fully_qualified_strict_types' => true,
  324. // Spaces should be properly placed in a function declaration.
  325. 'function_declaration' => true,
  326. /*
  327. * Replace core functions calls returning constants with the
  328. * constants.
  329. *
  330. * Risky!
  331. * Risky when any of the configured functions to replace are
  332. * overridden.
  333. */
  334. 'function_to_constant' => [
  335. 'functions' => [
  336. 'get_class',
  337. 'php_sapi_name',
  338. 'phpversion',
  339. 'pi',
  340. 'get_called_class',
  341. ],
  342. ],
  343. // Ensure single space between function's argument and its typehint.
  344. 'function_typehint_space' => true,
  345. // Configured annotations should be omitted from PHPDoc.
  346. 'general_phpdoc_annotation_remove' => true,
  347. // Imports or fully qualifies global classes/functions/constants.
  348. 'global_namespace_import' => [
  349. 'import_constants' => false,
  350. 'import_functions' => false,
  351. 'import_classes' => false,
  352. ],
  353. // Add, replace or remove header comment.
  354. 'header_comment' => false,
  355. /*
  356. * Heredoc/nowdoc content must be properly indented. Requires PHP >=
  357. * 7.3.
  358. */
  359. 'heredoc_indentation' => false,
  360. // Convert `heredoc` to `nowdoc` where possible.
  361. 'heredoc_to_nowdoc' => true,
  362. /*
  363. * Function `implode` must be called with 2 arguments in the
  364. * documented order.
  365. *
  366. * Risky!
  367. * Risky when the function `implode` is overridden.
  368. */
  369. 'implode_call' => true,
  370. /*
  371. * Include/Require and file path should be divided with a single
  372. * space. File path should not be placed under brackets.
  373. */
  374. 'include' => true,
  375. /*
  376. * Pre- or post-increment and decrement operators should be used if
  377. * possible.
  378. */
  379. 'increment_style' => false,
  380. // Code MUST use configured indentation type.
  381. 'indentation_type' => true,
  382. /*
  383. * Replaces `is_null($var)` expression with `null === $var`.
  384. *
  385. * Risky!
  386. * Risky when the function `is_null` is overridden.
  387. */
  388. 'is_null' => true,
  389. // All PHP files must use same line ending.
  390. 'line_ending' => true,
  391. // Ensure there is no code on the same line as the PHP open tag.
  392. 'linebreak_after_opening_tag' => true,
  393. /*
  394. * List (`array` destructuring) assignment should be declared using
  395. * the configured syntax. Requires PHP >= 7.1.
  396. */
  397. 'list_syntax' => false,
  398. /*
  399. * Use `&&` and `||` logical operators instead of `and` and `or`.
  400. *
  401. * Risky!
  402. * Risky, because you must double-check if using and/or with lower
  403. * precedence was intentional.
  404. */
  405. 'logical_operators' => true,
  406. // Cast should be written in lower case.
  407. 'lowercase_cast' => true,
  408. // PHP keywords MUST be in lower case.
  409. 'lowercase_keywords' => true,
  410. /*
  411. * Class static references `self`, `static` and `parent` MUST be in
  412. * lower case.
  413. */
  414. 'lowercase_static_reference' => true,
  415. // Magic constants should be referred to using the correct casing.
  416. 'magic_constant_casing' => true,
  417. /*
  418. * Magic method definitions and calls must be using the correct
  419. * casing.
  420. */
  421. 'magic_method_casing' => true,
  422. /*
  423. * Replace non multibyte-safe functions with corresponding mb
  424. * function.
  425. *
  426. * Risky!
  427. * Risky when any of the functions are overridden.
  428. */
  429. 'mb_str_functions' => false,
  430. /*
  431. * In method arguments and method call, there MUST NOT be a space
  432. * before each comma and there MUST be one space after each comma.
  433. * Argument lists MAY be split across multiple lines, where each
  434. * subsequent line is indented once. When doing so, the first item
  435. * in the list MUST be on the next line, and there MUST be only one
  436. * argument per line.
  437. */
  438. 'method_argument_space' => [
  439. 'on_multiline' => 'ensure_fully_multiline',
  440. ],
  441. /*
  442. * Method chaining MUST be properly indented. Method chaining with
  443. * different levels of indentation is not supported.
  444. */
  445. 'method_chaining_indentation' => true,
  446. /*
  447. * Replaces `intval`, `floatval`, `doubleval`, `strval` and
  448. * `boolval` function calls with according type casting operator.
  449. *
  450. * Risky!
  451. * Risky if any of the functions `intval`, `floatval`, `doubleval`,
  452. * `strval` or `boolval` are overridden.
  453. */
  454. 'modernize_types_casting' => true,
  455. /*
  456. * DocBlocks must start with two asterisks, multiline comments must
  457. * start with a single asterisk, after the opening slash. Both must
  458. * end with a single asterisk before the closing slash.
  459. */
  460. 'multiline_comment_opening_closing' => true,
  461. /*
  462. * Forbid multi-line whitespace before the closing semicolon or move
  463. * the semicolon to the new line for chained calls.
  464. */
  465. 'multiline_whitespace_before_semicolons' => [
  466. 'strategy' => 'new_line_for_chained_calls',
  467. ],
  468. /*
  469. * Add leading `\` before constant invocation of internal constant
  470. * to speed up resolving. Constant name match is case-sensitive,
  471. * except for `null`, `false` and `true`.
  472. *
  473. * Risky!
  474. * Risky when any of the constants are namespaced or overridden.
  475. */
  476. 'native_constant_invocation' => true,
  477. /*
  478. * Function defined by PHP should be called using the correct
  479. * casing.
  480. */
  481. 'native_function_casing' => true,
  482. /*
  483. * Add leading `\` before function invocation to speed up resolving.
  484. *
  485. * Risky!
  486. * Risky when any of the functions are overridden.
  487. */
  488. 'native_function_invocation' => [
  489. 'include' => [
  490. '@compiler_optimized',
  491. ],
  492. 'scope' => 'namespaced',
  493. 'strict' => true,
  494. ],
  495. // Native type hints for functions should use the correct case.
  496. 'native_function_type_declaration_casing' => true,
  497. /*
  498. * All instances created with new keyword must be followed by
  499. * braces.
  500. */
  501. 'new_with_braces' => true,
  502. /*
  503. * Master functions shall be used instead of aliases.
  504. *
  505. * Risky!
  506. * Risky when any of the alias functions are overridden.
  507. */
  508. 'no_alias_functions' => [
  509. 'sets' => [
  510. '@all',
  511. ],
  512. ],
  513. // Replace control structure alternative syntax to use braces.
  514. 'no_alternative_syntax' => true,
  515. // There should not be a binary flag before strings.
  516. 'no_binary_string' => true,
  517. // There should be no empty lines after class opening brace.
  518. 'no_blank_lines_after_class_opening' => true,
  519. /*
  520. * There should not be blank lines between docblock and the
  521. * documented element.
  522. */
  523. 'no_blank_lines_after_phpdoc' => true,
  524. // There should be no blank lines before a namespace declaration.
  525. 'no_blank_lines_before_namespace' => false,
  526. /*
  527. * There must be a comment when fall-through is intentional in a
  528. * non-empty case body.
  529. *
  530. * Adds a "no break" comment before fall-through cases, and removes
  531. * it if there is no fall-through.
  532. */
  533. 'no_break_comment' => [
  534. 'comment_text' => 'no break',
  535. ],
  536. /*
  537. * The closing `?>` tag MUST be omitted from files containing only
  538. * PHP.
  539. */
  540. 'no_closing_tag' => true,
  541. // There should not be any empty comments.
  542. 'no_empty_comment' => true,
  543. // There should not be empty PHPDoc blocks.
  544. 'no_empty_phpdoc' => true,
  545. // Remove useless semicolon statements.
  546. 'no_empty_statement' => true,
  547. /*
  548. * Removes extra blank lines and/or blank lines following
  549. * configuration.
  550. */
  551. 'no_extra_blank_lines' => [
  552. 'tokens' => [
  553. 'extra',
  554. 'case',
  555. 'continue',
  556. 'default',
  557. 'curly_brace_block',
  558. 'parenthesis_brace_block',
  559. 'return',
  560. 'square_brace_block',
  561. 'use',
  562. 'throw',
  563. 'use_trait',
  564. 'useTrait',
  565. 'switch',
  566. ],
  567. ],
  568. /*
  569. * Replace accidental usage of homoglyphs (non ascii characters) in
  570. * names.
  571. *
  572. * Risky!
  573. * Renames classes and cannot rename the files. You might have
  574. * string references to renamed code (`$$name`).
  575. */
  576. 'no_homoglyph_names' => true,
  577. // Remove leading slashes in `use` clauses.
  578. 'no_leading_import_slash' => true,
  579. /*
  580. * The namespace declaration line shouldn't contain leading
  581. * whitespace.
  582. */
  583. 'no_leading_namespace_whitespace' => true,
  584. // Either language construct `print` or `echo` should be used.
  585. 'no_mixed_echo_print' => true,
  586. // Operator `=>` should not be surrounded by multi-line whitespaces.
  587. 'no_multiline_whitespace_around_double_arrow' => true,
  588. /*
  589. * Properties MUST not be explicitly initialized with `null` except
  590. * when they have a type declaration (PHP 7.4).
  591. */
  592. 'no_null_property_initialization' => true,
  593. /*
  594. * Convert PHP4-style constructors to `__construct`.
  595. *
  596. * Risky!
  597. * Risky when old style constructor being fixed is overridden or
  598. * overrides parent one.
  599. */
  600. 'no_php4_constructor' => true,
  601. /*
  602. * Short cast `bool` using double exclamation mark should not be
  603. * used.
  604. */
  605. 'no_short_bool_cast' => true,
  606. // Replace short-echo `<?=` with long format `<?php echo` syntax.
  607. 'no_short_echo_tag' => false,
  608. // Single-line whitespace before closing semicolon are prohibited.
  609. 'no_singleline_whitespace_before_semicolons' => true,
  610. /*
  611. * When making a method or function call, there MUST NOT be a space
  612. * between the method or function name and the opening parenthesis.
  613. */
  614. 'no_spaces_after_function_name' => true,
  615. // There MUST NOT be spaces around offset braces.
  616. 'no_spaces_around_offset' => true,
  617. /*
  618. * There MUST NOT be a space after the opening parenthesis. There
  619. * MUST NOT be a space before the closing parenthesis.
  620. */
  621. 'no_spaces_inside_parenthesis' => true,
  622. // Replaces superfluous `elseif` with `if`.
  623. 'no_superfluous_elseif' => true,
  624. /*
  625. * Removes `@param`, `@return` and `@var` tags that don't provide
  626. * any useful information.
  627. */
  628. 'no_superfluous_phpdoc_tags' => false,
  629. // Remove trailing commas in list function calls.
  630. 'no_trailing_comma_in_list_call' => true,
  631. // PHP single-line arrays should not have trailing comma.
  632. 'no_trailing_comma_in_singleline_array' => true,
  633. // Remove trailing whitespace at the end of non-blank lines.
  634. 'no_trailing_whitespace' => true,
  635. // There MUST be no trailing spaces inside comment or PHPDoc.
  636. 'no_trailing_whitespace_in_comment' => true,
  637. // Removes unneeded parentheses around control statements.
  638. 'no_unneeded_control_parentheses' => true,
  639. /*
  640. * Removes unneeded curly braces that are superfluous and aren't
  641. * part of a control structure's body.
  642. */
  643. 'no_unneeded_curly_braces' => true,
  644. /*
  645. * A `final` class must not have `final` methods and `private`
  646. * methods must not be `final`.
  647. *
  648. * Risky!
  649. * Risky when child class overrides a `private` method.
  650. */
  651. 'no_unneeded_final_method' => true,
  652. /*
  653. * In function arguments there must not be arguments with default
  654. * values before non-default ones.
  655. *
  656. * Risky!
  657. * Modifies the signature of functions; therefore risky when using
  658. * systems (such as some Symfony components) that rely on those (for
  659. * example through reflection).
  660. */
  661. 'no_unreachable_default_argument_value' => false,
  662. // Variables must be set `null` instead of using `(unset)` casting.
  663. 'no_unset_cast' => true,
  664. /*
  665. * Properties should be set to `null` instead of using `unset`.
  666. *
  667. * Risky!
  668. * Changing variables to `null` instead of unsetting them will mean
  669. * they still show up when looping over class variables. With PHP
  670. * 7.4, this rule might introduce `null` assignments to property
  671. * whose type declaration does not allow it.
  672. */
  673. 'no_unset_on_property' => false,
  674. // Unused `use` statements must be removed.
  675. 'no_unused_imports' => true,
  676. // There should not be useless `else` cases.
  677. 'no_useless_else' => true,
  678. /*
  679. * There should not be an empty `return` statement at the end of a
  680. * function.
  681. */
  682. 'no_useless_return' => true,
  683. /*
  684. * In array declaration, there MUST NOT be a whitespace before each
  685. * comma.
  686. */
  687. 'no_whitespace_before_comma_in_array' => true,
  688. // Remove trailing whitespace at the end of blank lines.
  689. 'no_whitespace_in_blank_line' => true,
  690. /*
  691. * Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and
  692. * other invisible unicode symbols.
  693. *
  694. * Risky!
  695. * Risky when strings contain intended invisible characters.
  696. */
  697. 'non_printable_character' => true,
  698. // Array index should always be written by using square braces.
  699. 'normalize_index_brace' => true,
  700. /*
  701. * Logical NOT operators (`!`) should have leading and trailing
  702. * whitespaces.
  703. */
  704. 'not_operator_with_space' => false,
  705. // Logical NOT operators (`!`) should have one trailing whitespace.
  706. 'not_operator_with_successor_space' => false,
  707. /*
  708. * Adds or removes `?` before type declarations for parameters with
  709. * a default `null` value.
  710. *
  711. * Rule is applied only in a PHP 7.1+ environment.
  712. */
  713. 'nullable_type_declaration_for_default_null_value' => false,
  714. /*
  715. * There should not be space before or after object
  716. * `T_OBJECT_OPERATOR` `->`.
  717. */
  718. 'object_operator_without_whitespace' => true,
  719. // Orders the elements of classes/interfaces/traits.
  720. 'ordered_class_elements' => false,
  721. // Ordering `use` statements.
  722. 'ordered_imports' => [
  723. 'sort_algorithm' => 'alpha',
  724. 'imports_order' => [
  725. 'class',
  726. 'const',
  727. 'function',
  728. ],
  729. ],
  730. /*
  731. * Orders the interfaces in an `implements` or `interface extends`
  732. * clause.
  733. *
  734. * Risky!
  735. * Risky for `implements` when specifying both an interface and its
  736. * parent interface, because PHP doesn't break on `parent, child`
  737. * but does on `child, parent`.
  738. */
  739. 'ordered_interfaces' => false,
  740. /*
  741. * PHPUnit assertion method calls like `->assertSame(true, $foo)`
  742. * should be written with dedicated method like
  743. * `->assertTrue($foo)`.
  744. *
  745. * Risky!
  746. * Fixer could be risky if one is overriding PHPUnit's native
  747. * methods.
  748. */
  749. 'php_unit_construct' => true,
  750. /*
  751. * PHPUnit assertions like `assertInternalType`, `assertFileExists`,
  752. * should be used over `assertTrue`.
  753. *
  754. * Risky!
  755. * Fixer could be risky if one is overriding PHPUnit's native
  756. * methods.
  757. */
  758. 'php_unit_dedicate_assert' => [
  759. 'target' => '3.5',
  760. ],
  761. /*
  762. * PHPUnit assertions like `assertIsArray` should be used over
  763. * `assertInternalType`.
  764. *
  765. * Risky!
  766. * Risky when PHPUnit methods are overridden or when project has
  767. * PHPUnit incompatibilities.
  768. */
  769. 'php_unit_dedicate_assert_internal_type' => false,
  770. /*
  771. * Usages of `->setExpectedException*` methods MUST be replaced by
  772. * `->expectException*` methods.
  773. *
  774. * Risky!
  775. * Risky when PHPUnit classes are overridden or not accessible, or
  776. * when project has PHPUnit incompatibilities.
  777. */
  778. 'php_unit_expectation' => false,
  779. // PHPUnit annotations should be a FQCNs including a root namespace.
  780. 'php_unit_fqcn_annotation' => true,
  781. // All PHPUnit test classes should be marked as internal.
  782. 'php_unit_internal_class' => true,
  783. /*
  784. * Enforce camel (or snake) case for PHPUnit test methods, following
  785. * configuration.
  786. */
  787. 'php_unit_method_casing' => true,
  788. /*
  789. * Usages of `->getMock` and
  790. * `->getMockWithoutInvokingTheOriginalConstructor` methods MUST be
  791. * replaced by `->createMock` or `->createPartialMock` methods.
  792. *
  793. * Risky!
  794. * Risky when PHPUnit classes are overridden or not accessible, or
  795. * when project has PHPUnit incompatibilities.
  796. */
  797. 'php_unit_mock' => false,
  798. /*
  799. * Usage of PHPUnit's mock e.g. `->will($this->returnValue(..))`
  800. * must be replaced by its shorter equivalent such as
  801. * `->willReturn(...)`.
  802. *
  803. * Risky!
  804. * Risky when PHPUnit classes are overridden or not accessible, or
  805. * when project has PHPUnit incompatibilities.
  806. */
  807. 'php_unit_mock_short_will_return' => false,
  808. /*
  809. * PHPUnit classes MUST be used in namespaced version, e.g.
  810. * `\PHPUnit\Framework\TestCase` instead of
  811. * `\PHPUnit_Framework_TestCase`.
  812. *
  813. * PHPUnit v6 has finally fully switched to namespaces.
  814. * You could start preparing the upgrade by switching from
  815. * non-namespaced TestCase to namespaced one.
  816. * Forward compatibility layer (`\PHPUnit\Framework\TestCase` class)
  817. * was backported to PHPUnit v4.8.35 and PHPUnit v5.4.0.
  818. * Extended forward compatibility layer (`PHPUnit\Framework\Assert`,
  819. * `PHPUnit\Framework\BaseTestListener`,
  820. * `PHPUnit\Framework\TestListener` classes) was introduced in
  821. * v5.7.0.
  822. *
  823. * Risky!
  824. * Risky when PHPUnit classes are overridden or not accessible, or
  825. * when project has PHPUnit incompatibilities.
  826. */
  827. 'php_unit_namespaced' => [
  828. 'target' => '4.8',
  829. ],
  830. /*
  831. * Usages of `@expectedException*` annotations MUST be replaced by
  832. * `->setExpectedException*` methods.
  833. *
  834. * Risky!
  835. * Risky when PHPUnit classes are overridden or not accessible, or
  836. * when project has PHPUnit incompatibilities.
  837. */
  838. 'php_unit_no_expectation_annotation' => [
  839. 'target' => 'newest',
  840. ],
  841. // Order `@covers` annotation of PHPUnit tests.
  842. 'php_unit_ordered_covers' => true,
  843. /*
  844. * Changes the visibility of the `setUp()` and `tearDown()`
  845. * functions of PHPUnit to `protected`, to match the PHPUnit
  846. * TestCase.
  847. *
  848. * Risky!
  849. * This fixer may change functions named `setUp()` or `tearDown()`
  850. * outside of PHPUnit tests, when a class is wrongly seen as a
  851. * PHPUnit test.
  852. */
  853. 'php_unit_set_up_tear_down_visibility' => true,
  854. /*
  855. * All PHPUnit test cases should have `@small`, `@medium` or
  856. * `@large` annotation to enable run time limits.
  857. *
  858. * The special groups [small, medium, large] provides a way to
  859. * identify tests that are taking long to be executed.
  860. */
  861. 'php_unit_size_class' => true,
  862. /*
  863. * PHPUnit methods like `assertSame` should be used instead of
  864. * `assertEquals`.
  865. *
  866. * Risky!
  867. * Risky when any of the functions are overridden or when testing
  868. * object equality.
  869. */
  870. 'php_unit_strict' => false,
  871. /*
  872. * Adds or removes @test annotations from tests, following
  873. * configuration.
  874. *
  875. * Risky!
  876. * This fixer may change the name of your tests, and could cause
  877. * incompatibility with abstract classes or interfaces.
  878. */
  879. 'php_unit_test_annotation' => true,
  880. /*
  881. * Calls to `PHPUnit\Framework\TestCase` static methods must all be
  882. * of the same type, either `$this->`, `self::` or `static::`.
  883. *
  884. * Risky!
  885. * Risky when PHPUnit methods are overridden or not accessible, or
  886. * when project has PHPUnit incompatibilities.
  887. */
  888. 'php_unit_test_case_static_method_calls' => true,
  889. /*
  890. * Adds a default `@coversNothing` annotation to PHPUnit test
  891. * classes that have no `@covers*` annotation.
  892. */
  893. 'php_unit_test_class_requires_covers' => false,
  894. // PHPDoc should contain `@param` for all params.
  895. 'phpdoc_add_missing_param_annotation' => [
  896. 'only_untyped' => false,
  897. ],
  898. /*
  899. * All items of the given phpdoc tags must be either left-aligned or
  900. * (by default) aligned vertically.
  901. */
  902. 'phpdoc_align' => [
  903. 'tags' => [
  904. 'return',
  905. 'throws',
  906. 'type',
  907. 'var',
  908. 'property',
  909. 'method',
  910. 'param',
  911. ],
  912. 'align' => 'vertical',
  913. ],
  914. // PHPDoc annotation descriptions should not be a sentence.
  915. 'phpdoc_annotation_without_dot' => true,
  916. /*
  917. * Docblocks should have the same indentation as the documented
  918. * subject.
  919. */
  920. 'phpdoc_indent' => true,
  921. // Fix PHPDoc inline tags, make `@inheritdoc` always inline.
  922. 'phpdoc_inline_tag' => true,
  923. /*
  924. * Changes doc blocks from single to multi line, or reversed. Works
  925. * for class constants, properties and methods only.
  926. */
  927. 'phpdoc_line_span' => [
  928. 'const' => 'single',
  929. 'property' => 'single',
  930. 'method' => 'multi',
  931. ],
  932. // `@access` annotations should be omitted from PHPDoc.
  933. 'phpdoc_no_access' => true,
  934. // No alias PHPDoc tags should be used.
  935. 'phpdoc_no_alias_tag' => true,
  936. /*
  937. * `@return void` and `@return null` annotations should be omitted
  938. * from PHPDoc.
  939. */
  940. 'phpdoc_no_empty_return' => true,
  941. /*
  942. * `@package` and `@subpackage` annotations should be omitted from
  943. * PHPDoc.
  944. */
  945. 'phpdoc_no_package' => true,
  946. // Classy that does not inherit must not have `@inheritdoc` tags.
  947. 'phpdoc_no_useless_inheritdoc' => true,
  948. /*
  949. * Annotations in PHPDoc should be ordered so that `@param`
  950. * annotations come first, then `@throws` annotations, then
  951. * `@return` annotations.
  952. */
  953. 'phpdoc_order' => true,
  954. /*
  955. * The type of `@return` annotations of methods returning a
  956. * reference to itself must the configured one.
  957. */
  958. 'phpdoc_return_self_reference' => true,
  959. /*
  960. * Scalar types should always be written in the same form. `int` not
  961. * `integer`, `bool` not `boolean`, `float` not `real` or `double`.
  962. */
  963. 'phpdoc_scalar' => true,
  964. /*
  965. * Annotations in PHPDoc should be grouped together so that
  966. * annotations of the same type immediately follow each other, and
  967. * annotations of a different type are separated by a single blank
  968. * line.
  969. */
  970. 'phpdoc_separation' => true,
  971. // Single line `@var` PHPDoc should have proper spacing.
  972. 'phpdoc_single_line_var_spacing' => true,
  973. /*
  974. * PHPDoc summary should end in either a full stop, exclamation
  975. * mark, or question mark.
  976. */
  977. 'phpdoc_summary' => true,
  978. // Docblocks should only be used on structural elements.
  979. 'phpdoc_to_comment' => false,
  980. /*
  981. * EXPERIMENTAL: Takes `@param` annotations of non-mixed types and
  982. * adjusts accordingly the function signature. Requires PHP >= 7.0.
  983. *
  984. * Risky!
  985. * [1] This rule is EXPERIMENTAL and is not covered with backward
  986. * compatibility promise. [2] `@param` annotation is mandatory for
  987. * the fixer to make changes, signatures of methods without it (no
  988. * docblock, inheritdocs) will not be fixed. [3] Manual actions are
  989. * required if inherited signatures are not properly documented.
  990. */
  991. 'phpdoc_to_param_type' => false,
  992. /*
  993. * EXPERIMENTAL: Takes `@return` annotation of non-mixed types and
  994. * adjusts accordingly the function signature. Requires PHP >= 7.0.
  995. *
  996. * Risky!
  997. * [1] This rule is EXPERIMENTAL and is not covered with backward
  998. * compatibility promise. [2] `@return` annotation is mandatory for
  999. * the fixer to make changes, signatures of methods without it (no
  1000. * docblock, inheritdocs) will not be fixed. [3] Manual actions are
  1001. * required if inherited signatures are not properly documented. [4]
  1002. * `@inheritdocs` support is under construction.
  1003. */
  1004. 'phpdoc_to_return_type' => false,
  1005. /*
  1006. * PHPDoc should start and end with content, excluding the very
  1007. * first and last line of the docblocks.
  1008. */
  1009. 'phpdoc_trim' => true,
  1010. /*
  1011. * Removes extra blank lines after summary and after description in
  1012. * PHPDoc.
  1013. */
  1014. 'phpdoc_trim_consecutive_blank_line_separation' => true,
  1015. // The correct case must be used for standard PHP types in PHPDoc.
  1016. 'phpdoc_types' => true,
  1017. // Sorts PHPDoc types.
  1018. 'phpdoc_types_order' => [
  1019. 'sort_algorithm' => 'none',
  1020. 'null_adjustment' => 'always_last',
  1021. ],
  1022. /*
  1023. * `@var` and `@type` annotations must have type and name in the
  1024. * correct order.
  1025. */
  1026. 'phpdoc_var_annotation_correct_order' => true,
  1027. /*
  1028. * `@var` and `@type` annotations of classy properties should not
  1029. * contain the name.
  1030. */
  1031. 'phpdoc_var_without_name' => false,
  1032. /*
  1033. * Converts `pow` to the `**` operator.
  1034. *
  1035. * Risky!
  1036. * Risky when the function `pow` is overridden.
  1037. */
  1038. 'pow_to_exponentiation' => false,
  1039. /*
  1040. * Converts `protected` variables and methods to `private` where
  1041. * possible.
  1042. */
  1043. 'protected_to_private' => true,
  1044. /*
  1045. * Classes must be in a path that matches their namespace, be at
  1046. * least one namespace deep and the class name should match the file
  1047. * name.
  1048. *
  1049. * Risky!
  1050. * This fixer may change your class name, which will break the code
  1051. * that depends on the old name.
  1052. */
  1053. 'psr0' => false,
  1054. /*
  1055. * Class names should match the file name.
  1056. *
  1057. * Risky!
  1058. * This fixer may change your class name, which will break the code
  1059. * that depends on the old name.
  1060. */
  1061. 'psr4' => true,
  1062. /*
  1063. * Replaces `rand`, `srand`, `getrandmax` functions calls with their
  1064. * `mt_*` analogs.
  1065. *
  1066. * Risky!
  1067. * Risky when the configured functions are overridden.
  1068. */
  1069. 'random_api_migration' => [
  1070. 'replacements' => [
  1071. 'getrandmax' => 'mt_getrandmax',
  1072. 'rand' => 'mt_rand',
  1073. 'srand' => 'mt_srand',
  1074. ],
  1075. ],
  1076. /*
  1077. * Local, dynamic and directly referenced variables should not be
  1078. * assigned and directly returned by a function or method.
  1079. */
  1080. 'return_assignment' => true,
  1081. /*
  1082. * There should be one or no space before colon, and one space after
  1083. * it in return type declarations, according to configuration.
  1084. *
  1085. * Rule is applied only in a PHP 7+ environment.
  1086. */
  1087. 'return_type_declaration' => false,
  1088. /*
  1089. * Inside class or interface element `self` should be preferred to
  1090. * the class name itself.
  1091. *
  1092. * Risky!
  1093. * Risky when using dynamic calls like get_called_class() or late
  1094. * static binding.
  1095. */
  1096. 'self_accessor' => true,
  1097. /*
  1098. * Inside a `final` class or anonymous class `self` should be
  1099. * preferred to `static`.
  1100. */
  1101. 'self_static_accessor' => true,
  1102. // Instructions must be terminated with a semicolon.
  1103. 'semicolon_after_instruction' => true,
  1104. /*
  1105. * Cast shall be used, not `settype`.
  1106. *
  1107. * Risky!
  1108. * Risky when the `settype` function is overridden or when used as
  1109. * the 2nd or 3rd expression in a `for` loop .
  1110. */
  1111. 'set_type_to_cast' => true,
  1112. /*
  1113. * Cast `(boolean)` and `(integer)` should be written as `(bool)`
  1114. * and `(int)`, `(double)` and `(real)` as `(float)`, `(binary)` as
  1115. * `(string)`.
  1116. */
  1117. 'short_scalar_cast' => true,
  1118. /*
  1119. * Converts explicit variables in double-quoted strings and heredoc
  1120. * syntax from simple to complex format (`${` to `{$`).
  1121. *
  1122. * Doesn't touch implicit variables. Works together nicely with
  1123. * `explicit_string_variable`.
  1124. */
  1125. 'simple_to_complex_string_variable' => true,
  1126. /*
  1127. * A return statement wishing to return `void` should not return
  1128. * `null`.
  1129. */
  1130. 'simplified_null_return' => false,
  1131. /*
  1132. * A PHP file without end tag must always end with a single empty
  1133. * line feed.
  1134. */
  1135. 'single_blank_line_at_eof' => true,
  1136. /*
  1137. * There should be exactly one blank line before a namespace
  1138. * declaration.
  1139. */
  1140. 'single_blank_line_before_namespace' => true,
  1141. /*
  1142. * There MUST NOT be more than one property or constant declared per
  1143. * statement.
  1144. */
  1145. 'single_class_element_per_statement' => true,
  1146. // There MUST be one use keyword per declaration.
  1147. 'single_import_per_statement' => true,
  1148. /*
  1149. * Each namespace use MUST go on its own line and there MUST be one
  1150. * blank line after the use statements block.
  1151. */
  1152. 'single_line_after_imports' => true,
  1153. /*
  1154. * Single-line comments and multi-line comments with only one line
  1155. * of actual content should use the `//` syntax.
  1156. */
  1157. 'single_line_comment_style' => true,
  1158. // Throwing exception must be done in single line.
  1159. 'single_line_throw' => false,
  1160. // Convert double quotes to single quotes for simple strings.
  1161. 'single_quote' => [
  1162. 'strings_containing_single_quote_chars' => false,
  1163. ],
  1164. // Each trait `use` must be done as single statement.
  1165. 'single_trait_insert_per_statement' => true,
  1166. // Fix whitespace after a semicolon.
  1167. 'space_after_semicolon' => true,
  1168. // Increment and decrement operators should be used if possible.
  1169. 'standardize_increment' => true,
  1170. // Replace all `<>` with `!=`.
  1171. 'standardize_not_equals' => true,
  1172. /*
  1173. * Lambdas not (indirect) referencing `$this` must be declared
  1174. * `static`.
  1175. *
  1176. * Risky!
  1177. * Risky when using `->bindTo` on lambdas without referencing to
  1178. * `$this`.
  1179. */
  1180. 'static_lambda' => true,
  1181. /*
  1182. * Comparisons should be strict.
  1183. *
  1184. * Risky!
  1185. * Changing comparisons to strict might change code behavior.
  1186. */
  1187. 'strict_comparison' => false,
  1188. /*
  1189. * Functions should be used with `$strict` param set to `true`.
  1190. *
  1191. * The functions "array_keys", "array_search", "base64_decode",
  1192. * "in_array" and "mb_detect_encoding" should be used with $strict
  1193. * param.
  1194. *
  1195. * Risky!
  1196. * Risky when the fixed function is overridden or if the code relies
  1197. * on non-strict usage.
  1198. */
  1199. 'strict_param' => false,
  1200. /*
  1201. * All multi-line strings must use correct line ending.
  1202. *
  1203. * Risky!
  1204. * Changing the line endings of multi-line strings might affect
  1205. * string comparisons and outputs.
  1206. */
  1207. 'string_line_ending' => true,
  1208. // A case should be followed by a colon and not a semicolon.
  1209. 'switch_case_semicolon_to_colon' => true,
  1210. // Removes extra spaces between colon and case value.
  1211. 'switch_case_space' => true,
  1212. // Standardize spaces around ternary operator.
  1213. 'ternary_operator_spaces' => true,
  1214. /*
  1215. * Use `null` coalescing operator `??` where possible. Requires PHP
  1216. * >= 7.0.
  1217. */
  1218. 'ternary_to_null_coalescing' => false,
  1219. // PHP multi-line arrays should have a trailing comma.
  1220. 'trailing_comma_in_multiline_array' => true,
  1221. /*
  1222. * Arrays should be formatted like function/method arguments,
  1223. * without leading or trailing single line space.
  1224. */
  1225. 'trim_array_spaces' => true,
  1226. // Unary operators should be placed adjacent to their operands.
  1227. 'unary_operator_spaces' => true,
  1228. /*
  1229. * Visibility MUST be declared on all properties and methods;
  1230. * `abstract` and `final` MUST be declared before the visibility;
  1231. * `static` MUST be declared after the visibility.
  1232. */
  1233. 'visibility_required' => true,
  1234. /*
  1235. * Add `void` return type to functions with missing or empty return
  1236. * statements, but priority is given to `@return` annotations.
  1237. * Requires PHP >= 7.1.
  1238. *
  1239. * Risky!
  1240. * Modifies the signature of functions.
  1241. */
  1242. 'void_return' => false,
  1243. /*
  1244. * In array declaration, there MUST be a whitespace after each
  1245. * comma.
  1246. */
  1247. 'whitespace_after_comma_in_array' => true,
  1248. /*
  1249. * Write conditions in Yoda style (`true`), non-Yoda style (`false`)
  1250. * or ignore those conditions (`null`) based on configuration.
  1251. */
  1252. 'yoda_style' => [
  1253. 'equal' => false,
  1254. 'identical' => false,
  1255. 'less_and_greater' => false,
  1256. ],
  1257. ];
  1258. if (\PHP_SAPI === 'cli' && !class_exists(\PhpCsFixer\Config::class)) {
  1259. $binFixer = __DIR__ . '/vendor/bin/php-cs-fixer';
  1260. if (!is_file($binFixer)) {
  1261. $binFixer = 'php-cs-fixer';
  1262. }
  1263. $dryRun = !in_array('--force', $_SERVER['argv'], true);
  1264. $command = escapeshellarg($binFixer) . ' fix --config ' . escapeshellarg(__FILE__) . ' --diff-format udiff --ansi -vv';
  1265. if ($dryRun) {
  1266. $command .= ' --dry-run';
  1267. }
  1268. system($command, $returnCode);
  1269. if ($dryRun || $returnCode === 8) {
  1270. fwrite(\STDOUT, "\n\e[1;40;93m\e[K\n");
  1271. fwrite(\STDOUT, " [DEBUG] Dry run php-cs-fixer config.\e[K\n");
  1272. fwrite(\STDOUT, " Only shows which files would have been modified.\e[K\n");
  1273. fwrite(\STDOUT, " To apply the rules, use the --force option:\e[K\n\e[K\n");
  1274. fwrite(\STDOUT, " \e[1;40;92mphp {$_SERVER['argv'][0]} --force\e[K\n\e[0m\n");
  1275. } elseif ($returnCode !== 0) {
  1276. fwrite(\STDERR, "\n\e[1;41;97m\e[K\n ERROR CODE: {$returnCode}\e[K\n\e[0m\n");
  1277. }
  1278. exit($returnCode);
  1279. }
  1280. return \PhpCsFixer\Config::create()
  1281. ->setUsingCache(true)
  1282. ->setCacheFile(__DIR__ . '/.php_cs.cache')
  1283. ->setRules($rules)
  1284. ->setRiskyAllowed(true)
  1285. ->setFinder(
  1286. \PhpCsFixer\Finder::create()
  1287. ->in(__DIR__)
  1288. )
  1289. ;