switch_continue_to_break.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. =================================
  2. Rule ``switch_continue_to_break``
  3. =================================
  4. Switch case must not be ended with ``continue`` but with ``break``.
  5. Examples
  6. --------
  7. Example #1
  8. ~~~~~~~~~~
  9. .. code-block:: diff
  10. --- Original
  11. +++ New
  12. <?php
  13. switch ($foo) {
  14. case 1:
  15. - continue;
  16. + break;
  17. }
  18. Example #2
  19. ~~~~~~~~~~
  20. .. code-block:: diff
  21. --- Original
  22. +++ New
  23. <?php
  24. switch ($foo) {
  25. case 1:
  26. while($bar) {
  27. do {
  28. - continue 3;
  29. + break 3;
  30. } while(false);
  31. if ($foo + 1 > 3) {
  32. continue;
  33. }
  34. - continue 2;
  35. + break 2;
  36. }
  37. }
  38. Rule sets
  39. ---------
  40. The rule is part of the following rule sets:
  41. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  42. - `@Symfony <./../../ruleSets/Symfony.rst>`_
  43. References
  44. ----------
  45. - Fixer class: `PhpCsFixer\\Fixer\\ControlStructure\\SwitchContinueToBreakFixer <./../../../src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php>`_
  46. - Test class: `PhpCsFixer\\Tests\\Fixer\\ControlStructure\\SwitchContinueToBreakFixerTest <./../../../tests/Fixer/ControlStructure/SwitchContinueToBreakFixerTest.php>`_
  47. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.