phpdoc_align.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. =====================
  2. Rule ``phpdoc_align``
  3. =====================
  4. All items of the given phpdoc tags must be either left-aligned or (by default)
  5. aligned vertically.
  6. Configuration
  7. -------------
  8. ``tags``
  9. ~~~~~~~~
  10. The tags that should be aligned. Allowed values are tags with name (``'param',
  11. 'property', 'property-read', 'property-write', 'phpstan-param',
  12. 'phpstan-property', 'phpstan-property-read', 'phpstan-property-write',
  13. 'phpstan-assert', 'phpstan-assert-if-true', 'phpstan-assert-if-false',
  14. 'psalm-param', 'psalm-param-out', 'psalm-property', 'psalm-property-read',
  15. 'psalm-property-write', 'psalm-assert', 'psalm-assert-if-true',
  16. 'psalm-assert-if-false'``), tags with method signature (``'method',
  17. 'phpstan-method', 'psalm-method'``) and any custom tag with description (e.g.
  18. ``@tag <desc>``).
  19. Allowed types: ``array``
  20. Default value: ``['method', 'param', 'property', 'return', 'throws', 'type', 'var']``
  21. ``align``
  22. ~~~~~~~~~
  23. How comments should be aligned.
  24. Allowed values: ``'left'`` and ``'vertical'``
  25. Default value: ``'vertical'``
  26. Examples
  27. --------
  28. Example #1
  29. ~~~~~~~~~~
  30. *Default* configuration.
  31. .. code-block:: diff
  32. --- Original
  33. +++ New
  34. <?php
  35. /**
  36. - * @param EngineInterface $templating
  37. - * @param string $format
  38. - * @param int $code an HTTP response status code
  39. - * @param bool $debug
  40. - * @param mixed &$reference a parameter passed by reference
  41. + * @param EngineInterface $templating
  42. + * @param string $format
  43. + * @param int $code an HTTP response status code
  44. + * @param bool $debug
  45. + * @param mixed &$reference a parameter passed by reference
  46. */
  47. Example #2
  48. ~~~~~~~~~~
  49. With configuration: ``['align' => 'vertical']``.
  50. .. code-block:: diff
  51. --- Original
  52. +++ New
  53. <?php
  54. /**
  55. - * @param EngineInterface $templating
  56. - * @param string $format
  57. - * @param int $code an HTTP response status code
  58. - * @param bool $debug
  59. - * @param mixed &$reference a parameter passed by reference
  60. + * @param EngineInterface $templating
  61. + * @param string $format
  62. + * @param int $code an HTTP response status code
  63. + * @param bool $debug
  64. + * @param mixed &$reference a parameter passed by reference
  65. */
  66. Example #3
  67. ~~~~~~~~~~
  68. With configuration: ``['align' => 'left']``.
  69. .. code-block:: diff
  70. --- Original
  71. +++ New
  72. <?php
  73. /**
  74. - * @param EngineInterface $templating
  75. - * @param string $format
  76. - * @param int $code an HTTP response status code
  77. - * @param bool $debug
  78. - * @param mixed &$reference a parameter passed by reference
  79. + * @param EngineInterface $templating
  80. + * @param string $format
  81. + * @param int $code an HTTP response status code
  82. + * @param bool $debug
  83. + * @param mixed &$reference a parameter passed by reference
  84. */
  85. Rule sets
  86. ---------
  87. The rule is part of the following rule sets:
  88. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  89. - `@Symfony <./../../ruleSets/Symfony.rst>`_