phpdoc_align.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.
  11. Allowed values: a subset of ``['param', 'property', 'property-read', 'property-write', 'return', 'throws', 'type', 'var', 'method']``
  12. Default value: ``['param', 'return', 'throws', 'type', 'var']``
  13. ``align``
  14. ~~~~~~~~~
  15. Align comments
  16. Allowed values: ``'left'``, ``'vertical'``
  17. Default value: ``'vertical'``
  18. Examples
  19. --------
  20. Example #1
  21. ~~~~~~~~~~
  22. *Default* configuration.
  23. .. code-block:: diff
  24. --- Original
  25. +++ New
  26. @@ -1,8 +1,8 @@
  27. <?php
  28. /**
  29. - * @param EngineInterface $templating
  30. - * @param string $format
  31. - * @param int $code an HTTP response status code
  32. - * @param bool $debug
  33. - * @param mixed &$reference a parameter passed by reference
  34. + * @param EngineInterface $templating
  35. + * @param string $format
  36. + * @param int $code an HTTP response status code
  37. + * @param bool $debug
  38. + * @param mixed &$reference a parameter passed by reference
  39. */
  40. Example #2
  41. ~~~~~~~~~~
  42. With configuration: ``['align' => 'vertical']``.
  43. .. code-block:: diff
  44. --- Original
  45. +++ New
  46. @@ -1,8 +1,8 @@
  47. <?php
  48. /**
  49. - * @param EngineInterface $templating
  50. - * @param string $format
  51. - * @param int $code an HTTP response status code
  52. - * @param bool $debug
  53. - * @param mixed &$reference a parameter passed by reference
  54. + * @param EngineInterface $templating
  55. + * @param string $format
  56. + * @param int $code an HTTP response status code
  57. + * @param bool $debug
  58. + * @param mixed &$reference a parameter passed by reference
  59. */
  60. Example #3
  61. ~~~~~~~~~~
  62. With configuration: ``['align' => 'left']``.
  63. .. code-block:: diff
  64. --- Original
  65. +++ New
  66. @@ -1,8 +1,8 @@
  67. <?php
  68. /**
  69. - * @param EngineInterface $templating
  70. - * @param string $format
  71. - * @param int $code an HTTP response status code
  72. - * @param bool $debug
  73. - * @param mixed &$reference a parameter passed by reference
  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. */
  80. Rule sets
  81. ---------
  82. The rule is part of the following rule sets:
  83. @Symfony
  84. Using the ``@Symfony`` rule set will enable the ``phpdoc_align`` rule with the config below:
  85. ``['tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var']]``
  86. @PhpCsFixer
  87. Using the ``@PhpCsFixer`` rule set will enable the ``phpdoc_align`` rule with the config below:
  88. ``['tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var']]``