我找到了以下代码。这是一种特定的模式,还是像这样构建代码的原因 - 还是只是假的?
class ExportCSV extends Export
{
// some private and public vars
public function __construct($arg)
{
// [...]
new CustomerReport($this);
}
public function procCallback($proc)
{
switch($proc){
case "customer":
new InvoiceReport($this);
break;
case "invoice":
new PrepaymentReport($this);
break;
case "prepayment":
new RefundReport($this);
break;
case "refund":
$this->sendMail();
break;
}
}
}
class CustomerReport extends Foobar
{
private $inst;
public function __construct($inst)
{
$this->inst = $inst;
$this->exportCustomers($inst->from, $inst->to);
}
public function __destruct()
{
$this->inst->procCallback("customer");
}
}