no_break_comment.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. =========================
  2. Rule ``no_break_comment``
  3. =========================
  4. There must be a comment when fall-through is intentional in a non-empty case
  5. body.
  6. Description
  7. -----------
  8. Adds a "no break" comment before fall-through cases, and removes it if there is
  9. no fall-through.
  10. Configuration
  11. -------------
  12. ``comment_text``
  13. ~~~~~~~~~~~~~~~~
  14. The text to use in the added comment and to detect it.
  15. Allowed types: ``string``
  16. Default value: ``'no break'``
  17. Examples
  18. --------
  19. Example #1
  20. ~~~~~~~~~~
  21. *Default* configuration.
  22. .. code-block:: diff
  23. --- Original
  24. +++ New
  25. <?php
  26. switch ($foo) {
  27. case 1:
  28. foo();
  29. + // no break
  30. case 2:
  31. bar();
  32. - // no break
  33. break;
  34. case 3:
  35. baz();
  36. }
  37. Example #2
  38. ~~~~~~~~~~
  39. With configuration: ``['comment_text' => 'some comment']``.
  40. .. code-block:: diff
  41. --- Original
  42. +++ New
  43. <?php
  44. switch ($foo) {
  45. case 1:
  46. foo();
  47. + // some comment
  48. case 2:
  49. foo();
  50. }
  51. Rule sets
  52. ---------
  53. The rule is part of the following rule sets:
  54. - `@PER <./../../ruleSets/PER.rst>`_
  55. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  56. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  57. - `@PSR2 <./../../ruleSets/PSR2.rst>`_
  58. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  59. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  60. - `@Symfony <./../../ruleSets/Symfony.rst>`_