<?php | |
class Dog { | |
/** @var int */ | |
static $_woofs = 0; | |
function Woof() { | |
Dog::$_woofs ++; | |
} | |
} |
Ben Fistein Saturday, 25 March 2017 |
Every bunch of static fields is represented as a nested class named "_statics", whose instance is lazily bound to a web request, represented as a Context class in Peachpie. Then, by accessing a static field of a class, the compiler actually generates code that retrieves instances of "_statics" from Context and accesses its instance (non-static) fields. For more information on this, please refer to http://www.peachpie.io/2016/06/static-fields.html .
<?php | |
class Dog { | |
/** @var int */ | |
static $_woofs = 0; | |
function Woof() { | |
Dog::$_woofs ++; | |
} | |
} |