Creates an in-memory stream with the given data.

@return resource
178565
private function createStream(string $data = '')
    {
        $stream = fopen('php://temp', 'w+b');
        fwrite($stream, $data);
        rewind($stream);

        return $stream;
    }
321661
public function stream()
    {
        $endpoint = $this->getEndpoint();
        $params = $this->getParams();
        $list = $this->getClient()->request($endpoint, 'GET', $params);
        foreach ($list['items'] as $item) {
            yield $item;
        }

        while ($list['metadata']['continue']) {
            $params['continue'] = $list['metadata']['continue'];
            $list = $this->getClient()->request($endpoint, 'GET', $params);
            foreach ($list['items'] as $item) {
                yield $item;
            }
        }
    }
1313549
public function createStream($body = null)
	{
		if ( ! $body instanceof StreamInterface)
		{
			if (is_resource($body))
			{
				$body = new Stream($body);
			}
			else
			{
				$stream = new Stream('php://temp', 'rb+');
				
				if (null !== $body)
				{
					$stream->write((string) $body);
				}
				
				$body = $stream;
			}
		}
		
		$body->rewind();
		
		return $body;
	}
1134023
public function stream()
    {
        $key = $this->data['key'];
        unset($this->data['key']);
        $path = $this->getPath() . '/' . $key;
        if (!array_key_exists('end', $this->data)) {
            $patch = $this->jsonPatch->generate($path, JsonPatch::ACTION_ADD, $this->data, false);
        } else {
            $patch = $this->jsonPatch->generate($path . '/end', JsonPatch::ACTION_ADD, $this->data['end'], false);
        }

        $this->dataSource->save($this->process, [$patch]);
        $this->data = [];
    }
509582
public function detach()
    {
        $resource = $this->resource;

        $this->resource = null;
        $this->stream = null;
        $this->pointer = 0;
        $this->seekable = true;
        $this->writable = true;

        return $resource;
    }
790385
public function detach()
    {
        $resource = $this->resource;

        $this->resource = null;
        $this->stream = null;

        return $resource;
    }
1194011
function read($inByte = null)
    {
        $this->_assertReadable();

        $inByte = ($inByte === null)
            ?
            (
                ($this->getBuffer() === null) ? -1 : $this->getBuffer()
            )
            : $inByte;

        $stream = $this->resource()->getRHandler();
        $data   = stream_get_contents($stream, $inByte);
        if (false === $data)
            throw new \RuntimeException('Cannot read stream.');

        if (function_exists('mb_strlen'))
            $transCount = mb_strlen($data, '8bit');
        else
            $transCount = strlen($data);

        $this->_resetTransCount($transCount);

        return $data;
    }
693976
public function write($data)
    {
        $streamResource = $this->getStreamResource();
        if (!is_resource($streamResource)) {
            throw new \UnexpectedValueException('Stream resource parameter must be a resource');
        }

        $dataLength = strlen($data);

        if ($dataLength !== fwrite($streamResource, $data, $dataLength)) {
            throw new \RuntimeException('Unable to write data to the stream');
        }

        return $this;
    }
696715
def GetStream(data=None):
        
        if len(__mstreams_available__) == 0:
            if data:
                mstream = MemoryStream(data)
                mstream.seek(0)
            else:
                mstream = MemoryStream()
            __mstreams__.append(mstream)
            return mstream

        mstream = __mstreams_available__.pop()

        if data is not None and len(data):
            mstream.Cleanup()
            mstream.write(data)

        mstream.seek(0)

        return mstream
607576
public function getBodyAsStream()
    {
        $body = $this->getBody();
        if (is_callable($this->body)) {
            $body = $this->getBodyAsString();
        }
        if (is_string($body) || null === $body) {
            $stream = fopen('php://temp', 'r+');
            fwrite($stream, (string) $body);
            rewind($stream);

            return $stream;
        }

        return $body;
    }
946805
public function stream()
    {
        if (ob_get_level()) {
            ob_end_clean();
        }

        // Transfer file in 1024 byte chunks to save memory usage.
        if ($fd = fopen($this->path, 'rb')) {
            while (!feof($fd)) {
                echo fread($fd, 1024);
            }
            fclose($fd);
        }
    }
1297672
public function getBody()
    {
        $streamResource = fopen('php://memory', 'r+');
        if (is_resource($this->content)) {
            stream_copy_to_stream($this->content, $streamResource);
        } else {
            fwrite($streamResource, $this->content);
        }
        rewind($streamResource);

        return new ContentStream($streamResource);
    }
526597
public function getStream()
    {
        if(!$this->stream)
            $this->stream = Stream::createFromPath($this->path);

        return $this->stream;
    }
1179785
public function create($data)
    {
        set_time_limit(0);
        ignore_user_abort(true);
        //TODO magical value
        ini_set('memory_limit', '1800M');
        $verbose = $this->params()->fromQuery('verbose', false);
        $verbose = ($verbose !== false);
        $responseContent = array();
        $processExecutionHandler = $this->getProcessExecutionHandler();
        $processInformation = $processExecutionHandler->executeNextProcess($verbose);
        $processUpdater = $this->getProcessUpdater();
        $processUpdater->cleanOldExecutions();
        $response = $this->getResponse();
        $response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
        $adapter = new Json();
        $response->setContent($adapter->serialize($processInformation));
        return $response;
    }
709399
private function getStream()
    {
        if ($this->stream && get_resource_type($this->stream) === 'Unknown') {
            fclose($this->stream);
            $this->stream = null;
        }
        if (!$this->stream) {
            $this->stream = @fopen($this->streamUrl, 'a');
            if (!$this->stream) {
                LoggerPolicy::processIOError("Error open $this->streamUrl");
                $this->stream = null;
            }
        }

        return $this->stream;
    }
110070
protected function _buildFOpenStreamContext()
    {
        # Set the headers required to work with fopen
        $headers =  $this->_generateProxyRequestHeaders(TRUE);
        $headers.= 'Cookie: ' . $this->_buildProxyRequestCookieString();

        # Create the stream context
        $stream_context = array (
            'header'        => $headers,
            'user_agent'    => $this->_requestUserAgent
        );

        # Figure out what kind of request we're making, and what to fill it with
        $stream_context['method'] = $this->_requestMethod;

        if($this->_requestMethod === 'POST' ||
           $this->_requestMethod === 'PUT')
        {
            $stream_context['content'] = $this->_requestBody;
        }

        return stream_context_create(array('http' => $stream_context));
    }
227982
public function setStream($stream)
    {
        // streams have to be cached to file first
        $meta = @stream_get_meta_data($stream);
        if (!$meta || !$meta['mode'] || !in_array($meta['mode'], self::$readableModes, true) || $meta['eof']) {
            throw new Exception(
                'setStream() expects parameter stream to be readable stream resource.'
            );
        }

        /** @var resource $tmp_fp */
        $tmp_fp = tmpfile();
        if ($tmp_fp) {
            while (!feof($stream)) {
                fwrite($tmp_fp, fread($stream, 2028));
            }

            if (fread($tmp_fp, 1) != "\n") {
                fwrite($tmp_fp, PHP_EOL);
            }

            fseek($tmp_fp, 0);
            $this->stream = &$tmp_fp;
        } else {
            throw new Exception(
                'Could not create temporary files for attachments. Your tmp directory may be unwritable by PHP.'
            );
        }
        fclose($stream);

        $this->resource = mailparse_msg_create();
        // parses the message incrementally (low memory usage but slower)
        while (!feof($this->stream)) {
            mailparse_msg_parse($this->resource, fread($this->stream, 2082));
        }
        $this->parse();

        return $this;
    }