when accessing a static property you need to use self::$varName instead of $this->varName . Same thing with static methods.
Edit: To highlight some of the differences between abstract and static / non-static properties, I made a small example.
<?php abstract class A{ public abstract function setValue($someValue); public function test(){ echo '<pre>'; var_dump($this->childProperty); var_dump(B::$childStatic); echo '</pre>'; } } class B extends A{ protected $childProperty = 'property'; protected static $childStatic = 'static'; public function setValue($someValue){ $this->childProperty = $someValue; self::$childStatic = $someValue; } }
Conclusion:
string(8) "property" string(6) "static" string(8) "property" string(6) "static" string(14) "some new value" string(14) "some new value" string(8) "property" string(14) "some new value"
After calling setValue in $ X, you will see that the values โโof the static property change in both instances, while the non-static properties change in only one instance.
Also, I just found out something. In the method of an abstract class trying to access a static child property, you must specify the name of the child class to access the property, self:: does not work and throws an error.
source share