WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

YoastSEO_Vendor\GuzzleHttp\Psr7

stream_for() Yoast 1.0

Create a new stream based on the input type.

Options is an associative array that can contain the following keys:

  • metadata: Array of custom metadata.
  • size: Size of the stream.

Хуков нет.

Возвращает

StreamInterface.

Использование

stream_for( $resource, $options );
$resource(resource/строка/null/число/float/true/false/Streamчислоerface/callable/\Iterator)
Entity body data
По умолчанию: ''
$options(массив)
Additional options
По умолчанию: []

Код stream_for() Yoast 15.6.2

<?php
function stream_for($resource = '', array $options = [])
{
    if (\is_scalar($resource)) {
        $stream = \fopen('php://temp', 'r+');
        if ($resource !== '') {
            \fwrite($stream, $resource);
            \fseek($stream, 0);
        }
        return new \YoastSEO_Vendor\GuzzleHttp\Psr7\Stream($stream, $options);
    }
    switch (\gettype($resource)) {
        case 'resource':
            return new \YoastSEO_Vendor\GuzzleHttp\Psr7\Stream($resource, $options);
        case 'object':
            if ($resource instanceof \YoastSEO_Vendor\Psr\Http\Message\StreamInterface) {
                return $resource;
            } elseif ($resource instanceof \Iterator) {
                return new \YoastSEO_Vendor\GuzzleHttp\Psr7\PumpStream(function () use($resource) {
                    if (!$resource->valid()) {
                        return \false;
                    }
                    $result = $resource->current();
                    $resource->next();
                    return $result;
                }, $options);
            } elseif (\method_exists($resource, '__toString')) {
                return stream_for((string) $resource, $options);
            }
            break;
        case 'NULL':
            return new \YoastSEO_Vendor\GuzzleHttp\Psr7\Stream(\fopen('php://temp', 'r+'), $options);
    }
    if (\is_callable($resource)) {
        return new \YoastSEO_Vendor\GuzzleHttp\Psr7\PumpStream($resource, $options);
    }
    throw new \InvalidArgumentException('Invalid resource type: ' . \gettype($resource));
}