<?php
if (!defined('PHP_INT_MAX')) {
$min = -1;
do {
$last = $min;
} while(0 > $min <<= 1);
define('PHP_INT_MIN', $last);
define('PHP_INT_MAX', ~$last);
}
class Foo {
function getBacktrace($firstLevel = 0, $count = PHP_INT_MAX)
{
$result = array();
foreach (array_slice(debug_backtrace(), 1 + $firstLevel) as $level) {
var_dump($level);
}
}
function bar() {
$this->getBacktrace();
}
function baz() {
Foo::getBacktrace();
}
}
$a = new Foo;
$a->bar();
Foo::baz();
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- array(7) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(32)
["function"]=>
string(3) "bar"
["class"]=>
string(3) "Foo"
["object"]=>
object(Foo)#1 (0) {
}
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
Fatal error: Uncaught Error: Non-static method Foo::baz() cannot be called statically in /in/cSjVJ:33
Stack trace:
#0 {main}
thrown in /in/cSjVJ on line 33
Process exited with code 255. - Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
- array(7) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(32)
["function"]=>
string(3) "bar"
["class"]=>
string(3) "Foo"
["object"]=>
object(Foo)#1 (0) {
}
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
Deprecated: Non-static method Foo::baz() should not be called statically in /in/cSjVJ on line 33
Deprecated: Non-static method Foo::getBacktrace() should not be called statically in /in/cSjVJ on line 27
array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(33)
["function"]=>
string(3) "baz"
["class"]=>
string(3) "Foo"
["type"]=>
string(2) "::"
["args"]=>
array(0) {
}
}
- Output for 7.3.32 - 7.3.33
- array(7) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(32)
["function"]=>
string(3) "bar"
["class"]=>
string(3) "Foo"
["object"]=>
object(Foo)#1 (0) {
}
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(33)
["function"]=>
string(3) "baz"
["class"]=>
string(3) "Foo"
["type"]=>
string(2) "::"
["args"]=>
array(0) {
}
}
- Output for 5.1.1 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
- array(7) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(32)
["function"]=>
string(3) "bar"
["class"]=>
string(3) "Foo"
["object"]=>
object(Foo)#1 (0) {
}
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
Strict Standards: Non-static method Foo::baz() should not be called statically in /in/cSjVJ on line 33
Strict Standards: Non-static method Foo::getBacktrace() should not be called statically in /in/cSjVJ on line 27
array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(33)
["function"]=>
string(3) "baz"
["class"]=>
string(3) "Foo"
["type"]=>
string(2) "::"
["args"]=>
array(0) {
}
}
- Output for 5.0.0 - 5.0.5, 5.1.0
- array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(32)
["function"]=>
string(3) "bar"
["class"]=>
string(3) "Foo"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
Strict Standards: Non-static method Foo::baz() should not be called statically in /in/cSjVJ on line 33
Strict Standards: Non-static method Foo::getBacktrace() should not be called statically in /in/cSjVJ on line 27
array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(33)
["function"]=>
string(3) "baz"
["class"]=>
string(3) "Foo"
["type"]=>
string(2) "::"
["args"]=>
array(0) {
}
}
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
- array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(32)
["function"]=>
string(3) "bar"
["class"]=>
string(3) "foo"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
array(6) {
["file"]=>
string(9) "/in/cSjVJ"
["line"]=>
int(33)
["function"]=>
string(3) "baz"
["class"]=>
string(3) "foo"
["type"]=>
string(2) "::"
["args"]=>
array(0) {
}
}
preferences:
268.75 ms | 402 KiB | 327 Q