public function __destruct() { // Shift off anything else that's on the stack. This can happen if something throws // an exception that causes a premature TestSession::__destruct() call while (Controller::has_curr() && Controller::curr() !== $this->controller) { Controller::curr()->popCurrent(); } if (Controller::has_curr()) { $this->controller->popCurrent(); } }