Skip to content

SwitchContinueToBreakFixer - Introduction#4590

Merged
SpacePossum merged 1 commit intoPHP-CS-Fixer:masterfrom
SpacePossum:2_15_SwitchContinueToBreakFixer
Jan 28, 2020
Merged

SwitchContinueToBreakFixer - Introduction#4590
SpacePossum merged 1 commit intoPHP-CS-Fixer:masterfrom
SpacePossum:2_15_SwitchContinueToBreakFixer

Conversation

@SpacePossum
Copy link
Copy Markdown
Contributor

@SpacePossum SpacePossum commented Oct 12, 2019

Description of switch_continue_to_break rule.
Switch case must not be ended with continue but with break.

--- Original
+++ New
@@ -1,5 +1,5 @@
<?php
    switch ($foo) {
        case 1:
-           continue;
+           break;
    }
--- Original
+++ New
@@ -1,15 +1,15 @@
<?php
switch ($foo) {
    case 1:
        while($bar) {
            do {
-                continue 3;
+                break 3;
            } while(false);
            
            if ($foo + 1 > 3) {
                continue;
            }
            
-            continue 2;
+            break 2;
        }
}

@ see https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.continue-targeting-switch

https://wiki.php.net/rfc/continue_on_switch_deprecation

php/php-src#3364

@SpacePossum SpacePossum added this to the 2.16.0 milestone Oct 15, 2019
@keradus keradus modified the milestones: 2.16.0, 2.17.0 Nov 2, 2019
@SpacePossum SpacePossum added the RTM Ready To Merge label Jan 28, 2020
SpacePossum added a commit that referenced this pull request Jan 28, 2020
This PR was merged into the 2.17-dev branch.

Discussion
----------

SwitchContinueToBreakFixer - Introduction

Description of switch_continue_to_break rule.
Switch case must not be ended with `continue` but with `break`.

```diff
--- Original
+++ New
@@ -1,5 +1,5 @@
<?php
    switch ($foo) {
        case 1:
-           continue;
+           break;
    }
```

```diff
--- Original
+++ New
@@ -1,15 +1,15 @@
<?php
switch ($foo) {
    case 1:
        while($bar) {
            do {
-                continue 3;
+                break 3;
            } while(false);

            if ($foo + 1 > 3) {
                continue;
            }

-            continue 2;
+            break 2;
        }
}
```

@ see https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.continue-targeting-switch

https://wiki.php.net/rfc/continue_on_switch_deprecation

php/php-src#3364

Commits
-------

80f83b6 SwitchContinueToBreakFixer - Introduction
@SpacePossum SpacePossum merged commit 80f83b6 into PHP-CS-Fixer:master Jan 28, 2020
@SpacePossum SpacePossum removed the RTM Ready To Merge label Jan 28, 2020
@SpacePossum SpacePossum deleted the 2_15_SwitchContinueToBreakFixer branch January 28, 2020 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants