Req #80094 [Opn]: want a "error_reporting level at time of creation" for errors
| From: | nikic@php.net | Date: | Sat, 12 Sep 2020 08:11:03 +0000 |
| Subject: | Req #80094 [Opn]: want a "error_reporting level at time of creation" for errors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228982@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80094&edit=1
ID: 80094
Updated by: nikic@php.net
Reported by: divinity76 at gmail dot com
Summary: want a "error_reporting level at time of creation"
for errors
Status: Open
Type: Feature/Change Request
Package: Unknown/Other Function
PHP Version: Next Minor Version
Block user comment: N
Private report: N
New Comment:
Using a custom set_error_handler should work for that purpose -- any reason not to do that?
Apart from that, this seems like a reasonable request.
Previous Comments:
------------------------------------------------------------------------
[2020-09-12 07:59:59] divinity76 at gmail dot com
Description:
------------
with error_get_last() i wish there was some way to check the error_reporting level at the time that
error was created (or perhaps at the time it was triggered?), in particular, i've been in a
situation where i wanted to know if it was triggered in a statement prepended with the
error-suppression operator (
@) or not (which makes error_reporting 0 for the duration
of the statement), but seems there's no easy way to check that (could read the source code and
check if that specific line has @ in it, but if it's a line with multiple
statements, one could easily get a "false positive" by reading the wrong @,
also the error-suppression-operator doesn't even have to be on the same line as the the
statement it's suppressing, so..)
Test script:
---------------
<?php
unset($b);
@$a = $b;
var_dump(error_get_last());
Expected result:
----------------
array(5) {
["type"]=>
int(2)
["message"]=>
string(21) "Undefined variable $b"
["file"]=>
string(9) "/in/olPd9"
["line"]=>
int(3)
["error_reporting_level"]=>
int(0)
}
Actual result:
--------------
array(4) {
["type"]=>
int(2)
["message"]=>
string(21) "Undefined variable $b"
["file"]=>
string(9) "/in/olPd9"
["line"]=>
int(3)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80094&edit=1