|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2018-08-16 17:33 UTC] php at darkain dot com
 Description:
------------
Using "continue" on a "switch" statement now throws a warning. However, this warning never triggers the function specified in "set_error_handler". My unit testing framework uses "set_error_handler" to log and report any issues, but is not being triggered with this new warning.
Test script:
---------------
<?php
// REPORT ALL ERRORS / WARNINGS / NOTICES
error_reporting(E_ALL);
// CATCH ERRORS / WARNINGS / NOTICES, AND THROW AN EXCEPTION IN THEIR PLACE
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
	throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
});
for ($x=0; $x<10; $x++) {
    switch ($x) {
        case 1:
            continue;
    }
}
Expected result:
----------------
Fatal error: Uncaught ErrorException: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Actual result:
--------------
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 16:00:01 2025 UTC | 
In my particular case, the code is split between two separate files. The first file has the set_error_handler, and then AFTER that statement, there is include('other.php'), so it should still be caught (general syntax errors and all other errors/warnings are caught this way) You can see the full file here: https://github.com/darkain/altaform-core/blob/master/test/cli.php Results can be found here: https://travis-ci.org/darkain/altaform-core/jobs/416134464 (in my particular case, I found this by manually reviewing the Travis-CI reports, but because the warning was never caught, it never generated the email report saying there was an issue in the code base)