README.rst 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289
  1. PHP Coding Standards Fixer
  2. ==========================
  3. The PHP Coding Standards Fixer (PHP CS Fixer) tool fixes your code to follow standards;
  4. whether you want to follow PHP coding standards as defined in the PSR-1, PSR-2, etc.,
  5. or other community driven ones like the Symfony one.
  6. You can **also** define your (team's) style through configuration.
  7. It can modernize your code (like converting the ``pow`` function to the ``**`` operator on PHP 5.6)
  8. and (micro) optimize it.
  9. If you are already using a linter to identify coding standards problems in your
  10. code, you know that fixing them by hand is tedious, especially on large
  11. projects. This tool does not only detect them, but also fixes them for you.
  12. The PHP CS Fixer is maintained on GitHub at https://github.com/FriendsOfPHP/PHP-CS-Fixer.
  13. Bug reports and ideas about new features are welcome there.
  14. You can talk to us at https://gitter.im/PHP-CS-Fixer/Lobby about the project,
  15. configuration, possible improvements, ideas and questions, please visit us!
  16. Requirements
  17. ------------
  18. PHP needs to be a minimum version of PHP 5.6.0.
  19. Installation
  20. ------------
  21. Locally
  22. ~~~~~~~
  23. Download the `php-cs-fixer.phar`_ file and store it somewhere on your computer.
  24. Globally (manual)
  25. ~~~~~~~~~~~~~~~~~
  26. You can run these commands to easily access latest ``php-cs-fixer`` from anywhere on
  27. your system:
  28. .. code-block:: bash
  29. $ wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer
  30. or with specified version:
  31. .. code-block:: bash
  32. $ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -O php-cs-fixer
  33. or with curl:
  34. .. code-block:: bash
  35. $ curl -L https://cs.symfony.com/download/php-cs-fixer-v2.phar -o php-cs-fixer
  36. then:
  37. .. code-block:: bash
  38. $ sudo chmod a+x php-cs-fixer
  39. $ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
  40. Then, just run ``php-cs-fixer``.
  41. Globally (Composer)
  42. ~~~~~~~~~~~~~~~~~~~
  43. To install PHP CS Fixer, `install Composer <https://getcomposer.org/download/>`_ and issue the following command:
  44. .. code-block:: bash
  45. $ composer global require friendsofphp/php-cs-fixer
  46. Then make sure you have the global Composer binaries directory in your ``PATH``. This directory is platform-dependent, see `Composer documentation <https://getcomposer.org/doc/03-cli.md#composer-home>`_ for details. Example for some Unix systems:
  47. .. code-block:: bash
  48. $ export PATH="$PATH:$HOME/.composer/vendor/bin"
  49. Globally (homebrew)
  50. ~~~~~~~~~~~~~~~~~~~
  51. .. code-block:: bash
  52. $ brew install php-cs-fixer
  53. Locally (PHIVE)
  54. ~~~~~~~~~~~~~~~
  55. Install `PHIVE <https://phar.io>`_ and issue the following command:
  56. .. code-block:: bash
  57. $ phive install php-cs-fixer # use `--global` for global install
  58. Update
  59. ------
  60. Locally
  61. ~~~~~~~
  62. The ``self-update`` command tries to update ``php-cs-fixer`` itself:
  63. .. code-block:: bash
  64. $ php php-cs-fixer.phar self-update
  65. Globally (manual)
  66. ~~~~~~~~~~~~~~~~~
  67. You can update ``php-cs-fixer`` through this command:
  68. .. code-block:: bash
  69. $ sudo php-cs-fixer self-update
  70. Globally (Composer)
  71. ~~~~~~~~~~~~~~~~~~~
  72. You can update ``php-cs-fixer`` through this command:
  73. .. code-block:: bash
  74. $ ./composer.phar global update friendsofphp/php-cs-fixer
  75. Globally (homebrew)
  76. ~~~~~~~~~~~~~~~~~~~
  77. You can update ``php-cs-fixer`` through this command:
  78. .. code-block:: bash
  79. $ brew upgrade php-cs-fixer
  80. Locally (PHIVE)
  81. ~~~~~~~~~~~~~~~
  82. .. code-block:: bash
  83. $ phive update php-cs-fixer
  84. Usage
  85. -----
  86. The ``fix`` command tries to fix as much coding standards
  87. problems as possible on a given file or files in a given directory and its subdirectories:
  88. .. code-block:: bash
  89. $ php php-cs-fixer.phar fix /path/to/dir
  90. $ php php-cs-fixer.phar fix /path/to/file
  91. By default ``--path-mode`` is set to ``override``, which means, that if you specify the path to a file or a directory via
  92. command arguments, then the paths provided to a ``Finder`` in config file will be ignored. You can use ``--path-mode=intersection``
  93. to merge paths from the config file and from the argument:
  94. .. code-block:: bash
  95. $ php php-cs-fixer.phar fix --path-mode=intersection /path/to/dir
  96. The ``--format`` option for the output format. Supported formats are ``txt`` (default one), ``json``, ``xml``, ``checkstyle``, ``junit`` and ``gitlab``.
  97. NOTE: the output for the following formats are generated in accordance with XML schemas
  98. * ``junit`` follows the `JUnit xml schema from Jenkins </doc/junit-10.xsd>`_
  99. * ``checkstyle`` follows the common `"checkstyle" xml schema </doc/checkstyle.xsd>`_
  100. The ``--quiet`` Do not output any message.
  101. The ``--verbose`` option will show the applied rules. When using the ``txt`` format it will also display progress notifications.
  102. NOTE: if there is an error like "errors reported during linting after fixing", you can use this to be even more verbose for debugging purpose
  103. * ``--verbose=0`` or no option: normal
  104. * ``--verbose``, ``--verbose=1``, ``-v``: verbose
  105. * ``--verbose=2``, ``-vv``: very verbose
  106. * ``--verbose=3``, ``-vvv``: debug
  107. The ``--rules`` option limits the rules to apply to the
  108. project:
  109. .. code-block:: bash
  110. $ php php-cs-fixer.phar fix /path/to/project --rules=@PSR2
  111. By default the PSR1 and PSR2 rules are used.
  112. The ``--rules`` option lets you choose the exact rules to
  113. apply (the rule names must be separated by a comma):
  114. .. code-block:: bash
  115. $ php php-cs-fixer.phar fix /path/to/dir --rules=line_ending,full_opening_tag,indentation_type
  116. You can also exclude the rules you don't want by placing a dash in front of the rule name, if this is more convenient,
  117. using ``-name_of_fixer``:
  118. .. code-block:: bash
  119. $ php php-cs-fixer.phar fix /path/to/dir --rules=-full_opening_tag,-indentation_type
  120. When using combinations of exact and exclude rules, applying exact rules along with above excluded results:
  121. .. code-block:: bash
  122. $ php php-cs-fixer.phar fix /path/to/project --rules=@Symfony,-@PSR1,-blank_line_before_statement,strict_comparison
  123. Complete configuration for rules can be supplied using a ``json`` formatted string.
  124. .. code-block:: bash
  125. $ php php-cs-fixer.phar fix /path/to/project --rules='{"concat_space": {"spacing": "none"}}'
  126. The ``--dry-run`` flag will run the fixer without making changes to your files.
  127. The ``--diff`` flag can be used to let the fixer output all the changes it makes.
  128. The ``--diff-format`` option allows to specify in which format the fixer should output the changes it makes:
  129. * ``null``: no diff;
  130. * ``udiff``: unified diff format.
  131. The ``--allow-risky`` option (pass ``yes`` or ``no``) allows you to set whether risky rules may run. Default value is taken from config file.
  132. A rule is considered risky if it could change code behaviour. By default no risky rules are run.
  133. The ``--stop-on-violation`` flag stops the execution upon first file that needs to be fixed.
  134. The ``--show-progress`` option allows you to choose the way process progress is rendered:
  135. * ``none``: disables progress output;
  136. * ``dots``: multiline progress output with number of files and percentage on each line.
  137. If the option is not provided, it defaults to ``dots`` unless a config file that disables output is used, in which case it defaults to ``none``. This option has no effect if the verbosity of the command is less than ``verbose``.
  138. .. code-block:: bash
  139. $ php php-cs-fixer.phar fix --verbose --show-progress=dots
  140. The command can also read from standard input, in which case it won't
  141. automatically fix anything:
  142. .. code-block:: bash
  143. $ cat foo.php | php php-cs-fixer.phar fix --diff -
  144. Finally, if you don't need BC kept on CLI level, you might use `PHP_CS_FIXER_FUTURE_MODE` to start using options that
  145. would be default in next MAJOR release (unified differ, dots, full-width progress indicator):
  146. .. code-block:: bash
  147. $ PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer.phar fix -v --diff
  148. Rules
  149. -----
  150. Use the following command to quickly understand what a rule will do to your code:
  151. .. code-block:: bash
  152. $ php php-cs-fixer.phar describe align_multiline_comment
  153. To visualize all the rules that belong to a ruleset:
  154. .. code-block:: bash
  155. $ php php-cs-fixer.phar describe @PSR2
  156. Choose from the list of available rules:
  157. * **align_multiline_comment** [@PhpCsFixer]
  158. Each line of multi-line DocComments must have an asterisk [PSR-5] and
  159. must be aligned with the first one.
  160. Configuration options:
  161. - ``comment_type`` (``'all_multiline'``, ``'phpdocs_like'``, ``'phpdocs_only'``): whether
  162. to fix PHPDoc comments only (``phpdocs_only``), any multi-line comment
  163. whose lines all start with an asterisk (``phpdocs_like``) or any
  164. multi-line comment (``all_multiline``); defaults to ``'phpdocs_only'``
  165. * **array_indentation** [@PhpCsFixer]
  166. Each element of an array must be indented exactly once.
  167. * **array_push** [@Symfony:risky, @PhpCsFixer:risky]
  168. Converts simple usages of ``array_push($x, $y);`` to ``$x[] = $y;``.
  169. *Risky rule: risky when the function ``array_push`` is overridden.*
  170. * **array_syntax** [@Symfony, @PhpCsFixer]
  171. PHP arrays should be declared using the configured syntax.
  172. Configuration options:
  173. - ``syntax`` (``'long'``, ``'short'``): whether to use the ``long`` or ``short`` array
  174. syntax; defaults to ``'long'``
  175. * **backtick_to_shell_exec** [@Symfony, @PhpCsFixer]
  176. Converts backtick operators to ``shell_exec`` calls.
  177. * **binary_operator_spaces** [@Symfony, @PhpCsFixer]
  178. Binary operators should be surrounded by space as configured.
  179. Configuration options:
  180. - ``default`` (``'align'``, ``'align_single_space'``, ``'align_single_space_minimal'``,
  181. ``'no_space'``, ``'single_space'``, ``null``): default fix strategy; defaults to
  182. ``'single_space'``
  183. - ``operators`` (``array``): dictionary of ``binary operator`` => ``fix strategy``
  184. values that differ from the default strategy; defaults to ``[]``
  185. * **blank_line_after_namespace** [@PSR2, @Symfony, @PhpCsFixer]
  186. There MUST be one blank line after the namespace declaration.
  187. * **blank_line_after_opening_tag** [@Symfony, @PhpCsFixer]
  188. Ensure there is no code on the same line as the PHP open tag and it is
  189. followed by a blank line.
  190. * **blank_line_before_statement** [@Symfony, @PhpCsFixer]
  191. An empty line feed must precede any configured statement.
  192. Configuration options:
  193. - ``statements`` (a subset of ``['break', 'case', 'continue', 'declare',
  194. 'default', 'die', 'do', 'exit', 'for', 'foreach', 'goto', 'if',
  195. 'include', 'include_once', 'require', 'require_once', 'return',
  196. 'switch', 'throw', 'try', 'while', 'yield', 'yield_from']``): list of
  197. statements which must be preceded by an empty line; defaults to
  198. ``['break', 'continue', 'declare', 'return', 'throw', 'try']``
  199. * **braces** [@PSR2, @Symfony, @PhpCsFixer]
  200. The body of each structure MUST be enclosed by braces. Braces should be
  201. properly placed. Body of braces should be properly indented.
  202. Configuration options:
  203. - ``allow_single_line_anonymous_class_with_empty_body`` (``bool``): whether single
  204. line anonymous class with empty body notation should be allowed;
  205. defaults to ``false``
  206. - ``allow_single_line_closure`` (``bool``): whether single line lambda notation
  207. should be allowed; defaults to ``false``
  208. - ``position_after_anonymous_constructs`` (``'next'``, ``'same'``): whether the
  209. opening brace should be placed on "next" or "same" line after anonymous
  210. constructs (anonymous classes and lambda functions); defaults to ``'same'``
  211. - ``position_after_control_structures`` (``'next'``, ``'same'``): whether the opening
  212. brace should be placed on "next" or "same" line after control
  213. structures; defaults to ``'same'``
  214. - ``position_after_functions_and_oop_constructs`` (``'next'``, ``'same'``): whether
  215. the opening brace should be placed on "next" or "same" line after
  216. classy constructs (non-anonymous classes, interfaces, traits, methods
  217. and non-lambda functions); defaults to ``'next'``
  218. * **cast_spaces** [@Symfony, @PhpCsFixer]
  219. A single space or none should be between cast and variable.
  220. Configuration options:
  221. - ``space`` (``'none'``, ``'single'``): spacing to apply between cast and variable;
  222. defaults to ``'single'``
  223. * **class_attributes_separation** [@Symfony, @PhpCsFixer]
  224. Class, trait and interface elements must be separated with one or none
  225. blank line.
  226. Configuration options:
  227. - ``elements`` (``array``): dictionary of ``const|method|property`` => ``none|one``
  228. values; defaults to ``['const' => 'one', 'method' => 'one', 'property' =>
  229. 'one']``
  230. * **class_definition** [@PSR2, @Symfony, @PhpCsFixer]
  231. Whitespace around the keywords of a class, trait or interfaces
  232. definition should be one space.
  233. Configuration options:
  234. - ``multi_line_extends_each_single_line`` (``bool``): whether definitions should
  235. be multiline; defaults to ``false``; DEPRECATED alias:
  236. ``multiLineExtendsEachSingleLine``
  237. - ``single_item_single_line`` (``bool``): whether definitions should be single
  238. line when including a single item; defaults to ``false``; DEPRECATED alias:
  239. ``singleItemSingleLine``
  240. - ``single_line`` (``bool``): whether definitions should be single line; defaults
  241. to ``false``; DEPRECATED alias: ``singleLine``
  242. * **class_keyword_remove**
  243. Converts ``::class`` keywords to FQCN strings.
  244. * **combine_consecutive_issets** [@PhpCsFixer]
  245. Using ``isset($var) &&`` multiple times should be done in one call.
  246. * **combine_consecutive_unsets** [@PhpCsFixer]
  247. Calling ``unset`` on multiple items should be done in one call.
  248. * **combine_nested_dirname** [@Symfony:risky, @PhpCsFixer:risky, @PHP70Migration:risky, @PHP71Migration:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  249. Replace multiple nested calls of ``dirname`` by only one call with second
  250. ``$level`` parameter. Requires PHP >= 7.0.
  251. *Risky rule: risky when the function ``dirname`` is overridden.*
  252. * **comment_to_phpdoc** [@PhpCsFixer:risky]
  253. Comments with annotation should be docblock when used on structural
  254. elements.
  255. *Risky rule: risky as new docblocks might mean more, e.g. a Doctrine entity might have a new column in database.*
  256. Configuration options:
  257. - ``ignored_tags`` (``array``): list of ignored tags; defaults to ``[]``
  258. * **compact_nullable_typehint** [@PhpCsFixer]
  259. Remove extra spaces in a nullable typehint.
  260. * **concat_space** [@Symfony, @PhpCsFixer]
  261. Concatenation should be spaced according configuration.
  262. Configuration options:
  263. - ``spacing`` (``'none'``, ``'one'``): spacing to apply around concatenation operator;
  264. defaults to ``'none'``
  265. * **constant_case** [@PSR2, @Symfony, @PhpCsFixer]
  266. The PHP constants ``true``, ``false``, and ``null`` MUST be written using the
  267. correct casing.
  268. Configuration options:
  269. - ``case`` (``'lower'``, ``'upper'``): whether to use the ``upper`` or ``lower`` case
  270. syntax; defaults to ``'lower'``
  271. * **date_time_immutable**
  272. Class ``DateTimeImmutable`` should be used instead of ``DateTime``.
  273. *Risky rule: risky when the code relies on modifying ``DateTime`` objects or if any of the ``date_create*`` functions are overridden.*
  274. * **declare_equal_normalize** [@Symfony, @PhpCsFixer]
  275. Equal sign in declare statement should be surrounded by spaces or not
  276. following configuration.
  277. Configuration options:
  278. - ``space`` (``'none'``, ``'single'``): spacing to apply around the equal sign;
  279. defaults to ``'none'``
  280. * **declare_strict_types** [@PHP70Migration:risky, @PHP71Migration:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  281. Force strict types declaration in all files. Requires PHP >= 7.0.
  282. *Risky rule: forcing strict types will stop non strict code from working.*
  283. * **dir_constant** [@Symfony:risky, @PhpCsFixer:risky]
  284. Replaces ``dirname(__FILE__)`` expression with equivalent ``__DIR__``
  285. constant.
  286. *Risky rule: risky when the function ``dirname`` is overridden.*
  287. * **doctrine_annotation_array_assignment** [@DoctrineAnnotation]
  288. Doctrine annotations must use configured operator for assignment in
  289. arrays.
  290. Configuration options:
  291. - ``ignored_tags`` (``array``): list of tags that must not be treated as Doctrine
  292. Annotations; defaults to ``['abstract', 'access', 'code', 'deprec',
  293. 'encode', 'exception', 'final', 'ingroup', 'inheritdoc', 'inheritDoc',
  294. 'magic', 'name', 'toc', 'tutorial', 'private', 'static', 'staticvar',
  295. 'staticVar', 'throw', 'api', 'author', 'category', 'copyright',
  296. 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal',
  297. 'license', 'link', 'method', 'package', 'param', 'property',
  298. 'property-read', 'property-write', 'return', 'see', 'since', 'source',
  299. 'subpackage', 'throws', 'todo', 'TODO', 'usedBy', 'uses', 'var',
  300. 'version', 'after', 'afterClass', 'backupGlobals',
  301. 'backupStaticAttributes', 'before', 'beforeClass',
  302. 'codeCoverageIgnore', 'codeCoverageIgnoreStart',
  303. 'codeCoverageIgnoreEnd', 'covers', 'coversDefaultClass',
  304. 'coversNothing', 'dataProvider', 'depends', 'expectedException',
  305. 'expectedExceptionCode', 'expectedExceptionMessage',
  306. 'expectedExceptionMessageRegExp', 'group', 'large', 'medium',
  307. 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses',
  308. 'runInSeparateProcess', 'small', 'test', 'testdox', 'ticket', 'uses',
  309. 'SuppressWarnings', 'noinspection', 'package_version', 'enduml',
  310. 'startuml', 'fix', 'FIXME', 'fixme', 'override']``
  311. - ``operator`` (``':'``, ``'='``): the operator to use; defaults to ``'='``
  312. * **doctrine_annotation_braces** [@DoctrineAnnotation]
  313. Doctrine annotations without arguments must use the configured syntax.
  314. Configuration options:
  315. - ``ignored_tags`` (``array``): list of tags that must not be treated as Doctrine
  316. Annotations; defaults to ``['abstract', 'access', 'code', 'deprec',
  317. 'encode', 'exception', 'final', 'ingroup', 'inheritdoc', 'inheritDoc',
  318. 'magic', 'name', 'toc', 'tutorial', 'private', 'static', 'staticvar',
  319. 'staticVar', 'throw', 'api', 'author', 'category', 'copyright',
  320. 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal',
  321. 'license', 'link', 'method', 'package', 'param', 'property',
  322. 'property-read', 'property-write', 'return', 'see', 'since', 'source',
  323. 'subpackage', 'throws', 'todo', 'TODO', 'usedBy', 'uses', 'var',
  324. 'version', 'after', 'afterClass', 'backupGlobals',
  325. 'backupStaticAttributes', 'before', 'beforeClass',
  326. 'codeCoverageIgnore', 'codeCoverageIgnoreStart',
  327. 'codeCoverageIgnoreEnd', 'covers', 'coversDefaultClass',
  328. 'coversNothing', 'dataProvider', 'depends', 'expectedException',
  329. 'expectedExceptionCode', 'expectedExceptionMessage',
  330. 'expectedExceptionMessageRegExp', 'group', 'large', 'medium',
  331. 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses',
  332. 'runInSeparateProcess', 'small', 'test', 'testdox', 'ticket', 'uses',
  333. 'SuppressWarnings', 'noinspection', 'package_version', 'enduml',
  334. 'startuml', 'fix', 'FIXME', 'fixme', 'override']``
  335. - ``syntax`` (``'with_braces'``, ``'without_braces'``): whether to add or remove
  336. braces; defaults to ``'without_braces'``
  337. * **doctrine_annotation_indentation** [@DoctrineAnnotation]
  338. Doctrine annotations must be indented with four spaces.
  339. Configuration options:
  340. - ``ignored_tags`` (``array``): list of tags that must not be treated as Doctrine
  341. Annotations; defaults to ``['abstract', 'access', 'code', 'deprec',
  342. 'encode', 'exception', 'final', 'ingroup', 'inheritdoc', 'inheritDoc',
  343. 'magic', 'name', 'toc', 'tutorial', 'private', 'static', 'staticvar',
  344. 'staticVar', 'throw', 'api', 'author', 'category', 'copyright',
  345. 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal',
  346. 'license', 'link', 'method', 'package', 'param', 'property',
  347. 'property-read', 'property-write', 'return', 'see', 'since', 'source',
  348. 'subpackage', 'throws', 'todo', 'TODO', 'usedBy', 'uses', 'var',
  349. 'version', 'after', 'afterClass', 'backupGlobals',
  350. 'backupStaticAttributes', 'before', 'beforeClass',
  351. 'codeCoverageIgnore', 'codeCoverageIgnoreStart',
  352. 'codeCoverageIgnoreEnd', 'covers', 'coversDefaultClass',
  353. 'coversNothing', 'dataProvider', 'depends', 'expectedException',
  354. 'expectedExceptionCode', 'expectedExceptionMessage',
  355. 'expectedExceptionMessageRegExp', 'group', 'large', 'medium',
  356. 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses',
  357. 'runInSeparateProcess', 'small', 'test', 'testdox', 'ticket', 'uses',
  358. 'SuppressWarnings', 'noinspection', 'package_version', 'enduml',
  359. 'startuml', 'fix', 'FIXME', 'fixme', 'override']``
  360. - ``indent_mixed_lines`` (``bool``): whether to indent lines that have content
  361. before closing parenthesis; defaults to ``false``
  362. * **doctrine_annotation_spaces** [@DoctrineAnnotation]
  363. Fixes spaces in Doctrine annotations.
  364. Configuration options:
  365. - ``after_argument_assignments`` (``null``, ``bool``): whether to add, remove or
  366. ignore spaces after argument assignment operator; defaults to ``false``
  367. - ``after_array_assignments_colon`` (``null``, ``bool``): whether to add, remove or
  368. ignore spaces after array assignment ``:`` operator; defaults to ``true``
  369. - ``after_array_assignments_equals`` (``null``, ``bool``): whether to add, remove or
  370. ignore spaces after array assignment ``=`` operator; defaults to ``true``
  371. - ``around_commas`` (``bool``): whether to fix spaces around commas; defaults to
  372. ``true``
  373. - ``around_parentheses`` (``bool``): whether to fix spaces around parentheses;
  374. defaults to ``true``
  375. - ``before_argument_assignments`` (``null``, ``bool``): whether to add, remove or
  376. ignore spaces before argument assignment operator; defaults to ``false``
  377. - ``before_array_assignments_colon`` (``null``, ``bool``): whether to add, remove or
  378. ignore spaces before array ``:`` assignment operator; defaults to ``true``
  379. - ``before_array_assignments_equals`` (``null``, ``bool``): whether to add, remove or
  380. ignore spaces before array ``=`` assignment operator; defaults to ``true``
  381. - ``ignored_tags`` (``array``): list of tags that must not be treated as Doctrine
  382. Annotations; defaults to ``['abstract', 'access', 'code', 'deprec',
  383. 'encode', 'exception', 'final', 'ingroup', 'inheritdoc', 'inheritDoc',
  384. 'magic', 'name', 'toc', 'tutorial', 'private', 'static', 'staticvar',
  385. 'staticVar', 'throw', 'api', 'author', 'category', 'copyright',
  386. 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal',
  387. 'license', 'link', 'method', 'package', 'param', 'property',
  388. 'property-read', 'property-write', 'return', 'see', 'since', 'source',
  389. 'subpackage', 'throws', 'todo', 'TODO', 'usedBy', 'uses', 'var',
  390. 'version', 'after', 'afterClass', 'backupGlobals',
  391. 'backupStaticAttributes', 'before', 'beforeClass',
  392. 'codeCoverageIgnore', 'codeCoverageIgnoreStart',
  393. 'codeCoverageIgnoreEnd', 'covers', 'coversDefaultClass',
  394. 'coversNothing', 'dataProvider', 'depends', 'expectedException',
  395. 'expectedExceptionCode', 'expectedExceptionMessage',
  396. 'expectedExceptionMessageRegExp', 'group', 'large', 'medium',
  397. 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses',
  398. 'runInSeparateProcess', 'small', 'test', 'testdox', 'ticket', 'uses',
  399. 'SuppressWarnings', 'noinspection', 'package_version', 'enduml',
  400. 'startuml', 'fix', 'FIXME', 'fixme', 'override']``
  401. * **echo_tag_syntax** [@Symfony, @PhpCsFixer]
  402. Replaces short-echo ``<?=`` with long format ``<?php echo``/``<?php print``
  403. syntax, or vice-versa.
  404. Configuration options:
  405. - ``format`` (``'long'``, ``'short'``): the desired language construct; defaults to
  406. ``'long'``
  407. - ``long_function`` (``'echo'``, ``'print'``): the function to be used to expand the
  408. short echo tags; defaults to ``'echo'``
  409. - ``shorten_simple_statements_only`` (``bool``): render short-echo tags only in
  410. case of simple code; defaults to ``true``
  411. * **elseif** [@PSR2, @Symfony, @PhpCsFixer]
  412. The keyword ``elseif`` should be used instead of ``else if`` so that all
  413. control keywords look like single words.
  414. * **encoding** [@PSR1, @PSR2, @Symfony, @PhpCsFixer]
  415. PHP code MUST use only UTF-8 without BOM (remove BOM).
  416. * **ereg_to_preg** [@Symfony:risky, @PhpCsFixer:risky]
  417. Replace deprecated ``ereg`` regular expression functions with ``preg``.
  418. *Risky rule: risky if the ``ereg`` function is overridden.*
  419. * **error_suppression** [@Symfony:risky, @PhpCsFixer:risky]
  420. Error control operator should be added to deprecation notices and/or
  421. removed from other cases.
  422. *Risky rule: risky because adding/removing ``@`` might cause changes to code behaviour or if ``trigger_error`` function is overridden.*
  423. Configuration options:
  424. - ``mute_deprecation_error`` (``bool``): whether to add ``@`` in deprecation
  425. notices; defaults to ``true``
  426. - ``noise_remaining_usages`` (``bool``): whether to remove ``@`` in remaining
  427. usages; defaults to ``false``
  428. - ``noise_remaining_usages_exclude`` (``array``): list of global functions to
  429. exclude from removing ``@``; defaults to ``[]``
  430. * **escape_implicit_backslashes** [@PhpCsFixer]
  431. Escape implicit backslashes in strings and heredocs to ease the
  432. understanding of which are special chars interpreted by PHP and which
  433. not.
  434. Configuration options:
  435. - ``double_quoted`` (``bool``): whether to fix double-quoted strings; defaults to
  436. ``true``
  437. - ``heredoc_syntax`` (``bool``): whether to fix heredoc syntax; defaults to ``true``
  438. - ``single_quoted`` (``bool``): whether to fix single-quoted strings; defaults to
  439. ``false``
  440. * **explicit_indirect_variable** [@PhpCsFixer]
  441. Add curly braces to indirect variables to make them clear to understand.
  442. Requires PHP >= 7.0.
  443. * **explicit_string_variable** [@PhpCsFixer]
  444. Converts implicit variables into explicit ones in double-quoted strings
  445. or heredoc syntax.
  446. * **final_class**
  447. All classes must be final, except abstract ones and Doctrine entities.
  448. *Risky rule: risky when subclassing non-abstract classes.*
  449. * **final_internal_class** [@PhpCsFixer:risky]
  450. Internal classes should be ``final``.
  451. *Risky rule: changing classes to ``final`` might cause code execution to break.*
  452. Configuration options:
  453. - ``annotation_exclude`` (``array``): class level annotations tags that must be
  454. omitted to fix the class, even if all of the white list ones are used
  455. as well. (case insensitive); defaults to ``['@final', '@Entity',
  456. '@ORM\\Entity', '@ORM\\Mapping\\Entity', '@Mapping\\Entity']``;
  457. DEPRECATED alias: ``annotation-black-list``
  458. - ``annotation_include`` (``array``): class level annotations tags that must be
  459. set in order to fix the class. (case insensitive); defaults to
  460. ``['@internal']``; DEPRECATED alias: ``annotation-white-list``
  461. - ``consider_absent_docblock_as_internal_class`` (``bool``): should classes
  462. without any DocBlock be fixed to final?; defaults to ``false``; DEPRECATED
  463. alias: ``consider-absent-docblock-as-internal-class``
  464. * **final_public_method_for_abstract_class**
  465. All ``public`` methods of ``abstract`` classes should be ``final``.
  466. *Risky rule: risky when overriding ``public`` methods of ``abstract`` classes.*
  467. * **final_static_access**
  468. Converts ``static`` access to ``self`` access in ``final`` classes.
  469. DEPRECATED: use ``self_static_accessor`` instead.
  470. * **fopen_flag_order** [@Symfony:risky, @PhpCsFixer:risky]
  471. Order the flags in ``fopen`` calls, ``b`` and ``t`` must be last.
  472. *Risky rule: risky when the function ``fopen`` is overridden.*
  473. * **fopen_flags** [@Symfony:risky, @PhpCsFixer:risky]
  474. The flags in ``fopen`` calls must omit ``t``, and ``b`` must be omitted or
  475. included consistently.
  476. *Risky rule: risky when the function ``fopen`` is overridden.*
  477. Configuration options:
  478. - ``b_mode`` (``bool``): the ``b`` flag must be used (``true``) or omitted (``false``);
  479. defaults to ``true``
  480. * **full_opening_tag** [@PSR1, @PSR2, @Symfony, @PhpCsFixer]
  481. PHP code must use the long ``<?php`` tags or short-echo ``<?=`` tags and not
  482. other tag variations.
  483. * **fully_qualified_strict_types** [@Symfony, @PhpCsFixer]
  484. Transforms imported FQCN parameters and return types in function
  485. arguments to short version.
  486. * **function_declaration** [@PSR2, @Symfony, @PhpCsFixer]
  487. Spaces should be properly placed in a function declaration.
  488. Configuration options:
  489. - ``closure_function_spacing`` (``'none'``, ``'one'``): spacing to use before open
  490. parenthesis for closures; defaults to ``'one'``
  491. * **function_to_constant** [@Symfony:risky, @PhpCsFixer:risky]
  492. Replace core functions calls returning constants with the constants.
  493. *Risky rule: risky when any of the configured functions to replace are overridden.*
  494. Configuration options:
  495. - ``functions`` (a subset of ``['get_called_class', 'get_class',
  496. 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']``): list of
  497. function names to fix; defaults to ``['get_called_class', 'get_class',
  498. 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']``
  499. * **function_typehint_space** [@Symfony, @PhpCsFixer]
  500. Ensure single space between function's argument and its typehint.
  501. * **general_phpdoc_annotation_remove**
  502. Configured annotations should be omitted from PHPDoc.
  503. Configuration options:
  504. - ``annotations`` (``array``): list of annotations to remove, e.g. ``["author"]``;
  505. defaults to ``[]``
  506. * **general_phpdoc_tag_rename** [@Symfony, @PhpCsFixer]
  507. Renames PHPDoc tags.
  508. Configuration options:
  509. - ``case_sensitive`` (``bool``): whether tags should be replaced only if they have
  510. exact same casing; defaults to ``false``
  511. - ``fix_annotation`` (``bool``): whether annotation tags should be fixed; defaults
  512. to ``true``
  513. - ``fix_inline`` (``bool``): whether inline tags should be fixed; defaults to ``true``
  514. - ``replacements`` (``array``): a map of tags to replace; defaults to ``[]``
  515. * **global_namespace_import**
  516. Imports or fully qualifies global classes/functions/constants.
  517. Configuration options:
  518. - ``import_classes`` (``false``, ``null``, ``true``): whether to import, not import or
  519. ignore global classes; defaults to ``true``
  520. - ``import_constants`` (``false``, ``null``, ``true``): whether to import, not import or
  521. ignore global constants; defaults to ``null``
  522. - ``import_functions`` (``false``, ``null``, ``true``): whether to import, not import or
  523. ignore global functions; defaults to ``null``
  524. * **group_import**
  525. There MUST be group use for the same namespaces.
  526. * **header_comment**
  527. Add, replace or remove header comment.
  528. Configuration options:
  529. - ``comment_type`` (``'comment'``, ``'PHPDoc'``): comment syntax type; defaults to
  530. ``'comment'``; DEPRECATED alias: ``commentType``
  531. - ``header`` (``string``): proper header content; required
  532. - ``location`` (``'after_declare_strict'``, ``'after_open'``): the location of the
  533. inserted header; defaults to ``'after_declare_strict'``
  534. - ``separate`` (``'both'``, ``'bottom'``, ``'none'``, ``'top'``): whether the header should be
  535. separated from the file content with a new line; defaults to ``'both'``
  536. * **heredoc_indentation** [@PHP73Migration, @PHP74Migration, @PHP8Migration]
  537. Heredoc/nowdoc content must be properly indented. Requires PHP >= 7.3.
  538. Configuration options:
  539. - ``indentation`` (``'same_as_start'``, ``'start_plus_one'``): whether the indentation
  540. should be the same as in the start token line or one level more;
  541. defaults to ``'start_plus_one'``
  542. * **heredoc_to_nowdoc** [@PhpCsFixer]
  543. Convert ``heredoc`` to ``nowdoc`` where possible.
  544. * **implode_call** [@Symfony:risky, @PhpCsFixer:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  545. Function ``implode`` must be called with 2 arguments in the documented
  546. order.
  547. *Risky rule: risky when the function ``implode`` is overridden.*
  548. * **include** [@Symfony, @PhpCsFixer]
  549. Include/Require and file path should be divided with a single space.
  550. File path should not be placed under brackets.
  551. * **increment_style** [@Symfony, @PhpCsFixer]
  552. Pre- or post-increment and decrement operators should be used if
  553. possible.
  554. Configuration options:
  555. - ``style`` (``'post'``, ``'pre'``): whether to use pre- or post-increment and
  556. decrement operators; defaults to ``'pre'``
  557. * **indentation_type** [@PSR2, @Symfony, @PhpCsFixer]
  558. Code MUST use configured indentation type.
  559. * **is_null** [@Symfony:risky, @PhpCsFixer:risky]
  560. Replaces ``is_null($var)`` expression with ``null === $var``.
  561. *Risky rule: risky when the function ``is_null`` is overridden.*
  562. * **lambda_not_used_import** [@Symfony, @PhpCsFixer]
  563. Lambda must not import variables it doesn't use.
  564. * **line_ending** [@PSR2, @Symfony, @PhpCsFixer]
  565. All PHP files must use same line ending.
  566. * **linebreak_after_opening_tag** [@Symfony, @PhpCsFixer]
  567. Ensure there is no code on the same line as the PHP open tag.
  568. * **list_syntax**
  569. List (``array`` destructuring) assignment should be declared using the
  570. configured syntax. Requires PHP >= 7.1.
  571. Configuration options:
  572. - ``syntax`` (``'long'``, ``'short'``): whether to use the ``long`` or ``short`` ``list``
  573. syntax; defaults to ``'long'``
  574. * **logical_operators** [@Symfony:risky, @PhpCsFixer:risky]
  575. Use ``&&`` and ``||`` logical operators instead of ``and`` and ``or``.
  576. *Risky rule: risky, because you must double-check if using and/or with lower precedence was intentional.*
  577. * **lowercase_cast** [@Symfony, @PhpCsFixer]
  578. Cast should be written in lower case.
  579. * **lowercase_keywords** [@PSR2, @Symfony, @PhpCsFixer]
  580. PHP keywords MUST be in lower case.
  581. * **lowercase_static_reference** [@Symfony, @PhpCsFixer]
  582. Class static references ``self``, ``static`` and ``parent`` MUST be in lower
  583. case.
  584. * **magic_constant_casing** [@Symfony, @PhpCsFixer]
  585. Magic constants should be referred to using the correct casing.
  586. * **magic_method_casing** [@Symfony, @PhpCsFixer]
  587. Magic method definitions and calls must be using the correct casing.
  588. * **mb_str_functions**
  589. Replace non multibyte-safe functions with corresponding mb function.
  590. *Risky rule: risky when any of the functions are overridden.*
  591. * **method_argument_space** [@PSR2, @Symfony, @PhpCsFixer]
  592. In method arguments and method call, there MUST NOT be a space before
  593. each comma and there MUST be one space after each comma. Argument lists
  594. MAY be split across multiple lines, where each subsequent line is
  595. indented once. When doing so, the first item in the list MUST be on the
  596. next line, and there MUST be only one argument per line.
  597. Configuration options:
  598. - ``after_heredoc`` (``bool``): whether the whitespace between heredoc end and
  599. comma should be removed; defaults to ``false``
  600. - ``ensure_fully_multiline`` (``bool``): ensure every argument of a multiline
  601. argument list is on its own line; defaults to ``false``. DEPRECATED: use
  602. option ``on_multiline`` instead
  603. - ``keep_multiple_spaces_after_comma`` (``bool``): whether keep multiple spaces
  604. after comma; defaults to ``false``
  605. - ``on_multiline`` (``'ensure_fully_multiline'``, ``'ensure_single_line'``, ``'ignore'``):
  606. defines how to handle function arguments lists that contain newlines;
  607. defaults to ``'ensure_fully_multiline'``
  608. * **method_chaining_indentation** [@PhpCsFixer]
  609. Method chaining MUST be properly indented. Method chaining with
  610. different levels of indentation is not supported.
  611. * **modernize_types_casting** [@Symfony:risky, @PhpCsFixer:risky]
  612. Replaces ``intval``, ``floatval``, ``doubleval``, ``strval`` and ``boolval``
  613. function calls with according type casting operator.
  614. *Risky rule: risky if any of the functions ``intval``, ``floatval``, ``doubleval``, ``strval`` or ``boolval`` are overridden.*
  615. * **multiline_comment_opening_closing** [@PhpCsFixer]
  616. DocBlocks must start with two asterisks, multiline comments must start
  617. with a single asterisk, after the opening slash. Both must end with a
  618. single asterisk before the closing slash.
  619. * **multiline_whitespace_before_semicolons** [@PhpCsFixer]
  620. Forbid multi-line whitespace before the closing semicolon or move the
  621. semicolon to the new line for chained calls.
  622. Configuration options:
  623. - ``strategy`` (``'new_line_for_chained_calls'``, ``'no_multi_line'``): forbid
  624. multi-line whitespace or move the semicolon to the new line for chained
  625. calls; defaults to ``'no_multi_line'``
  626. * **native_constant_invocation** [@Symfony:risky, @PhpCsFixer:risky]
  627. Add leading ``\`` before constant invocation of internal constant to speed
  628. up resolving. Constant name match is case-sensitive, except for ``null``,
  629. ``false`` and ``true``.
  630. *Risky rule: risky when any of the constants are namespaced or overridden.*
  631. Configuration options:
  632. - ``exclude`` (``array``): list of constants to ignore; defaults to ``['null',
  633. 'false', 'true']``
  634. - ``fix_built_in`` (``bool``): whether to fix constants returned by
  635. ``get_defined_constants``. User constants are not accounted in this list
  636. and must be specified in the include one; defaults to ``true``
  637. - ``include`` (``array``): list of additional constants to fix; defaults to ``[]``
  638. - ``scope`` (``'all'``, ``'namespaced'``): only fix constant invocations that are made
  639. within a namespace or fix all; defaults to ``'all'``
  640. - ``strict`` (``bool``): whether leading ``\`` of constant invocation not meant to
  641. have it should be removed; defaults to ``false``
  642. * **native_function_casing** [@Symfony, @PhpCsFixer]
  643. Function defined by PHP should be called using the correct casing.
  644. * **native_function_invocation** [@Symfony:risky, @PhpCsFixer:risky]
  645. Add leading ``\`` before function invocation to speed up resolving.
  646. *Risky rule: risky when any of the functions are overridden.*
  647. Configuration options:
  648. - ``exclude`` (``array``): list of functions to ignore; defaults to ``[]``
  649. - ``include`` (``array``): list of function names or sets to fix. Defined sets are
  650. ``@internal`` (all native functions), ``@all`` (all global functions) and
  651. ``@compiler_optimized`` (functions that are specially optimized by Zend);
  652. defaults to ``['@compiler_optimized']``
  653. - ``scope`` (``'all'``, ``'namespaced'``): only fix function calls that are made
  654. within a namespace or fix all; defaults to ``'all'``
  655. - ``strict`` (``bool``): whether leading ``\`` of function call not meant to have it
  656. should be removed; defaults to ``false``
  657. * **native_function_type_declaration_casing** [@Symfony, @PhpCsFixer]
  658. Native type hints for functions should use the correct case.
  659. * **new_with_braces** [@Symfony, @PhpCsFixer]
  660. All instances created with new keyword must be followed by braces.
  661. * **no_alias_functions** [@Symfony:risky, @PhpCsFixer:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  662. Master functions shall be used instead of aliases.
  663. *Risky rule: risky when any of the alias functions are overridden.*
  664. Configuration options:
  665. - ``sets`` (a subset of ``['@internal', '@IMAP', '@mbreg', '@all', '@time',
  666. '@exif']``): list of sets to fix. Defined sets are ``@internal`` (native
  667. functions), ``@IMAP`` (IMAP functions), ``@mbreg`` (from ``ext-mbstring``)
  668. ``@all`` (all listed sets); defaults to ``['@internal', '@IMAP']``
  669. * **no_alias_language_construct_call** [@Symfony, @PhpCsFixer]
  670. Master language constructs shall be used instead of aliases.
  671. * **no_alternative_syntax** [@Symfony, @PhpCsFixer]
  672. Replace control structure alternative syntax to use braces.
  673. * **no_binary_string** [@Symfony, @PhpCsFixer]
  674. There should not be a binary flag before strings.
  675. * **no_blank_lines_after_class_opening** [@Symfony, @PhpCsFixer]
  676. There should be no empty lines after class opening brace.
  677. * **no_blank_lines_after_phpdoc** [@Symfony, @PhpCsFixer]
  678. There should not be blank lines between docblock and the documented
  679. element.
  680. * **no_blank_lines_before_namespace**
  681. There should be no blank lines before a namespace declaration.
  682. * **no_break_comment** [@PSR2, @Symfony, @PhpCsFixer]
  683. There must be a comment when fall-through is intentional in a non-empty
  684. case body.
  685. Configuration options:
  686. - ``comment_text`` (``string``): the text to use in the added comment and to
  687. detect it; defaults to ``'no break'``
  688. * **no_closing_tag** [@PSR2, @Symfony, @PhpCsFixer]
  689. The closing ``?>`` tag MUST be omitted from files containing only PHP.
  690. * **no_empty_comment** [@Symfony, @PhpCsFixer]
  691. There should not be any empty comments.
  692. * **no_empty_phpdoc** [@Symfony, @PhpCsFixer]
  693. There should not be empty PHPDoc blocks.
  694. * **no_empty_statement** [@Symfony, @PhpCsFixer]
  695. Remove useless semicolon statements.
  696. * **no_extra_blank_lines** [@Symfony, @PhpCsFixer]
  697. Removes extra blank lines and/or blank lines following configuration.
  698. Configuration options:
  699. - ``tokens`` (a subset of ``['break', 'case', 'continue', 'curly_brace_block',
  700. 'default', 'extra', 'parenthesis_brace_block', 'return',
  701. 'square_brace_block', 'switch', 'throw', 'use', 'use_trait']``): list of
  702. tokens to fix; defaults to ``['extra']``
  703. * **no_homoglyph_names** [@Symfony:risky, @PhpCsFixer:risky]
  704. Replace accidental usage of homoglyphs (non ascii characters) in names.
  705. *Risky rule: renames classes and cannot rename the files. You might have string references to renamed code (``$$name``).*
  706. * **no_leading_import_slash** [@Symfony, @PhpCsFixer]
  707. Remove leading slashes in ``use`` clauses.
  708. * **no_leading_namespace_whitespace** [@Symfony, @PhpCsFixer]
  709. The namespace declaration line shouldn't contain leading whitespace.
  710. * **no_mixed_echo_print** [@Symfony, @PhpCsFixer]
  711. Either language construct ``print`` or ``echo`` should be used.
  712. Configuration options:
  713. - ``use`` (``'echo'``, ``'print'``): the desired language construct; defaults to
  714. ``'echo'``
  715. * **no_multiline_whitespace_around_double_arrow** [@Symfony, @PhpCsFixer]
  716. Operator ``=>`` should not be surrounded by multi-line whitespaces.
  717. * **no_null_property_initialization** [@PhpCsFixer]
  718. Properties MUST not be explicitly initialized with ``null`` except when
  719. they have a type declaration (PHP 7.4).
  720. * **no_php4_constructor** [@Symfony:risky, @PhpCsFixer:risky]
  721. Convert PHP4-style constructors to ``__construct``.
  722. *Risky rule: risky when old style constructor being fixed is overridden or overrides parent one.*
  723. * **no_short_bool_cast** [@Symfony, @PhpCsFixer]
  724. Short cast ``bool`` using double exclamation mark should not be used.
  725. * **no_singleline_whitespace_before_semicolons** [@Symfony, @PhpCsFixer]
  726. Single-line whitespace before closing semicolon are prohibited.
  727. * **no_spaces_after_function_name** [@PSR2, @Symfony, @PhpCsFixer]
  728. When making a method or function call, there MUST NOT be a space between
  729. the method or function name and the opening parenthesis.
  730. * **no_spaces_around_offset** [@Symfony, @PhpCsFixer]
  731. There MUST NOT be spaces around offset braces.
  732. Configuration options:
  733. - ``positions`` (a subset of ``['inside', 'outside']``): whether spacing should be
  734. fixed inside and/or outside the offset braces; defaults to ``['inside',
  735. 'outside']``
  736. * **no_spaces_inside_parenthesis** [@PSR2, @Symfony, @PhpCsFixer]
  737. There MUST NOT be a space after the opening parenthesis. There MUST NOT
  738. be a space before the closing parenthesis.
  739. * **no_superfluous_elseif** [@PhpCsFixer]
  740. Replaces superfluous ``elseif`` with ``if``.
  741. * **no_superfluous_phpdoc_tags** [@Symfony, @PhpCsFixer]
  742. Removes ``@param``, ``@return`` and ``@var`` tags that don't provide any
  743. useful information.
  744. Configuration options:
  745. - ``allow_mixed`` (``bool``): whether type ``mixed`` without description is allowed
  746. (``true``) or considered superfluous (``false``); defaults to ``false``
  747. - ``allow_unused_params`` (``bool``): whether ``param`` annotation without actual
  748. signature is allowed (``true``) or considered superfluous (``false``);
  749. defaults to ``false``
  750. - ``remove_inheritdoc`` (``bool``): remove ``@inheritDoc`` tags; defaults to ``false``
  751. * **no_trailing_comma_in_list_call** [@Symfony, @PhpCsFixer]
  752. Remove trailing commas in list function calls.
  753. * **no_trailing_comma_in_singleline_array** [@Symfony, @PhpCsFixer]
  754. PHP single-line arrays should not have trailing comma.
  755. * **no_trailing_whitespace** [@PSR2, @Symfony, @PhpCsFixer]
  756. Remove trailing whitespace at the end of non-blank lines.
  757. * **no_trailing_whitespace_in_comment** [@PSR2, @Symfony, @PhpCsFixer]
  758. There MUST be no trailing spaces inside comment or PHPDoc.
  759. * **no_trailing_whitespace_in_string** [@Symfony:risky, @PhpCsFixer:risky]
  760. There must be no trailing whitespace in strings.
  761. *Risky rule: changing the whitespaces in strings might affect string comparisons and outputs.*
  762. * **no_unneeded_control_parentheses** [@Symfony, @PhpCsFixer]
  763. Removes unneeded parentheses around control statements.
  764. Configuration options:
  765. - ``statements`` (``array``): list of control statements to fix; defaults to
  766. ``['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case',
  767. 'yield']``
  768. * **no_unneeded_curly_braces** [@Symfony, @PhpCsFixer]
  769. Removes unneeded curly braces that are superfluous and aren't part of a
  770. control structure's body.
  771. Configuration options:
  772. - ``namespaces`` (``bool``): remove unneeded curly braces from bracketed
  773. namespaces; defaults to ``false``
  774. * **no_unneeded_final_method** [@Symfony:risky, @PhpCsFixer:risky, @PHP8Migration:risky]
  775. A ``final`` class must not have ``final`` methods and ``private`` methods must
  776. not be ``final``.
  777. *Risky rule: risky when child class overrides a ``private`` method.*
  778. Configuration options:
  779. - ``private_methods`` (``bool``): private methods of non-``final`` classes must not
  780. be declared ``final``; defaults to ``true``
  781. * **no_unreachable_default_argument_value** [@PhpCsFixer:risky]
  782. In function arguments there must not be arguments with default values
  783. before non-default ones.
  784. *Risky rule: modifies the signature of functions; therefore risky when using systems (such as some Symfony components) that rely on those (for example through reflection).*
  785. * **no_unset_cast** [@Symfony, @PhpCsFixer, @PHP8Migration]
  786. Variables must be set ``null`` instead of using ``(unset)`` casting.
  787. * **no_unset_on_property** [@PhpCsFixer:risky]
  788. Properties should be set to ``null`` instead of using ``unset``.
  789. *Risky rule: risky when relying on attributes to be removed using ``unset`` rather than be set to ``null``. Changing variables to ``null`` instead of unsetting means these still show up when looping over class variables and reference properties remain unbroken. With PHP 7.4, this rule might introduce ``null`` assignments to properties whose type declaration does not allow it.*
  790. * **no_unused_imports** [@Symfony, @PhpCsFixer]
  791. Unused ``use`` statements must be removed.
  792. * **no_useless_else** [@PhpCsFixer]
  793. There should not be useless ``else`` cases.
  794. * **no_useless_return** [@PhpCsFixer]
  795. There should not be an empty ``return`` statement at the end of a
  796. function.
  797. * **no_whitespace_before_comma_in_array** [@Symfony, @PhpCsFixer]
  798. In array declaration, there MUST NOT be a whitespace before each comma.
  799. Configuration options:
  800. - ``after_heredoc`` (``bool``): whether the whitespace between heredoc end and
  801. comma should be removed; defaults to ``false``
  802. * **no_whitespace_in_blank_line** [@Symfony, @PhpCsFixer]
  803. Remove trailing whitespace at the end of blank lines.
  804. * **non_printable_character** [@Symfony:risky, @PhpCsFixer:risky, @PHP70Migration:risky, @PHP71Migration:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  805. Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other
  806. invisible unicode symbols.
  807. *Risky rule: risky when strings contain intended invisible characters.*
  808. Configuration options:
  809. - ``use_escape_sequences_in_strings`` (``bool``): whether characters should be
  810. replaced with escape sequences in strings; defaults to ``false``
  811. * **normalize_index_brace** [@Symfony, @PhpCsFixer, @PHP74Migration, @PHP8Migration]
  812. Array index should always be written by using square braces.
  813. * **not_operator_with_space**
  814. Logical NOT operators (``!``) should have leading and trailing
  815. whitespaces.
  816. * **not_operator_with_successor_space**
  817. Logical NOT operators (``!``) should have one trailing whitespace.
  818. * **nullable_type_declaration_for_default_null_value**
  819. Adds or removes ``?`` before type declarations for parameters with a
  820. default ``null`` value.
  821. Configuration options:
  822. - ``use_nullable_type_declaration`` (``bool``): whether to add or remove ``?``
  823. before type declarations for parameters with a default ``null`` value;
  824. defaults to ``true``
  825. * **object_operator_without_whitespace** [@Symfony, @PhpCsFixer]
  826. There should not be space before or after object ``T_OBJECT_OPERATOR``
  827. ``->``.
  828. * **operator_linebreak** [@PhpCsFixer]
  829. Operators - when multiline - must always be at the beginning or at the
  830. end of the line.
  831. Configuration options:
  832. - ``only_booleans`` (``bool``): whether to limit operators to only boolean ones;
  833. defaults to ``false``
  834. - ``position`` (``'beginning'``, ``'end'``): whether to place operators at the
  835. beginning or at the end of the line; defaults to ``'beginning'``
  836. * **ordered_class_elements** [@PhpCsFixer]
  837. Orders the elements of classes/interfaces/traits.
  838. Configuration options:
  839. - ``order`` (a subset of ``['use_trait', 'public', 'protected', 'private',
  840. 'constant', 'constant_public', 'constant_protected',
  841. 'constant_private', 'property', 'property_static', 'property_public',
  842. 'property_protected', 'property_private', 'property_public_static',
  843. 'property_protected_static', 'property_private_static', 'method',
  844. 'method_abstract', 'method_static', 'method_public',
  845. 'method_protected', 'method_private', 'method_public_abstract',
  846. 'method_protected_abstract', 'method_public_abstract_static',
  847. 'method_protected_abstract_static', 'method_public_static',
  848. 'method_protected_static', 'method_private_static', 'construct',
  849. 'destruct', 'magic', 'phpunit']``): list of strings defining order of
  850. elements; defaults to ``['use_trait', 'constant_public',
  851. 'constant_protected', 'constant_private', 'property_public',
  852. 'property_protected', 'property_private', 'construct', 'destruct',
  853. 'magic', 'phpunit', 'method_public', 'method_protected',
  854. 'method_private']``
  855. - ``sort_algorithm`` (``'alpha'``, ``'none'``): how multiple occurrences of same type
  856. statements should be sorted; defaults to ``'none'``; DEPRECATED alias:
  857. ``sortAlgorithm``
  858. * **ordered_imports** [@Symfony, @PhpCsFixer]
  859. Ordering ``use`` statements.
  860. Configuration options:
  861. - ``imports_order`` (``array``, ``null``): defines the order of import types; defaults
  862. to ``null``; DEPRECATED alias: ``importsOrder``
  863. - ``sort_algorithm`` (``'alpha'``, ``'length'``, ``'none'``): whether the statements
  864. should be sorted alphabetically or by length, or not sorted; defaults
  865. to ``'alpha'``; DEPRECATED alias: ``sortAlgorithm``
  866. * **ordered_interfaces**
  867. Orders the interfaces in an ``implements`` or ``interface extends`` clause.
  868. *Risky rule: risky for ``implements`` when specifying both an interface and its parent interface, because PHP doesn't break on ``parent, child`` but does on ``child, parent``.*
  869. Configuration options:
  870. - ``direction`` (``'ascend'``, ``'descend'``): which direction the interfaces should
  871. be ordered; defaults to ``'ascend'``
  872. - ``order`` (``'alpha'``, ``'length'``): how the interfaces should be ordered;
  873. defaults to ``'alpha'``
  874. * **ordered_traits** [@Symfony, @PhpCsFixer]
  875. Trait ``use`` statements must be sorted alphabetically.
  876. * **php_unit_construct** [@Symfony:risky, @PhpCsFixer:risky]
  877. PHPUnit assertion method calls like ``->assertSame(true, $foo)`` should be
  878. written with dedicated method like ``->assertTrue($foo)``.
  879. *Risky rule: fixer could be risky if one is overriding PHPUnit's native methods.*
  880. Configuration options:
  881. - ``assertions`` (a subset of ``['assertSame', 'assertEquals',
  882. 'assertNotEquals', 'assertNotSame']``): list of assertion methods to fix;
  883. defaults to ``['assertEquals', 'assertSame', 'assertNotEquals',
  884. 'assertNotSame']``
  885. * **php_unit_dedicate_assert** [@PHPUnit30Migration:risky, @PHPUnit32Migration:risky, @PHPUnit35Migration:risky, @PHPUnit43Migration:risky, @PHPUnit48Migration:risky, @PHPUnit50Migration:risky, @PHPUnit52Migration:risky, @PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky, @PHPUnit75Migration:risky, @PHPUnit84Migration:risky]
  886. PHPUnit assertions like ``assertInternalType``, ``assertFileExists``, should
  887. be used over ``assertTrue``.
  888. *Risky rule: fixer could be risky if one is overriding PHPUnit's native methods.*
  889. Configuration options:
  890. - ``target`` (``'3.0'``, ``'3.5'``, ``'5.0'``, ``'5.6'``, ``'newest'``): target version of
  891. PHPUnit; defaults to ``'newest'``
  892. * **php_unit_dedicate_assert_internal_type** [@PHPUnit75Migration:risky, @PHPUnit84Migration:risky]
  893. PHPUnit assertions like ``assertIsArray`` should be used over
  894. ``assertInternalType``.
  895. *Risky rule: risky when PHPUnit methods are overridden or when project has PHPUnit incompatibilities.*
  896. Configuration options:
  897. - ``target`` (``'7.5'``, ``'newest'``): target version of PHPUnit; defaults to
  898. ``'newest'``. DEPRECATED: option was not used
  899. * **php_unit_expectation** [@PHPUnit52Migration:risky, @PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky, @PHPUnit75Migration:risky, @PHPUnit84Migration:risky]
  900. Usages of ``->setExpectedException*`` methods MUST be replaced by
  901. ``->expectException*`` methods.
  902. *Risky rule: risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.*
  903. Configuration options:
  904. - ``target`` (``'5.2'``, ``'5.6'``, ``'8.4'``, ``'newest'``): target version of PHPUnit;
  905. defaults to ``'newest'``
  906. * **php_unit_fqcn_annotation** [@Symfony, @PhpCsFixer]
  907. PHPUnit annotations should be a FQCNs including a root namespace.
  908. * **php_unit_internal_class** [@PhpCsFixer]
  909. All PHPUnit test classes should be marked as internal.
  910. Configuration options:
  911. - ``types`` (a subset of ``['normal', 'final', 'abstract']``): what types of
  912. classes to mark as internal; defaults to ``['normal', 'final']``
  913. * **php_unit_method_casing** [@Symfony, @PhpCsFixer]
  914. Enforce camel (or snake) case for PHPUnit test methods, following
  915. configuration.
  916. Configuration options:
  917. - ``case`` (``'camel_case'``, ``'snake_case'``): apply camel or snake case to test
  918. methods; defaults to ``'camel_case'``
  919. * **php_unit_mock** [@PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky, @PHPUnit75Migration:risky, @PHPUnit84Migration:risky]
  920. Usages of ``->getMock`` and
  921. ``->getMockWithoutInvokingTheOriginalConstructor`` methods MUST be
  922. replaced by ``->createMock`` or ``->createPartialMock`` methods.
  923. *Risky rule: risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.*
  924. Configuration options:
  925. - ``target`` (``'5.4'``, ``'5.5'``, ``'newest'``): target version of PHPUnit; defaults to
  926. ``'newest'``
  927. * **php_unit_mock_short_will_return** [@Symfony:risky, @PhpCsFixer:risky]
  928. Usage of PHPUnit's mock e.g. ``->will($this->returnValue(..))`` must be
  929. replaced by its shorter equivalent such as ``->willReturn(...)``.
  930. *Risky rule: risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.*
  931. * **php_unit_namespaced** [@PHPUnit48Migration:risky, @PHPUnit50Migration:risky, @PHPUnit52Migration:risky, @PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky, @PHPUnit75Migration:risky, @PHPUnit84Migration:risky]
  932. PHPUnit classes MUST be used in namespaced version, e.g.
  933. ``\PHPUnit\Framework\TestCase`` instead of ``\PHPUnit_Framework_TestCase``.
  934. *Risky rule: risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.*
  935. Configuration options:
  936. - ``target`` (``'4.8'``, ``'5.7'``, ``'6.0'``, ``'newest'``): target version of PHPUnit;
  937. defaults to ``'newest'``
  938. * **php_unit_no_expectation_annotation** [@PHPUnit32Migration:risky, @PHPUnit35Migration:risky, @PHPUnit43Migration:risky, @PHPUnit48Migration:risky, @PHPUnit50Migration:risky, @PHPUnit52Migration:risky, @PHPUnit54Migration:risky, @PHPUnit55Migration:risky, @PHPUnit56Migration:risky, @PHPUnit57Migration:risky, @PHPUnit60Migration:risky, @PHPUnit75Migration:risky, @PHPUnit84Migration:risky]
  939. Usages of ``@expectedException*`` annotations MUST be replaced by
  940. ``->setExpectedException*`` methods.
  941. *Risky rule: risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.*
  942. Configuration options:
  943. - ``target`` (``'3.2'``, ``'4.3'``, ``'newest'``): target version of PHPUnit; defaults to
  944. ``'newest'``
  945. - ``use_class_const`` (``bool``): use ::class notation; defaults to ``true``
  946. * **php_unit_set_up_tear_down_visibility** [@Symfony:risky, @PhpCsFixer:risky]
  947. Changes the visibility of the ``setUp()`` and ``tearDown()`` functions of
  948. PHPUnit to ``protected``, to match the PHPUnit TestCase.
  949. *Risky rule: this fixer may change functions named ``setUp()`` or ``tearDown()`` outside of PHPUnit tests, when a class is wrongly seen as a PHPUnit test.*
  950. * **php_unit_size_class**
  951. All PHPUnit test cases should have ``@small``, ``@medium`` or ``@large``
  952. annotation to enable run time limits.
  953. Configuration options:
  954. - ``group`` (``'large'``, ``'medium'``, ``'small'``): define a specific group to be used
  955. in case no group is already in use; defaults to ``'small'``
  956. * **php_unit_strict** [@PhpCsFixer:risky]
  957. PHPUnit methods like ``assertSame`` should be used instead of
  958. ``assertEquals``.
  959. *Risky rule: risky when any of the functions are overridden or when testing object equality.*
  960. Configuration options:
  961. - ``assertions`` (a subset of ``['assertAttributeEquals',
  962. 'assertAttributeNotEquals', 'assertEquals', 'assertNotEquals']``): list
  963. of assertion methods to fix; defaults to ``['assertAttributeEquals',
  964. 'assertAttributeNotEquals', 'assertEquals', 'assertNotEquals']``
  965. * **php_unit_test_annotation** [@Symfony:risky, @PhpCsFixer:risky]
  966. Adds or removes @test annotations from tests, following configuration.
  967. *Risky rule: this fixer may change the name of your tests, and could cause incompatibility with abstract classes or interfaces.*
  968. Configuration options:
  969. - ``style`` (``'annotation'``, ``'prefix'``): whether to use the @test annotation or
  970. not; defaults to ``'prefix'``
  971. * **php_unit_test_case_static_method_calls** [@PhpCsFixer:risky]
  972. Calls to ``PHPUnit\Framework\TestCase`` static methods must all be of the
  973. same type, either ``$this->``, ``self::`` or ``static::``.
  974. *Risky rule: risky when PHPUnit methods are overridden or not accessible, or when project has PHPUnit incompatibilities.*
  975. Configuration options:
  976. - ``call_type`` (``'self'``, ``'static'``, ``'this'``): the call type to use for referring
  977. to PHPUnit methods; defaults to ``'static'``
  978. - ``methods`` (``array``): dictionary of ``method`` => ``call_type`` values that
  979. differ from the default strategy; defaults to ``[]``
  980. * **php_unit_test_class_requires_covers** [@PhpCsFixer]
  981. Adds a default ``@coversNothing`` annotation to PHPUnit test classes that
  982. have no ``@covers*`` annotation.
  983. * **phpdoc_add_missing_param_annotation** [@PhpCsFixer]
  984. PHPDoc should contain ``@param`` for all params.
  985. Configuration options:
  986. - ``only_untyped`` (``bool``): whether to add missing ``@param`` annotations for
  987. untyped parameters only; defaults to ``true``
  988. * **phpdoc_align** [@Symfony, @PhpCsFixer]
  989. All items of the given phpdoc tags must be either left-aligned or (by
  990. default) aligned vertically.
  991. Configuration options:
  992. - ``align`` (``'left'``, ``'vertical'``): align comments; defaults to ``'vertical'``
  993. - ``tags`` (a subset of ``['param', 'property', 'property-read',
  994. 'property-write', 'return', 'throws', 'type', 'var', 'method']``): the
  995. tags that should be aligned; defaults to ``['method', 'param',
  996. 'property', 'return', 'throws', 'type', 'var']``
  997. * **phpdoc_annotation_without_dot** [@Symfony, @PhpCsFixer]
  998. PHPDoc annotation descriptions should not be a sentence.
  999. * **phpdoc_indent** [@Symfony, @PhpCsFixer]
  1000. Docblocks should have the same indentation as the documented subject.
  1001. * **phpdoc_inline_tag**
  1002. Fix PHPDoc inline tags, make ``@inheritdoc`` always inline. DEPRECATED:
  1003. use ``general_phpdoc_tag_rename``, ``phpdoc_inline_tag_normalizer`` and
  1004. ``phpdoc_tag_type`` instead.
  1005. * **phpdoc_inline_tag_normalizer** [@Symfony, @PhpCsFixer]
  1006. Fixes PHPDoc inline tags.
  1007. Configuration options:
  1008. - ``tags`` (``array``): the list of tags to normalize; defaults to ``['example',
  1009. 'id', 'internal', 'inheritdoc', 'inheritdocs', 'link', 'source', 'toc',
  1010. 'tutorial']``
  1011. * **phpdoc_line_span**
  1012. Changes doc blocks from single to multi line, or reversed. Works for
  1013. class constants, properties and methods only.
  1014. Configuration options:
  1015. - ``const`` (``'multi'``, ``'single'``): whether const blocks should be single or
  1016. multi line; defaults to ``'multi'``
  1017. - ``method`` (``'multi'``, ``'single'``): whether method doc blocks should be single
  1018. or multi line; defaults to ``'multi'``
  1019. - ``property`` (``'multi'``, ``'single'``): whether property doc blocks should be
  1020. single or multi line; defaults to ``'multi'``
  1021. * **phpdoc_no_access** [@Symfony, @PhpCsFixer]
  1022. ``@access`` annotations should be omitted from PHPDoc.
  1023. * **phpdoc_no_alias_tag** [@Symfony, @PhpCsFixer]
  1024. No alias PHPDoc tags should be used.
  1025. Configuration options:
  1026. - ``replacements`` (``array``): mapping between replaced annotations with new
  1027. ones; defaults to ``['property-read' => 'property', 'property-write' =>
  1028. 'property', 'type' => 'var', 'link' => 'see']``
  1029. * **phpdoc_no_empty_return** [@PhpCsFixer]
  1030. ``@return void`` and ``@return null`` annotations should be omitted from
  1031. PHPDoc.
  1032. * **phpdoc_no_package** [@Symfony, @PhpCsFixer]
  1033. ``@package`` and ``@subpackage`` annotations should be omitted from PHPDoc.
  1034. * **phpdoc_no_useless_inheritdoc** [@Symfony, @PhpCsFixer]
  1035. Classy that does not inherit must not have ``@inheritdoc`` tags.
  1036. * **phpdoc_order** [@PhpCsFixer]
  1037. Annotations in PHPDoc should be ordered so that ``@param`` annotations
  1038. come first, then ``@throws`` annotations, then ``@return`` annotations.
  1039. * **phpdoc_order_by_value** [@PhpCsFixer]
  1040. Order phpdoc tags by value.
  1041. Configuration options:
  1042. - ``annotations`` (a subset of ``['author', 'covers', 'coversNothing',
  1043. 'dataProvider', 'depends', 'group', 'internal', 'requires', 'uses']``):
  1044. list of annotations to order, e.g. ``["covers"]``; defaults to ``['covers']``
  1045. * **phpdoc_return_self_reference** [@Symfony, @PhpCsFixer]
  1046. The type of ``@return`` annotations of methods returning a reference to
  1047. itself must the configured one.
  1048. Configuration options:
  1049. - ``replacements`` (``array``): mapping between replaced return types with new
  1050. ones; defaults to ``['this' => '$this', '@this' => '$this', '$self' =>
  1051. 'self', '@self' => 'self', '$static' => 'static', '@static' =>
  1052. 'static']``
  1053. * **phpdoc_scalar** [@Symfony, @PhpCsFixer]
  1054. Scalar types should always be written in the same form. ``int`` not
  1055. ``integer``, ``bool`` not ``boolean``, ``float`` not ``real`` or ``double``.
  1056. Configuration options:
  1057. - ``types`` (a subset of ``['boolean', 'callback', 'double', 'integer', 'real',
  1058. 'str']``): a map of types to fix; defaults to ``['boolean', 'double',
  1059. 'integer', 'real', 'str']``
  1060. * **phpdoc_separation** [@Symfony, @PhpCsFixer]
  1061. Annotations in PHPDoc should be grouped together so that annotations of
  1062. the same type immediately follow each other, and annotations of a
  1063. different type are separated by a single blank line.
  1064. * **phpdoc_single_line_var_spacing** [@Symfony, @PhpCsFixer]
  1065. Single line ``@var`` PHPDoc should have proper spacing.
  1066. * **phpdoc_summary** [@Symfony, @PhpCsFixer]
  1067. PHPDoc summary should end in either a full stop, exclamation mark, or
  1068. question mark.
  1069. * **phpdoc_tag_casing**
  1070. Fixes casing of PHPDoc tags.
  1071. Configuration options:
  1072. - ``tags`` (``array``): list of tags to fix with their expected casing; defaults
  1073. to ``['inheritDoc']``
  1074. * **phpdoc_tag_type** [@Symfony, @PhpCsFixer]
  1075. Forces PHPDoc tags to be either regular annotations or inline.
  1076. Configuration options:
  1077. - ``tags`` (``array``): the list of tags to fix; defaults to ``['api' =>
  1078. 'annotation', 'author' => 'annotation', 'copyright' => 'annotation',
  1079. 'deprecated' => 'annotation', 'example' => 'annotation', 'global' =>
  1080. 'annotation', 'inheritDoc' => 'annotation', 'internal' => 'annotation',
  1081. 'license' => 'annotation', 'method' => 'annotation', 'package' =>
  1082. 'annotation', 'param' => 'annotation', 'property' => 'annotation',
  1083. 'return' => 'annotation', 'see' => 'annotation', 'since' =>
  1084. 'annotation', 'throws' => 'annotation', 'todo' => 'annotation', 'uses'
  1085. => 'annotation', 'var' => 'annotation', 'version' => 'annotation']``
  1086. * **phpdoc_to_comment** [@Symfony, @PhpCsFixer]
  1087. Docblocks should only be used on structural elements.
  1088. * **phpdoc_to_param_type**
  1089. EXPERIMENTAL: Takes ``@param`` annotations of non-mixed types and adjusts
  1090. accordingly the function signature. Requires PHP >= 7.0.
  1091. *Risky rule: this rule is EXPERIMENTAL and [1] is not covered with backward compatibility promise. [2] ``@param`` annotation is mandatory for the fixer to make changes, signatures of methods without it (no docblock, inheritdocs) will not be fixed. [3] Manual actions are required if inherited signatures are not properly documented.*
  1092. * **phpdoc_to_return_type**
  1093. EXPERIMENTAL: Takes ``@return`` annotation of non-mixed types and adjusts
  1094. accordingly the function signature. Requires PHP >= 7.0.
  1095. *Risky rule: this rule is EXPERIMENTAL and [1] is not covered with backward compatibility promise. [2] ``@return`` annotation is mandatory for the fixer to make changes, signatures of methods without it (no docblock, inheritdocs) will not be fixed. [3] Manual actions are required if inherited signatures are not properly documented. [4] ``@inheritdocs`` support is under construction.*
  1096. Configuration options:
  1097. - ``scalar_types`` (``bool``): fix also scalar types; may have unexpected
  1098. behaviour due to PHP bad type coercion system; defaults to ``true``
  1099. * **phpdoc_trim** [@Symfony, @PhpCsFixer]
  1100. PHPDoc should start and end with content, excluding the very first and
  1101. last line of the docblocks.
  1102. * **phpdoc_trim_consecutive_blank_line_separation** [@Symfony, @PhpCsFixer]
  1103. Removes extra blank lines after summary and after description in PHPDoc.
  1104. * **phpdoc_types** [@Symfony, @PhpCsFixer]
  1105. The correct case must be used for standard PHP types in PHPDoc.
  1106. Configuration options:
  1107. - ``groups`` (a subset of ``['simple', 'alias', 'meta']``): type groups to fix;
  1108. defaults to ``['simple', 'alias', 'meta']``
  1109. * **phpdoc_types_order** [@Symfony, @PhpCsFixer]
  1110. Sorts PHPDoc types.
  1111. Configuration options:
  1112. - ``null_adjustment`` (``'always_first'``, ``'always_last'``, ``'none'``): forces the
  1113. position of ``null`` (overrides ``sort_algorithm``); defaults to
  1114. ``'always_first'``
  1115. - ``sort_algorithm`` (``'alpha'``, ``'none'``): the sorting algorithm to apply;
  1116. defaults to ``'alpha'``
  1117. * **phpdoc_var_annotation_correct_order** [@PhpCsFixer]
  1118. ``@var`` and ``@type`` annotations must have type and name in the correct
  1119. order.
  1120. * **phpdoc_var_without_name** [@Symfony, @PhpCsFixer]
  1121. ``@var`` and ``@type`` annotations of classy properties should not contain
  1122. the name.
  1123. * **pow_to_exponentiation** [@Symfony:risky, @PhpCsFixer:risky, @PHP56Migration:risky, @PHP70Migration:risky, @PHP71Migration:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  1124. Converts ``pow`` to the ``**`` operator.
  1125. *Risky rule: risky when the function ``pow`` is overridden.*
  1126. * **protected_to_private** [@Symfony, @PhpCsFixer]
  1127. Converts ``protected`` variables and methods to ``private`` where possible.
  1128. * **psr0**
  1129. Classes must be in a path that matches their namespace, be at least one
  1130. namespace deep and the class name should match the file name.
  1131. DEPRECATED: use ``psr_autoloading`` instead.
  1132. *Risky rule: this fixer may change your class name, which will break the code that depends on the old name.*
  1133. Configuration options:
  1134. - ``dir`` (``string``): the directory where the project code is placed; defaults
  1135. to ``''``
  1136. * **psr4**
  1137. Class names should match the file name. DEPRECATED: use
  1138. ``psr_autoloading`` instead.
  1139. *Risky rule: this fixer may change your class name, which will break the code that depends on the old name.*
  1140. * **psr_autoloading** [@Symfony:risky, @PhpCsFixer:risky]
  1141. Classes must be in a path that matches their namespace, be at least one
  1142. namespace deep and the class name should match the file name.
  1143. *Risky rule: this fixer may change your class name, which will break the code that depends on the old name.*
  1144. Configuration options:
  1145. - ``dir`` (``null``, ``string``): if provided, the directory where the project code is
  1146. placed; defaults to ``null``
  1147. * **random_api_migration** [@PHP70Migration:risky, @PHP71Migration:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  1148. Replaces ``rand``, ``srand``, ``getrandmax`` functions calls with their ``mt_*``
  1149. analogs.
  1150. *Risky rule: risky when the configured functions are overridden.*
  1151. Configuration options:
  1152. - ``replacements`` (``array``): mapping between replaced functions with the new
  1153. ones; defaults to ``['getrandmax' => 'mt_getrandmax', 'rand' =>
  1154. 'mt_rand', 'srand' => 'mt_srand']``
  1155. * **regular_callable_call**
  1156. Callables must be called without using ``call_user_func*`` when possible.
  1157. *Risky rule: risky when the ``call_user_func`` or ``call_user_func_array`` function is overridden or when are used in constructions that should be avoided, like ``call_user_func_array('foo', ['bar' => 'baz'])`` or ``call_user_func($foo, $foo = 'bar')``.*
  1158. * **return_assignment** [@PhpCsFixer]
  1159. Local, dynamic and directly referenced variables should not be assigned
  1160. and directly returned by a function or method.
  1161. * **return_type_declaration** [@Symfony, @PhpCsFixer]
  1162. There should be one or no space before colon, and one space after it in
  1163. return type declarations, according to configuration.
  1164. Configuration options:
  1165. - ``space_before`` (``'none'``, ``'one'``): spacing to apply before colon; defaults to
  1166. ``'none'``
  1167. * **self_accessor** [@Symfony:risky, @PhpCsFixer:risky]
  1168. Inside class or interface element ``self`` should be preferred to the
  1169. class name itself.
  1170. *Risky rule: risky when using dynamic calls like get_called_class() or late static binding.*
  1171. * **self_static_accessor**
  1172. Inside a ``final`` class or anonymous class ``self`` should be preferred to
  1173. ``static``.
  1174. * **semicolon_after_instruction** [@Symfony, @PhpCsFixer]
  1175. Instructions must be terminated with a semicolon.
  1176. * **set_type_to_cast** [@Symfony:risky, @PhpCsFixer:risky]
  1177. Cast shall be used, not ``settype``.
  1178. *Risky rule: risky when the ``settype`` function is overridden or when used as the 2nd or 3rd expression in a ``for`` loop .*
  1179. * **short_scalar_cast** [@Symfony, @PhpCsFixer, @PHP74Migration]
  1180. Cast ``(boolean)`` and ``(integer)`` should be written as ``(bool)`` and
  1181. ``(int)``, ``(double)`` and ``(real)`` as ``(float)``, ``(binary)`` as
  1182. ``(string)``.
  1183. * **simple_to_complex_string_variable** [@PhpCsFixer]
  1184. Converts explicit variables in double-quoted strings and heredoc syntax
  1185. from simple to complex format (``${`` to ``{$``).
  1186. * **simplified_if_return**
  1187. Simplify ``if`` control structures that return the boolean result of their
  1188. condition.
  1189. * **simplified_null_return**
  1190. A return statement wishing to return ``void`` should not return ``null``.
  1191. * **single_blank_line_at_eof** [@PSR2, @Symfony, @PhpCsFixer]
  1192. A PHP file without end tag must always end with a single empty line
  1193. feed.
  1194. * **single_blank_line_before_namespace** [@Symfony, @PhpCsFixer]
  1195. There should be exactly one blank line before a namespace declaration.
  1196. * **single_class_element_per_statement** [@PSR2, @Symfony, @PhpCsFixer]
  1197. There MUST NOT be more than one property or constant declared per
  1198. statement.
  1199. Configuration options:
  1200. - ``elements`` (a subset of ``['const', 'property']``): list of strings which
  1201. element should be modified; defaults to ``['const', 'property']``
  1202. * **single_import_per_statement** [@PSR2, @Symfony, @PhpCsFixer]
  1203. There MUST be one use keyword per declaration.
  1204. * **single_line_after_imports** [@PSR2, @Symfony, @PhpCsFixer]
  1205. Each namespace use MUST go on its own line and there MUST be one blank
  1206. line after the use statements block.
  1207. * **single_line_comment_style** [@Symfony, @PhpCsFixer]
  1208. Single-line comments and multi-line comments with only one line of
  1209. actual content should use the ``//`` syntax.
  1210. Configuration options:
  1211. - ``comment_types`` (a subset of ``['asterisk', 'hash']``): list of comment types
  1212. to fix; defaults to ``['asterisk', 'hash']``
  1213. * **single_line_throw** [@Symfony]
  1214. Throwing exception must be done in single line.
  1215. * **single_quote** [@Symfony, @PhpCsFixer]
  1216. Convert double quotes to single quotes for simple strings.
  1217. Configuration options:
  1218. - ``strings_containing_single_quote_chars`` (``bool``): whether to fix
  1219. double-quoted strings that contains single-quotes; defaults to ``false``
  1220. * **single_trait_insert_per_statement** [@Symfony, @PhpCsFixer]
  1221. Each trait ``use`` must be done as single statement.
  1222. * **space_after_semicolon** [@Symfony, @PhpCsFixer]
  1223. Fix whitespace after a semicolon.
  1224. Configuration options:
  1225. - ``remove_in_empty_for_expressions`` (``bool``): whether spaces should be removed
  1226. for empty ``for`` expressions; defaults to ``false``
  1227. * **standardize_increment** [@Symfony, @PhpCsFixer]
  1228. Increment and decrement operators should be used if possible.
  1229. * **standardize_not_equals** [@Symfony, @PhpCsFixer]
  1230. Replace all ``<>`` with ``!=``.
  1231. * **static_lambda**
  1232. Lambdas not (indirect) referencing ``$this`` must be declared ``static``.
  1233. *Risky rule: risky when using ``->bindTo`` on lambdas without referencing to ``$this``.*
  1234. * **strict_comparison** [@PhpCsFixer:risky]
  1235. Comparisons should be strict.
  1236. *Risky rule: changing comparisons to strict might change code behavior.*
  1237. * **strict_param** [@PhpCsFixer:risky]
  1238. Functions should be used with ``$strict`` param set to ``true``.
  1239. *Risky rule: risky when the fixed function is overridden or if the code relies on non-strict usage.*
  1240. * **string_line_ending** [@Symfony:risky, @PhpCsFixer:risky]
  1241. All multi-line strings must use correct line ending.
  1242. *Risky rule: changing the line endings of multi-line strings might affect string comparisons and outputs.*
  1243. * **switch_case_semicolon_to_colon** [@PSR2, @Symfony, @PhpCsFixer]
  1244. A case should be followed by a colon and not a semicolon.
  1245. * **switch_case_space** [@PSR2, @Symfony, @PhpCsFixer]
  1246. Removes extra spaces between colon and case value.
  1247. * **switch_continue_to_break** [@Symfony, @PhpCsFixer, @PHP73Migration, @PHP74Migration, @PHP8Migration]
  1248. Switch case must not be ended with ``continue`` but with ``break``.
  1249. * **ternary_operator_spaces** [@Symfony, @PhpCsFixer]
  1250. Standardize spaces around ternary operator.
  1251. * **ternary_to_elvis_operator** [@Symfony:risky, @PhpCsFixer:risky]
  1252. Use the Elvis operator ``?:`` where possible.
  1253. *Risky rule: risky when relying on functions called on both sides of the ``?`` operator.*
  1254. * **ternary_to_null_coalescing** [@PHP70Migration, @PHP71Migration, @PHP73Migration, @PHP74Migration, @PHP8Migration]
  1255. Use ``null`` coalescing operator ``??`` where possible. Requires PHP >= 7.0.
  1256. * **trailing_comma_in_multiline_array** [@Symfony, @PhpCsFixer]
  1257. PHP multi-line arrays should have a trailing comma.
  1258. Configuration options:
  1259. - ``after_heredoc`` (``bool``): whether a trailing comma should also be placed
  1260. after heredoc end; defaults to ``false``
  1261. * **trim_array_spaces** [@Symfony, @PhpCsFixer]
  1262. Arrays should be formatted like function/method arguments, without
  1263. leading or trailing single line space.
  1264. * **unary_operator_spaces** [@Symfony, @PhpCsFixer]
  1265. Unary operators should be placed adjacent to their operands.
  1266. * **use_arrow_functions** [@PHP74Migration:risky]
  1267. Anonymous functions with one-liner return statement must use arrow
  1268. functions.
  1269. *Risky rule: risky when using ``isset()`` on outside variables that are not imported with ``use ()``.*
  1270. * **visibility_required** [@PSR2, @Symfony, @PhpCsFixer, @PHP71Migration, @PHP73Migration, @PHP74Migration, @PHP8Migration]
  1271. Visibility MUST be declared on all properties and methods; ``abstract``
  1272. and ``final`` MUST be declared before the visibility; ``static`` MUST be
  1273. declared after the visibility.
  1274. Configuration options:
  1275. - ``elements`` (a subset of ``['property', 'method', 'const']``): the structural
  1276. elements to fix (PHP >= 7.1 required for ``const``); defaults to
  1277. ``['property', 'method']``
  1278. * **void_return** [@PHP71Migration:risky, @PHP74Migration:risky, @PHP8Migration:risky]
  1279. Add ``void`` return type to functions with missing or empty return
  1280. statements, but priority is given to ``@return`` annotations. Requires
  1281. PHP >= 7.1.
  1282. *Risky rule: modifies the signature of functions.*
  1283. * **whitespace_after_comma_in_array** [@Symfony, @PhpCsFixer]
  1284. In array declaration, there MUST be a whitespace after each comma.
  1285. * **yoda_style** [@Symfony, @PhpCsFixer]
  1286. Write conditions in Yoda style (``true``), non-Yoda style (``false``) or
  1287. ignore those conditions (``null``) based on configuration.
  1288. Configuration options:
  1289. - ``always_move_variable`` (``bool``): whether variables should always be on non
  1290. assignable side when applying Yoda style; defaults to ``false``
  1291. - ``equal`` (``bool``, ``null``): style for equal (``==``, ``!=``) statements; defaults to
  1292. ``true``
  1293. - ``identical`` (``bool``, ``null``): style for identical (``===``, ``!==``) statements;
  1294. defaults to ``true``
  1295. - ``less_and_greater`` (``bool``, ``null``): style for less and greater than (``<``,
  1296. ``<=``, ``>``, ``>=``) statements; defaults to ``null``
  1297. The ``--dry-run`` option displays the files that need to be
  1298. fixed but without actually modifying them:
  1299. .. code-block:: bash
  1300. $ php php-cs-fixer.phar fix /path/to/code --dry-run
  1301. Config file
  1302. -----------
  1303. Instead of using command line options to customize the rule, you can save the
  1304. project configuration in a ``.php_cs.dist`` file in the root directory of your project.
  1305. The file must return an instance of `PhpCsFixer\\ConfigInterface <https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.16.4/src/ConfigInterface.php>`_
  1306. which lets you configure the rules, the files and directories that
  1307. need to be analyzed. You may also create ``.php_cs`` file, which is
  1308. the local configuration that will be used instead of the project configuration. It
  1309. is a good practice to add that file into your ``.gitignore`` file.
  1310. With the ``--config`` option you can specify the path to the
  1311. ``.php_cs`` file.
  1312. The example below will add two rules to the default list of PSR2 set rules:
  1313. .. code-block:: php
  1314. <?php
  1315. $finder = PhpCsFixer\Finder::create()
  1316. ->exclude('somedir')
  1317. ->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php')
  1318. ->in(__DIR__)
  1319. ;
  1320. return (new PhpCsFixer\Config())
  1321. ->setRules([
  1322. '@PSR2' => true,
  1323. 'strict_param' => true,
  1324. 'array_syntax' => ['syntax' => 'short'],
  1325. ])
  1326. ->setFinder($finder)
  1327. ;
  1328. **NOTE**: ``exclude`` will work only for directories, so if you need to exclude file, try ``notPath``.
  1329. Both ``exclude`` and ``notPath`` methods accept only relative paths to the ones defined with the ``in`` method.
  1330. See `Symfony\\Finder <https://symfony.com/doc/current/components/finder.html>`_
  1331. online documentation for other `Finder` methods.
  1332. You may also use an exclude list for the rules instead of the above shown include approach.
  1333. The following example shows how to use all ``Symfony`` rules but the ``full_opening_tag`` rule.
  1334. .. code-block:: php
  1335. <?php
  1336. $finder = PhpCsFixer\Finder::create()
  1337. ->exclude('somedir')
  1338. ->in(__DIR__)
  1339. ;
  1340. return (new PhpCsFixer\Config())
  1341. ->setRules([
  1342. '@Symfony' => true,
  1343. 'full_opening_tag' => false,
  1344. ])
  1345. ->setFinder($finder)
  1346. ;
  1347. You may want to use non-linux whitespaces in your project. Then you need to
  1348. configure them in your config file.
  1349. .. code-block:: php
  1350. <?php
  1351. return (new PhpCsFixer\Config())
  1352. ->setIndent("\t")
  1353. ->setLineEnding("\r\n")
  1354. ;
  1355. By using ``--using-cache`` option with ``yes`` or ``no`` you can set if the caching
  1356. mechanism should be used.
  1357. Caching
  1358. -------
  1359. The caching mechanism is enabled by default. This will speed up further runs by
  1360. fixing only files that were modified since the last run. The tool will fix all
  1361. files if the tool version has changed or the list of rules has changed.
  1362. Cache is supported only for tool downloaded as phar file or installed via
  1363. composer.
  1364. Cache can be disabled via ``--using-cache`` option or config file:
  1365. .. code-block:: php
  1366. <?php
  1367. return (new PhpCsFixer\Config())
  1368. ->setUsingCache(false)
  1369. ;
  1370. Cache file can be specified via ``--cache-file`` option or config file:
  1371. .. code-block:: php
  1372. <?php
  1373. return (new PhpCsFixer\Config())
  1374. ->setCacheFile(__DIR__.'/.php_cs.cache')
  1375. ;
  1376. Using PHP CS Fixer on CI
  1377. ------------------------
  1378. Require ``friendsofphp/php-cs-fixer`` as a ``dev`` dependency:
  1379. .. code-block:: bash
  1380. $ ./composer.phar require --dev friendsofphp/php-cs-fixer
  1381. Then, add the following command to your CI:
  1382. .. code-block:: bash
  1383. $ IFS='
  1384. $ '
  1385. $ CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}")
  1386. $ if ! echo "${CHANGED_FILES}" | grep -qE "^(\\.php_cs(\\.dist)?|composer\\.lock)$"; then EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}"); else EXTRA_ARGS=''; fi
  1387. $ vendor/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no ${EXTRA_ARGS}
  1388. Where ``$COMMIT_RANGE`` is your range of commits, e.g. ``$TRAVIS_COMMIT_RANGE`` or ``HEAD~..HEAD``.
  1389. Exit code
  1390. ---------
  1391. Exit code is built using following bit flags:
  1392. * 0 - OK.
  1393. * 1 - General error (or PHP minimal requirement not matched).
  1394. * 4 - Some files have invalid syntax (only in dry-run mode).
  1395. * 8 - Some files need fixing (only in dry-run mode).
  1396. * 16 - Configuration error of the application.
  1397. * 32 - Configuration error of a Fixer.
  1398. * 64 - Exception raised within the application.
  1399. (Applies to exit code of the ``fix`` command only)
  1400. Helpers
  1401. -------
  1402. Dedicated plugins exist for:
  1403. * `Atom`_
  1404. * `NetBeans`_
  1405. * `PhpStorm`_
  1406. * `Sublime Text`_
  1407. * `Vim`_
  1408. * `VS Code`_
  1409. Contribute
  1410. ----------
  1411. The tool comes with quite a few built-in fixers, but everyone is more than
  1412. welcome to `contribute`_ more of them.
  1413. Fixers
  1414. ~~~~~~
  1415. A *fixer* is a class that tries to fix one CS issue (a ``Fixer`` class must
  1416. implement ``FixerInterface``).
  1417. Configs
  1418. ~~~~~~~
  1419. A *config* knows about the CS rules and the files and directories that must be
  1420. scanned by the tool when run in the directory of your project. It is useful for
  1421. projects that follow a well-known directory structures (like for Symfony
  1422. projects for instance).
  1423. .. _php-cs-fixer.phar: https://cs.symfony.com/download/php-cs-fixer-v2.phar
  1424. .. _Atom: https://github.com/Glavin001/atom-beautify
  1425. .. _NetBeans: http://plugins.netbeans.org/plugin/49042/php-cs-fixer
  1426. .. _PhpStorm: https://medium.com/@valeryan/how-to-configure-phpstorm-to-use-php-cs-fixer-1844991e521f
  1427. .. _Sublime Text: https://github.com/benmatselby/sublime-phpcs
  1428. .. _Vim: https://github.com/stephpy/vim-php-cs-fixer
  1429. .. _VS Code: https://github.com/junstyle/vscode-php-cs-fixer
  1430. .. _contribute: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/CONTRIBUTING.md