lib/ProcessInputStream.php
public function read(): Promise
    {
        if ($this->initialRead) {
            throw new PendingReadError;
        }

        if ($this->error) {
            return new Failure($this->error);
        }

        if ($this->resourceStream) {
            return $this->resourceStream->read();
        }

        if ($this->shouldClose) {
            return new Success; // Resolve reads on closed streams with null.
        }

        $this->initialRead = new Deferred;

        return $this->initialRead->promise();
    }
public function read(): Promise
    {
        if ($this->initialRead) {
            throw new PendingReadError;
        }

        if ($this->error) {
            return new Failure($this->error);
        }

        if ($this->resourceStream) {
            return $this->resourceStream->read();
        }

        if ($this->shouldClose) {
            return new Success; // Resolve reads on closed streams with null.
        }

        $this->initialRead = new Deferred;

        return $this->initialRead->promise();
    }
Reads data from the stream.

@return Promise Resolves with a string when new data is available or `null` if the stream has closed.

@throws PendingReadError Thrown if another read operation is still pending.