public function buffer(Context $context): Promise
    {
        return $context->task(function (Context $context) {
            $buffer = '';
            
            try {
                while (null !== ($chunk = yield $this->read($context, 0xFFFF))) {
                    $buffer .= $chunk;
                }
            } finally {
                $this->close();
            }
            
            return $buffer;
        });
    }
public function buffer(Context $context): Promise
    {
        return $context->task(function (Context $context) {
            $buffer = '';
            
            try {
                while (null !== ($chunk = yield $this->read($context, 0xFFFF))) {
                    $buffer .= $chunk;
                }
            } finally {
                $this->close();
            }
            
            return $buffer;
        });
    }
public function buffer ( Context $ context ) : Promise { return $ context -> task ( function ( Context $ context ) { $ buffer = '' ; try { while ( null !== ( $ chunk = yield $ this -> read ( $ context , 0xFFFF ) ) ) { $ buffer .= $ chunk ; } } finally { $ this -> close ( ) ; } return $ buffer ; } ) ; }
Buffer remaining stream contents in memory and close the stream.

@param Context $context Async execution context.
@return string Buffered stream contents.

@throws StreamClosedException When the stream has been closed.
Buffer remaining stream contents in memory and close the stream .