<?php
class A {
public function doStuff() {
var_dump(get_class($this));
}
}
class B {
public function doStuff() {
A::doStuff();
}
}
$b = new B;
$b->doStuff();
Fatal error: Uncaught Error: Non-static method A::doStuff() cannot be called statically in /in/SXAhC:11
Stack trace:
#0 /in/SXAhC(17): B->doStuff()
#1 {main}
thrown in /in/SXAhC on line 11
Process exited with code 255.
Deprecated: Non-static method A::doStuff() should not be called statically in /in/SXAhC on line 11
Fatal error: Uncaught Error: Using $this when not in object context in /in/SXAhC:5
Stack trace:
#0 /in/SXAhC(11): A::doStuff()
#1 /in/SXAhC(17): B->doStuff()
#2 {main}
thrown in /in/SXAhC on line 5
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26
Fatal error: Uncaught Error: Using $this when not in object context in /in/SXAhC:5
Stack trace:
#0 /in/SXAhC(11): A::doStuff()
#1 /in/SXAhC(17): B->doStuff()
#2 {main}
thrown in /in/SXAhC on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Non-static method A::doStuff() should not be called statically in /in/SXAhC on line 11
Notice: Undefined variable: this in /in/SXAhC on line 5
string(1) "A"
Output for 5.6.0 - 5.6.30
Deprecated: Non-static method A::doStuff() should not be called statically, assuming $this from incompatible context in /in/SXAhC on line 11
string(1) "B"
Strict Standards: Non-static method A::doStuff() should not be called statically, assuming $this from incompatible context in /in/SXAhC on line 11
string(1) "B"