php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39111 debug_backtrace() has problems with static classes
Submitted: 2006-10-10 12:15 UTC Modified: 2006-10-10 14:00 UTC
From: vincent dot guth at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.1.6 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vincent dot guth at gmail dot com
New email:
PHP Version: OS:

 

 [2006-10-10 12:15 UTC] vincent dot guth at gmail dot com
Description:
------------
The "class" parameter should be "B" instead of "A", as I called B::r() and not A::r().

Reproduce code:
---------------
<?php
abstract class A {
	public static function r() {
		var_dump(debug_backtrace());
	}
}

class B extends A {

}

echo B::r();
?>

Expected result:
----------------
array(1) {
  [0]=>
  array(6) {
    ["file"]=>
    string(13) "/www/test.php"
    ["line"]=>
    int(12)
    ["function"]=>
    string(1) "r"
    ["class"]=>
    string(1) "B" /* Not A */
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(0) {
    }
  }
}

Actual result:
--------------
array(1) {
  [0]=>
  array(6) {
    ["file"]=>
    string(13) "/www/test.php"
    ["line"]=>
    int(12)
    ["function"]=>
    string(1) "r"
    ["class"]=>
    string(1) "A"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(0) {
    }
  }
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-10 14:00 UTC] tony2001@php.net
The function r() belongs to class A and is executed in its scope, so the result you get is expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC