#30828 [Com]: debug_backtrace reports incorrect class in overridden methods

From: Date: Fri, 07 Jan 2005 12:39:44 +0000
Subject: #30828 [Com]: debug_backtrace reports incorrect class in overridden methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71559@lists.php.net to get a copy of this message
 ID:          30828
 Comment by:  vargusz at freemail dot hu
 Reported By: lists at infospleen dot com
 Status:      Open
 Bug Type:    Scripting Engine problem
 PHP Version: 5.0.1
 New Comment:

Possibly the same underlying code causes inherited static method calls
to be misreported:
class A {
  static function f () {
    $bt = debug_backtrace();
    echo "{$bt['class']}\n";
  }
}
class B extends A {}
And both A::f() and B::f() produce 'A'.


Previous Comments:
------------------------------------------------------------------------

[2004-11-18 16:32:47] lists at infospleen dot com

Description:
------------
If class B extends class A, and overrides a method of class A,
debug_backtrace() reports that the method of class A is a method of
class B instead.

Reproduce code:
---------------
class A {
	function __construct() {
		$bt = debug_backtrace();
		foreach ($bt as $t)
			print 
				$t['class'].'::'.
				$t['function'].'<br>';
	}
}

class B extends A {
	function __construct() {
		parent::__construct();
	}
}

$b = new B();

Expected result:
----------------
Expected output:

A::__construct
B::__construct


Actual result:
--------------
Actual output:

B::__construct
B::__construct



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30828&edit=1


Thread (4 messages)

« previous php.bugs (#71559) next »