From: joh at deworks dot net Operating system: Linux PHP version: Irrelevant PHP Bug Type: Scripting Engine problem Bug description: E_STRICT errors are passed to custom error handler
Description: ------------ E_STRICT errors are passed to a custom error handler when the errors appear in an included file. The documentation for set_error_handler() clearly states that "The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and E_STRICT". This is true, if the error occurs in the same file as the error handler, but when a file which triggers an E_STRICT warning is included, PHP passes the error to the custom error handler. As this only happens when including an erroneous file, I'm reporting this bug as a Scripting Engine problem, and not a Documentation problem. I've tested this on the latest 5.1.0 (200502101130) development snapshot. Reproduce code: --------------- errorhandler.php: <?php function errorHandler($severity, $message, $file = null, $line = null, $context = array()) { static $severityMap = array( E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_CORE_ERROR => 'E_CORE_ERROR', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING', E_USER_NOTICE => 'E_USER_NOTICE', E_STRICT => 'E_STRICT' ); echo '<strong>' . __METHOD__ . ': PHP Error with severity ' . $severityMap[$severity] . '(' . $severity . ') raised: ' . $message . "</strong><br />"; } set_error_handler('errorHandler'); include 'strict.php'; ?> strict.php: <?php class Foo { public function __construct() { } public function Foo() { } } ?> Expected result: ---------------- Strict Standards: Redefining already defined constructor for class Foo in strict.php on line 4 Actual result: -------------- errorHandler: PHP Error with severity E_STRICT(2048) raised: Redefining already defined constructor for class Foo -- Edit bug report at http://bugs.php.net/?id=31919&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31919&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31919&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31919&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31919&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31919&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31919&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31919&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31919&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31919&r=support Expected behavior: http://bugs.php.net/fix.php?id=31919&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31919&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31919&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31919&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31919&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31919&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31919&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31919&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31919&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31919&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31919&r=mysqlcfg