Actually, that's an inaccurate representation of the problem, my fault.. here is how it should be:
class Parent {
var $errorArray = array();
function Parent() {
return true;
}
function getErrorArray() {
return $this->errorArray;
}
function setErrorArray($errorArray) {
$this->errorArray = $this->errorArray + $errorArray;
}
}
class Child1 extends Parent {
function Child1() {
return true;
}
function doStuff() {
if ($this->isWrong) { // IN THIS CASE ASSUME IT'S TRUE
$this->setErrorArray(array('action1' => 'Oops from Child1'));
}
}
}
class Child2 extends Parent {
function Child2() {
return true;
}
function doStuff2() {
if ($this->isWrong) { // IN THIS CASE ASSUME IT'S TRUE
$this->setErrorArray(array('action2' => 'Oops from Child2'));
}
}
}
class GrandChild1 extends Child1 {
function GrandChild1() {
return true;
}
function doMyStuff() {
if ($this->isWrong) {
$this->setErrorArray(array('action1.1' => 'Oops from GrandChild1'));
}
$child2 =& new Child2();
if ($child2->isWrong) { // AGAIN, ASSUME IT'S TRUE
print_r($this->getErrorArray());
}
}
}
$grandchild1 =& new GrandChild1();
$grandchild1->doStuff();
$grandchild1->doMyStuff();
Am I not right in assuming that the result should be:
Array ('action2' => 'Oops from Child2', 'action1.1' => 'Oops from GrandChild1')
Instead I get:
what I ultimately have to do in my script is this:
In GrandChild1 Object I call an instance of Child2 Object to set an error array which I assume GrandChild1 should inherit since GrandChild1 extends Child1 extends Parent, while Child2 extends Parent, and Parent has the errorArray property and the Getter/Setter methods to change it.
Am I just off-balance here?
Thanx
Phil