The scope resolution operator :: sometimes behaves in an unobvious way. When applied to constants or variables, it is always resolved in a static way.
However, when applied to functions, the execution context of the called user depends on the execution context of the caller's code; the context does not change.
For example, this works great without any warnings:
class Test { private $a = 123; public function __construct() { Test::test(); self::test(); } public function test() { echo $this->a; } } new Test();
The call to self::test() and Test::test() is performed non-statically because __construct() is called non-statically and you are referring to the same class.
To reference any instance variable, for example $a in the above example, you need to use $this-> .
source share