protected function getState() { if ($this->isTerminated()) { return PROMISABLE::ERROR; } switch ($this->state) { case PROMISABLE::PENDING: case null: return PROMISABLE::PENDING; default: return $this->state; } }