Edit report at https://bugs.php.net/bug.php?id=45351&edit=1
ID: 45351 Updated by: s...@php.net Reported by: lasse100 at planet dot nl Summary: Exception::getTrace() should return 'object' array-element Status: Open Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: 5.3 Block user comment: N Private report: N New Comment: Unfortunately, proposed solution breaks the fix for bug #29368, since it keeps the reference to the constructed option. Better solution is needed (maybe better patch for #29368). Previous Comments: ------------------------------------------------------------------------ [2013-01-04 19:38:24] lstro...@php.net A test is missing for the new functionality. ------------------------------------------------------------------------ [2012-08-16 07:38:05] jachym dot tousek at gmail dot com Why is this feature not yet integrated in PHP? ------------------------------------------------------------------------ [2008-06-24 20:23:26] lasse100 at planet dot nl Description: ------------ As in function debug_backtrace(), the method Exception::getTrace() should return a array with a 'object' element, representing the current object. The method Exception::getTrace() should also have a $provide_object parameter like the parameter in function debug_backtrace(), to disable the 'object'-element in the array. Reproduce code: --------------- <?php class Foo { public $bar; public function __construct($bar) { $this->bar = $bar; echo 'debug_backtrace: <pre>'; var_dump(debug_backtrace()); echo '</pre>'; throw new Exception('Foo throws an exception!'); } } try { $foo = new Foo('test'); } catch (Exception $e) { echo 'Exception::getTrace(): <pre>'; var_dump($e->getTrace()); echo '</pre>'; } ?> Expected result: ---------------- debug_backtrace: array(1) { [0]=> array(7) { ["file"]=> string(50) "C:\server\apache\htdocs\forum\htdocs\bugreport.php" ["line"]=> int(13) ["function"]=> string(11) "__construct" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (1) { ["bar"]=> string(4) "test" } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> &string(4) "test" } } } Exception::getTrace(): array(1) { [0]=> array(6) { ["file"]=> string(50) "C:\server\apache\htdocs\forum\htdocs\bugreport.php" ["line"]=> int(13) ["function"]=> string(11) "__construct" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (1) { ["bar"]=> string(4) "test" } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(4) "test" } } } Actual result: -------------- debug_backtrace: array(1) { [0]=> array(7) { ["file"]=> string(50) "C:\server\apache\htdocs\forum\htdocs\bugreport.php" ["line"]=> int(13) ["function"]=> string(11) "__construct" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (1) { ["bar"]=> string(4) "test" } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> &string(4) "test" } } } Exception::getTrace(): array(1) { [0]=> array(6) { ["file"]=> string(50) "C:\server\apache\htdocs\forum\htdocs\bugreport.php" ["line"]=> int(13) ["function"]=> string(11) "__construct" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(4) "test" } } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=45351&edit=1