I am interested in merging an array made in a parent class with an array made in its child class. For example:
Code: Select all
class A {
var $something = array(1,2,3);
}
class B extends A {
var $something = array(4,5,6);
}
At this point, I want B::something to be equal to array(1,2,3,4,5,6). I know this seems useless in a setup such as this, but imagine that there are functions in class A that do something with $something (which would include both the values set in class A and in its children). Better yet, imagine that A actually extends another object which holds this function, ie:
Code: Select all
class P {
abstract var $something;
function show() {
foreach($this->something as $thing) {
echo $thing . " ";
}
}
}
class A extends P {
var $something = array(1,2,3);
}
class B extends A {
var $something = array(3,4,5);
}
$myVar = new B();
$myVar->show(); // expected output: 1 2 3 4 5 6
Is this possible? I think it should be, because in the CakePHP framework, some variables (such as $uses) displays this functionality and I haven't figured out how.
Thanks a bundle in advance.