single_line_comment_style.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ==================================
  2. Rule ``single_line_comment_style``
  3. ==================================
  4. Single-line comments and multi-line comments with only one line of actual
  5. content should use the ``//`` syntax.
  6. Configuration
  7. -------------
  8. ``comment_types``
  9. ~~~~~~~~~~~~~~~~~
  10. List of comment types to fix.
  11. Allowed values: a subset of ``['asterisk', 'hash']``
  12. Default value: ``['asterisk', 'hash']``
  13. Examples
  14. --------
  15. Example #1
  16. ~~~~~~~~~~
  17. *Default* configuration.
  18. .. code-block:: diff
  19. --- Original
  20. +++ New
  21. <?php
  22. -/* asterisk comment */
  23. +// asterisk comment
  24. $a = 1;
  25. -# hash comment
  26. +// hash comment
  27. $b = 2;
  28. /*
  29. * multi-line
  30. * comment
  31. */
  32. $c = 3;
  33. Example #2
  34. ~~~~~~~~~~
  35. With configuration: ``['comment_types' => ['asterisk']]``.
  36. .. code-block:: diff
  37. --- Original
  38. +++ New
  39. <?php
  40. -/* first comment */
  41. +// first comment
  42. $a = 1;
  43. -/*
  44. - * second comment
  45. - */
  46. +// second comment
  47. $b = 2;
  48. /*
  49. * third
  50. * comment
  51. */
  52. $c = 3;
  53. Example #3
  54. ~~~~~~~~~~
  55. With configuration: ``['comment_types' => ['hash']]``.
  56. .. code-block:: diff
  57. --- Original
  58. +++ New
  59. -<?php # comment
  60. +<?php // comment
  61. Rule sets
  62. ---------
  63. The rule is part of the following rule sets:
  64. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  65. - `@Symfony <./../../ruleSets/Symfony.rst>`_ with config:
  66. ``['comment_types' => ['hash']]``