Fix compatibility with PHP 7.3/nightly#2086
Conversation
And I'm sure that's what I intended in all these cases. It's just lucky that there is no code after the switch in all of them. I know that using break here is the equivalent of what the code actually does, but it's not what the intention of the developer was. So I think using |
65eca84 to
16c771d
Compare
|
@gsherwood I've updated (amended) the PR to reflect your remark. Should be good to go. |
As of PHP 7.3, using `continue` to target a `switch` control structure will throw an `E_WARNING`. Applying `continue` to a `switch` is equivalent to using `break` and more often than not, a `continue` targeting a higher level control structure is actually intended. To target the higher level control structure, a numeric argument has to be passed to `continue`. Refs: * php/php-src#3364 * https://wiki.php.net/rfc/continue_on_switch_deprecation This change has been recently committed to PHP itself and will break the build against `nightly` for the current `master` already. See: https://travis-ci.org/jrfnl/PHP_CodeSniffer/jobs/401533444 (this branch, but without commits, so equal to the current `master`). This PR fixes the instances of this in PHPCS. All these switches are nested in other control structures, but end the switch end the scope closer of the outer control structure, so using `break` in these cases would be equivalent to using `continue 2`. FYI: The PHPCompatibility standard will include a sniff to detect this in the near future.
|
Thanks a lot for finding and fixing these. I think that PHPCompat sniff is going to come in handy. |
You're welcome ;-) The PR for the PHPCompatibility sniff has been opened: PHPCompatibility/PHPCompatibility#687 (in case other people are looking for it), |
On php:master there's no xdebug
As of PHP 7.3, using
continueto target aswitchcontrol structure will throw anE_WARNING.Applying
continueto aswitchis equivalent to usingbreakand more often than not, acontinuetargeting a higher level control structure is actually intended.To target the higher level control structure, a numeric argument has to be passed to
continue.Refs:
This change has been recently committed to PHP itself and will break the build against
nightlyfor the currentmasteralready.See: https://travis-ci.org/jrfnl/PHP_CodeSniffer/jobs/401533444 (this branch, but without commits, so equal to the current PHPCS
master).This PR fixes the instances of this in PHPCS so the build against
nightlywill pass again.Notes:
breakin these cases is equivalent to usingcontinue 2.FYI: The PHPCompatibility standard will include a sniff to detect this in the near future. This PR is the result of some tests I've been running on the WIP PHPCompatibility sniff 😉