ID:               42520
 Updated by:       [EMAIL PROTECTED]
 Reported By:      konstantin at boyandin dot com
 Status:           Verified
 Bug Type:         Documentation problem
 Operating System: Windows XP
 PHP Version:      5.2.4
 New Comment:

The code is only executed if you are catching recoverable errors (errno
= 4096 = E_RECOVERABLE_ERROR).

This is documented as ...

"Catchable fatal error. It indicates that a probably dangerous error
occured, but did not leave the Engine in an unstable state. If the error
is not caught by a user defined handle (see also set_error_handler()),
the application aborts as it was an E_ERROR."

This is available since PHP V5.2.0

http://www.php.net/manual/en/ref.errorfunc.php#errorfunc.constants.errorlevels.e-recoverable-error

So, this IS documented.

If you return False from set_error_handler the code aborts at that
stage with the Catchable fatal error report.





Previous Comments:
------------------------------------------------------------------------

[2007-09-05 09:57:49] konstantin at boyandin dot com

I have revised the reproducible code in accordance with the advice
given. Now it demonstrates that the function is called in pure PHP 5.2.4
installation.

<?php
set_error_handler("report_error");
$a = new B();
test($a);

class A {
    public function show() {
        print('Class A used');
    }
}

class B {
    public function show() {
        print('Class B used');
    }
}

function test(A $obj) {
    $obj->show();
}

function report_error($errno, $errstr) {
    echo "PHP error $errstr<br />";
}
?>

------------------------------------------------------------------------

[2007-09-03 09:09:54] konstantin at boyandin dot com

I was using the Windows binary PHP 5.2.4 distribution.

Note: xdebug was installed when I found that behavior (no explicit
options for it set in php.ini). I will try the situation without xdebug
but with error handler set/unset.

------------------------------------------------------------------------

[2007-09-03 08:20:51] [EMAIL PROTECTED]

[EMAIL PROTECTED]:~$ php
<?php
function err($errno, $errstr) {
 echo $errstr, "\n";
}
set_error_handler("err");
function typeHint(array $foo) {
 echo "I am inside the type hint with :", gettype($foo), "\n";
}

typeHint("string");

Argument 1 passed to typeHint() must be an array, string given, called
in /home/bjori/- on line 10 and defined
I am inside the type hint with :string


------------------------------------------------------------------------

[2007-09-03 08:14:12] [EMAIL PROTECTED]

his example is missing the custom error handler catching the
E_RECOVERABLE_ERROR.

------------------------------------------------------------------------

[2007-09-03 08:03:16] [EMAIL PROTECTED]

I'm only seeing the error, no output using PHP 5.2.4RC4-dev.

What version are you using that shows the 'A' or 'B' as well as the
error message?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/42520

-- 
Edit this bug report at http://bugs.php.net/?id=42520&edit=1

Reply via email to