1.2.242. Continue Is For Loop¶
Since PHP 7.3, the execution emits a warning when finding a continue
inside a switch
: ‘”continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”?’
<?php
while ($foo) {
switch ($bar) {
case 'baz':
continue; // In PHP: Behaves like 'break;'
// In C: Behaves like 'continue 2;'
}
}
?>
See also Deprecate and remove continue targeting switch.
1.2.242.1. Suggestions¶
Replace continue by break
1.2.242.2. Specs¶
Short name |
Structures/ContinueIsForLoop |
Rulesets |
All, Analyze, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72, CompatibilityPHP73 |
Exakat since |
1.3.9 |
PHP Version |
With PHP 7.3 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Features |
continue, loop |
Examples |
|
Available in |