align_multiline_comment.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ================================
  2. Rule ``align_multiline_comment``
  3. ================================
  4. Each line of multi-line DocComments must have an asterisk [PSR-5] and must be
  5. aligned with the first one.
  6. Configuration
  7. -------------
  8. ``comment_type``
  9. ~~~~~~~~~~~~~~~~
  10. Whether to fix PHPDoc comments only (``phpdocs_only``), any multi-line comment
  11. whose lines all start with an asterisk (``phpdocs_like``) or any multi-line
  12. comment (``all_multiline``).
  13. Allowed values: ``'all_multiline'``, ``'phpdocs_like'`` and ``'phpdocs_only'``
  14. Default value: ``'phpdocs_only'``
  15. Examples
  16. --------
  17. Example #1
  18. ~~~~~~~~~~
  19. *Default* configuration.
  20. .. code-block:: diff
  21. --- Original
  22. +++ New
  23. <?php
  24. /**
  25. - * This is a DOC Comment
  26. -with a line not prefixed with asterisk
  27. -
  28. - */
  29. + * This is a DOC Comment
  30. + * with a line not prefixed with asterisk
  31. + *
  32. + */
  33. Example #2
  34. ~~~~~~~~~~
  35. With configuration: ``['comment_type' => 'phpdocs_like']``.
  36. .. code-block:: diff
  37. --- Original
  38. +++ New
  39. <?php
  40. /*
  41. - * This is a doc-like multiline comment
  42. -*/
  43. + * This is a doc-like multiline comment
  44. + */
  45. Example #3
  46. ~~~~~~~~~~
  47. With configuration: ``['comment_type' => 'all_multiline']``.
  48. .. code-block:: diff
  49. --- Original
  50. +++ New
  51. <?php
  52. /*
  53. - * This is a doc-like multiline comment
  54. + * This is a doc-like multiline comment
  55. with a line not prefixed with asterisk
  56. - */
  57. + */
  58. Rule sets
  59. ---------
  60. The rule is part of the following rule sets:
  61. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  62. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  63. References
  64. ----------
  65. - Fixer class: `PhpCsFixer\\Fixer\\Phpdoc\\AlignMultilineCommentFixer <./../../../src/Fixer/Phpdoc/AlignMultilineCommentFixer.php>`_
  66. - Test class: `PhpCsFixer\\Tests\\Fixer\\Phpdoc\\AlignMultilineCommentFixerTest <./../../../tests/Fixer/Phpdoc/AlignMultilineCommentFixerTest.php>`_
  67. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.