Req #69027 [Opn]: Backtrace does not include class
| From: | roborg at gmail dot com | Date: | Tue, 21 Jul 2015 07:46:22 +0000 |
| Subject: | Req #69027 [Opn]: Backtrace does not include class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194587@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69027&edit=1
ID: 69027
User updated by: roborg at gmail dot com
Reported by: roborg at gmail dot com
Summary: Backtrace does not include class
Status: Open
Type: Feature/Change Request
Package: Unknown/Other Function
Operating System: N/A
-PHP Version: Irrelevant
+PHP Version: 7.0.0beta1
Block user comment: N
Private report: N
New Comment:
This affects all PHP versions, but PHP7 seems the ideal time to add it
Previous Comments:
------------------------------------------------------------------------
[2015-02-11 10:20:12] roborg at gmail dot com
Description:
------------
The backtrace (either from an exception or debug_backtrace) doesn't contain an entry for the
class of the object that a method was called on - only the class that the method was defined in.
In the example below, there's even though the call is on a B object, there's no mention of
B in the backtrace, which cane make debugging very difficult.
I would suggest adding an extra item to the trace, e.g. "object_class", alongside class.
Test script:
---------------
<?php
class A
{
protected $val = 0;
public function ex()
{
throw new Exception('Value is ' . $this->val);
}
}
class B extends A
{
protected $val = 1;
}
try
{
$b = new B();
$b->ex();
}
catch (Exception $e)
{
print '<pre>' . print_r($e->getTrace(), true) . '</pre>';
}
Expected result:
----------------
Array
(
[0] => Array
(
[file] => C:\bug.php
[line] => 21
[function] => ex
[class] => A
[object_class] => B
[type] => ->
[args] => Array
(
)
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[file] => C:\bug.php
[line] => 21
[function] => ex
[class] => A
[type] => ->
[args] => Array
(
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69027&edit=1