From:             lasse100 at planet dot nl
Operating system: Irrelevant
PHP version:      5.2.6
PHP Bug Type:     Feature/Change Request
Bug description:  Exception::getTrace() should return 'object' array-element

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 bug report at http://bugs.php.net/?id=45351&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45351&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45351&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45351&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45351&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45351&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45351&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45351&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45351&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45351&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45351&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45351&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45351&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45351&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45351&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45351&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45351&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45351&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45351&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45351&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45351&r=mysqlcfg

Reply via email to