header_comment.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. =======================
  2. Rule ``header_comment``
  3. =======================
  4. Add, replace or remove header comment.
  5. Configuration
  6. -------------
  7. ``header``
  8. ~~~~~~~~~~
  9. Proper header content.
  10. Allowed types: ``string``
  11. This option is required.
  12. ``comment_type``
  13. ~~~~~~~~~~~~~~~~
  14. Comment syntax type.
  15. Allowed values: ``'comment'``, ``'PHPDoc'``
  16. Default value: ``'comment'``
  17. ``location``
  18. ~~~~~~~~~~~~
  19. The location of the inserted header.
  20. Allowed values: ``'after_declare_strict'``, ``'after_open'``
  21. Default value: ``'after_declare_strict'``
  22. ``separate``
  23. ~~~~~~~~~~~~
  24. Whether the header should be separated from the file content with a new line.
  25. Allowed values: ``'both'``, ``'bottom'``, ``'none'``, ``'top'``
  26. Default value: ``'both'``
  27. Examples
  28. --------
  29. Example #1
  30. ~~~~~~~~~~
  31. With configuration: ``['header' => 'Made with love.']``.
  32. .. code-block:: diff
  33. --- Original
  34. +++ New
  35. @@ -1,6 +1,10 @@
  36. <?php
  37. declare(strict_types=1);
  38. +/*
  39. + * Made with love.
  40. + */
  41. +
  42. namespace A\B;
  43. echo 1;
  44. Example #2
  45. ~~~~~~~~~~
  46. With configuration: ``['header' => 'Made with love.', 'comment_type' => 'PHPDoc', 'location' => 'after_open', 'separate' => 'bottom']``.
  47. .. code-block:: diff
  48. --- Original
  49. +++ New
  50. @@ -1,4 +1,8 @@
  51. <?php
  52. +/**
  53. + * Made with love.
  54. + */
  55. +
  56. declare(strict_types=1);
  57. namespace A\B;
  58. Example #3
  59. ~~~~~~~~~~
  60. With configuration: ``['header' => 'Made with love.', 'comment_type' => 'comment', 'location' => 'after_declare_strict']``.
  61. .. code-block:: diff
  62. --- Original
  63. +++ New
  64. @@ -1,6 +1,10 @@
  65. <?php
  66. declare(strict_types=1);
  67. +/*
  68. + * Made with love.
  69. + */
  70. +
  71. namespace A\B;
  72. echo 1;