ID: 31919
Updated by: [EMAIL PROTECTED]
Reported By: joh at deworks dot net
Status: Open
-Bug Type: Scripting Engine problem
+Bug Type: Documentation problem
Operating System: Linux
PHP Version: Irrelevant
New Comment:
I appreciate your reasoning behind labeling it as a scripting engine
problem, but the solution really lies in updating the documentation.
Good analysis of the root cause though.
Previous Comments:
------------------------------------------------------------------------
[2005-02-10 21:18:13] joh at deworks dot net
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 this bug report at http://bugs.php.net/?id=31919&edit=1