php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30828 debug_backtrace() reports incorrect class in overridden methods
Submitted: 2004-11-18 16:32 UTC Modified: 2005-06-23 11:25 UTC
Votes:8
Avg. Score:3.9 ± 1.5
Reproduced:7 of 8 (87.5%)
Same Version:2 (28.6%)
Same OS:3 (42.9%)
From: lists at infospleen dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-06-19 OS: *
Private report: No CVE-ID: None
 [2004-11-18 16:32 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-07 13:39 UTC] vargusz at freemail dot hu
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'.
 [2005-06-23 11:25 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC