php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80094 want a "error_reporting level at time of creation" for errors
Submitted: 2020-09-12 07:59 UTC Modified: 2020-09-12 08:11 UTC
From: divinity76 at gmail dot com Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: divinity76 at gmail dot com
New email:
PHP Version: OS:

 

 [2020-09-12 07:59 UTC] 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)
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-12 08:11 UTC] nikic@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 08:01:27 2024 UTC