/** * Not proper downcasting, really replacing an object with it's * child. */ public static function downCast(Order $o) { if ($o->hasChildObject()) { //print "Downcasting to ". $o->getDescendantClass() . "\n"; return $o->getChildObject(); } else { return $o; } }