It seems to me that you are trying to save data on an interface. This is not what interfaces can do. Interfaces are designed to describe what a class should look like from the outside, and not to actually implement functionality.
What you want is probably a regular class hierarchy, for example:
class Car { public function doGeneralCarStuff() { //honk horn , blink blinkers, wipers on, yadda yadda } } class CompactCar extends Car { public static $numCompactCars = 0; public function __construct() { self::$numCompactCars++; } public function doCompactCarStuff() { //foo and bar and foobar } } class HondaCivic extends CompactCar { public function __construct() { parent::__construct(); // do Honda Civic stuff } } class ToyotaCorolla extends CompactCar { public function __construct() { parent::__construct(); // do Corolla stuff } } $myCar = new HondaCivic(); $myFriendCar = new ToyotaCorolla(); echo CompactCar::$numCompactCars; // -> 2
The interface will be more suitable for describing a function that is not necessarily inherited, for example:
interface HasSunroof { function openSunroof(); function closeSunroof(); }
In some languages โโ(Javascript, Ruby, etc.) HasSunroof can be โmixinโ and have data and functionality associated with it, but in PHP (and Java, etc.) you have to put the functionality in a class that implements interface.
Interfaces (in my experience) are more often used in languages โโthat check the type of compilation time, for example Java, than in "duck" languages โโlike PHP.
source share