Bug #68164 [Com]: error_get_last() ignores silence operator

From: Date: Tue, 26 May 2015 16:46:26 +0000
Subject: Bug #68164 [Com]: error_get_last() ignores silence operator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192895@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68164&edit=1 ID: 68164 Comment by: chrisdmiddleton at gmail dot com Reported by: willem at mollie dot nl Summary: error_get_last() ignores silence operator Status: Not a bug Type: Bug Package: Unknown/Other Function Operating System: N/A PHP Version: 5.5.17 Block user comment: N Private report: N New Comment: I'd like to echo the request for a way to check if the suppression operator was used. Perhaps it could be added as a key in the array returned by error_get_last? E.g. 'suppressed' => true Also, a related issue: the fact that error_get_last ignores the error_reporting level should be added to the documentation for both pages. Currently, this fact exists in a user comment on http://php.net/manual/en/function.error-get-last.php. But it should be noted officially, since many people don't read through the user comments. Previous Comments: ------------------------------------------------------------------------ [2015-02-16 20:07:00] marc at gutt dot it Even its not a bug, its a missing feature. It would be really nice to know if an error was suppressed. ------------------------------------------------------------------------ [2014-10-07 07:47:43] willem at mollie dot nl Thank you. I seems as though I was mistaken with the return value of error_reporting() when using a custom error handler. There does not seem to be any possibility of checking if the silence operator was used when using error_get_last() though (e.g. in a shutdown handler). ------------------------------------------------------------------------ [2014-10-06 18:55:28] nikic@php.net That's how it's supposed to work. When suppressing errors you still may want to retrieve information about it. ------------------------------------------------------------------------ [2014-10-06 13:04:50] willem at mollie dot nl Description: ------------ The function error_get_last() ignores the silence operator. Functions such as set_error_handler() received 0 as the value for the error type when the silence operator is used on the expression that triggered the error. However, error_get_last() does not. This is rather inconsistent and makes it impossible to ignore errors when using error_get_last() for error handling (e.g. in a registered shutdown function). Test script: --------------- php -r '@1/0; print_r(error_get_last());' Expected result: ---------------- PHP Warning: Division by zero in Command line code on line 1 Array ( [type] => 0 [message] => Division by zero [file] => Command line code [line] => 1 ) Actual result: -------------- PHP Warning: Division by zero in Command line code on line 1 Array ( [type] => 2 [message] => Division by zero [file] => Command line code [line] => 1 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68164&edit=1

« previous php.bugs (#192895) next »