#44543 closed defect (bug) (fixed)
PHP 7.3 compatibility: using `continue` in `switch` statements
Reported by: | jrf | Owned by: | jrf |
---|---|---|---|
Milestone: | 5.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch commit fixed-major php73 |
Focuses: | Cc: |
Description
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 quite possibly, 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:
- http://php.net/manual/en/control-structures.continue.php
- https://github.com/php/php-src/pull/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/WordPress/wordpress-develop/jobs/401538006#L828-L831.
The attached patch fixes the two instances of this in WordPress.
Notes:
- Both these switches are nested in other control structures, but end the switch at the scope closer of the outer control structure, so using
break
in these cases is equivalent to usingcontinue 2
.
FYI: The PHPCompatibility standard will include a sniff to detect this in the near future. This ticket is the result of some tests I've been running on the WIP PHPCompatibility sniff :wink:
Attachments (1)
Change History (14)
#2
@
6 years ago
- Keywords commit added; 2nd-opinion removed
- Owner set to jrf
- Status changed from new to assigned
#3
@
6 years ago
- Milestone changed from 5.0 to 4.9.9
Bumping it to a minor release to ensure consideration for the next round. PHP 7.3 GA is scheduled for December 13th.
+1 on patch looking good.
#5
@
6 years ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for consideration for 4.9.9
#8
@
6 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Reopened as this needs to be ported to the 5.0
branch as well.
Patch looks good to me.