no_break_comment.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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-CS <./../../ruleSets/PER-CS.rst>`_
  56. - `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
  57. - `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
  58. - `@PSR2 <./../../ruleSets/PSR2.rst>`_
  59. - `@PSR12 <./../../ruleSets/PSR12.rst>`_
  60. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  61. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  62. References
  63. ----------
  64. - Fixer class: `PhpCsFixer\\Fixer\\ControlStructure\\NoBreakCommentFixer <./../../../src/Fixer/ControlStructure/NoBreakCommentFixer.php>`_
  65. - Test class: `PhpCsFixer\\Tests\\Fixer\\ControlStructure\\NoBreakCommentFixerTest <./../../../tests/Fixer/ControlStructure/NoBreakCommentFixerTest.php>`_
  66. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.