Non-static method %s::%s() cannot be called statically¶
Description¶
While a non-static method can call a static method, the contrary is not possible. In particular, the non-static method will not be able to have a valid $this
variable, since the static call doesn’t provide one.
Example¶
<?php
class X {
static function foo() {
//Non-static method x::foo() cannot be called statically
self::goo();
}
function goo() {}
}
(new X)->foo();
?>
Literal Examples¶
Non-static method x::foo() cannot be called statically
Solutions¶
Make the concrete method static too.
Find an object to call the non-static method.