public function write($socket, $iterator) { if (!$iterator->valid()) { return new Success(); } $this->socket = $socket; $this->iterator = $iterator; $this->promisor = new Deferred(); $this->writeNextElement(); return $this->promisor->promise(); }