It is kind of hard for me to explain what I am trying to do so I will just provide an example
class A {
static $data = ['a'];
static function getData() { return static::$data; }
}
class B extends A {
static $data = ['b'];
}
class C extends B {
static $data = ['c'];
}
class D extends B {
static $data = ['d'];
}
$a = new A;
$b = new B;
$c = new C;
$d = new D;
$a::getData(); // Output: Array('a'), Expected: Array('a');
$b::getData(); // Output: Array('b'), Expected: Array('a', 'b');
$c::getData(); // Output: Array('c'), Expected: Array('a', 'b', 'c');
$c::getData(); // Output: Array('d'), Expected: Array('a', 'b', 'd');
Is this possible at all?
EDIT: I have my data objects and each object has a set of rules for its properties. For example a User object has a property name which can be maximum 10 symbols, I define this in the user class' rules and then all user objects will obey the rule when their property name is about to be changed. The rules array is static because they apply to all objects of this class. However when I inherit it for example in a VIP user then the VIP will need to have additional rules for properties that the basic user doesn't have. I need to be able to extend the rules array but if I define such an array in the child class it just overwrites the parent rules which I also need.