Repo Added
|
Files
173
|
Badge
Embed ▾
README BADGES
|
travis-ci
:sparkles: PHP 7.3: New `DiscouragedSwitchContinue` sniff As of PHP 7.3, using `continue` to target `switch` will start throwing an `E_WARNING`. > . "continue" statements targeting "switch" control flow structures will now > generate a warning. In PHP such "continue" statements are equivalent to > "break", while they behave as "continue 2" in other languages. Refs: * https://github.com/php/php-src/blob/<a class=hub.com/PHPCompatibility/PHPCompatibility/commit/04e3523b7d095341f65ed5e71a3cac82fca690e4">04e3523b7/UPGRADING#L47-L58 * https://github.com/php/php-src/commit/04e3523b7d095341f65ed5e71a3cac82fca690e4 * https://wiki.php.net/rfc/continue_on_switch_deprecation This PR adds a new sniff to detect this. Notes: * This sniff runs into the same difficulties with unscoped control structures as the `ForbiddenBreakContinueOutsideLoop` sniff. For this sniff, I've elected to prevent the false positives which plague the other sniff, though this does mean that the sniff will underreport (false negatives) for `continue` targeting `switch` when nested control structures without braces are encountered. This underreporting is minimized by examining each `case` individually. `Case`s with unscoped control structures will be ignored by this sniff. `Case`s within the same `switch` _without_ unscoped control structures will be handled correctly. * Due to differences in the tokenizer array in the various PHPCS versions, this new sniff will only work on PHPCS 2.3.0+. The minimum PHPCS requirement in Composer has been adjusted to reflect this. As PHPCS 2.3.0 was released over three years ago, I would expect this not to be an issue. * Includes one fix for an instance in PHPCompatibility itself which is affected by this PHP 7.3 change (in a copy of an upstream PHPCS method). * Note: PHPCS 3.x is also affected by this and until the PR I've pulled upstream to fix this has been merged, the build for PHPCompatibility against PHPCS 3.x on PHP `nightly` will fail. Fixes 686
86 of 86 new or added lines in 1 file covered. (100.0%)
3188 of 3300 relevant lines covered (96.61%)
30.24 hits per line
Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
---|