php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70634 debug_backtrace() return value changed
Submitted: 2015-10-04 10:33 UTC Modified: 2015-10-04 14:16 UTC
From: kenji dot uui at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.0RC4 OS: Linux
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: kenji dot uui at gmail dot com
New email:
PHP Version: OS:

 

 [2015-10-04 10:33 UTC] kenji dot uui at gmail dot com
Description:
------------
The return value of debug_backtrace() was changed since php7.


Test script:
---------------
$ cat Proxy.php 
<?php
class Proxy
{
  public static function __callStatic($function, array $arguments)
  {
    if (self::checkCalledMethod($function))
    {
    }
  }
  
  public static function checkCalledMethod($function)
  {
    $trace = debug_backtrace();
    var_dump($trace);
  }
}
----- ----- ----- -----
$ cat Test.php 
<?php
class Test
{
  public function run()
  {
    Proxy::bar();
  }
}
----- ----- ----- -----
$ cat app.php 
<?php
require './Test.php';
require './Proxy.php';

$test = new Test();
$test->run();
----- ----- ----- -----
$ php app.php


Expected result:
----------------
PHP 5.6.10-dev

array(4) {
  [0]=>
  array(6) {
    ["file"]=>
    string(34) "/vagrant/debug_backtrace/Proxy.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(17) "checkCalledMethod"
    ["class"]=>
    string(5) "Proxy"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(1) {
      [0]=>
      &string(3) "bar"
    }
  }
  [1]=>
  array(6) {
    ["file"]=>
    string(33) "/vagrant/debug_backtrace/Test.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(12) "__callStatic"
    ["class"]=>
    string(5) "Proxy"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(2) {
      [0]=>
      &string(3) "bar"
      [1]=>
      &array(0) {
      }
    }
  }
  [2]=>
  array(6) {
    ["file"]=>
    string(33) "/vagrant/debug_backtrace/Test.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(3) "bar"
    ["class"]=>
    string(5) "Proxy"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(0) {
    }
  }
  [3]=>
  array(7) {
    ["file"]=>
    string(32) "/vagrant/debug_backtrace/app.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(3) "run"
    ["class"]=>
    string(4) "Test"
    ["object"]=>
    object(Test)#1 (0) {
    }
    ["type"]=>
    string(2) "->"
    ["args"]=>
    array(0) {
    }
  }
}


Actual result:
--------------
PHP 7.0.0-dev

array(3) {
  [0]=>
  array(6) {
    ["file"]=>
    string(34) "/vagrant/debug_backtrace/Proxy.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(17) "checkCalledMethod"
    ["class"]=>
    string(5) "Proxy"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(1) {
      [0]=>
      string(3) "bar"
    }
  }
  [1]=>
  array(6) {
    ["file"]=>
    string(33) "/vagrant/debug_backtrace/Test.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(12) "__callStatic"
    ["class"]=>
    string(5) "Proxy"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(2) {
      [0]=>
      string(3) "bar"
      [1]=>
      array(0) {
      }
    }
  }
  [2]=>
  array(7) {
    ["file"]=>
    string(32) "/vagrant/debug_backtrace/app.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(3) "run"
    ["class"]=>
    string(4) "Test"
    ["object"]=>
    object(Test)#1 (0) {
    }
    ["type"]=>
    string(2) "->"
    ["args"]=>
    array(0) {
    }
  }
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-04 14:16 UTC] bwoebi@php.net
-Status: Open +Status: Not a bug
 [2015-10-04 14:16 UTC] bwoebi@php.net
Yeah, the Proxy::bar() disappeared and is now immediately going to Proxy::__callStatic(). This is the result of an optimization (trampolines), which causes the VM in PHP 7 to immediately call the __callStatic().
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 08:00:02 2026 UTC