: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
declare (strict_types=1);
namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
* Provides a read only stream that pumps data from a PHP callable.
* When invoking the provided callable, the PumpStream will pass the amount of
* data requested to read to the callable. The callable can choose to ignore
* this value and return fewer or more bytes than requested. Any extra data
* returned by the provided callable is buffered internally until drained using
* the read() function of the PumpStream. The provided callable MUST return
* false when there is no more data to read.
final class PumpStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
/** @var callable(int): (string|false|null)|null */
* @param callable(int): (string|false|null) $source Source of the stream data. The callable MAY
* accept an integer argument used to control the
* amount of data to return. The callable MUST
* return a string when called, or false|null on error
* @param array{size?: int, metadata?: array} $options Stream options:
* - metadata: Hash of metadata to use with stream.
* - size: Size of the stream, if known.
public function __construct(callable $source, array $options = [])
$this->size = $options['size'] ?? null;
$this->metadata = $options['metadata'] ?? [];
$this->buffer = new \YoastSEO_Vendor\GuzzleHttp\Psr7\BufferStream();
public function __toString() : string
return \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::copyToString($this);
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
\trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
public function close() : void
public function getSize() : ?int
public function tell() : int
public function eof() : bool
return $this->source === null;
public function isSeekable() : bool
public function rewind() : void
public function seek($offset, $whence = \SEEK_SET) : void
throw new \RuntimeException('Cannot seek a PumpStream');
public function isWritable() : bool
public function write($string) : int
throw new \RuntimeException('Cannot write to a PumpStream');
public function isReadable() : bool
public function read($length) : string
$data = $this->buffer->read($length);
$readLen = \strlen($data);
$this->tellPos += $readLen;
$remaining = $length - $readLen;
$data .= $this->buffer->read($remaining);
$this->tellPos += \strlen($data) - $readLen;
public function getContents() : string
$result .= $this->read(1000000);
public function getMetadata($key = null)
return $this->metadata[$key] ?? null;
private function pump(int $length) : void
if ($this->source !== null) {
$data = ($this->source)($length);
if ($data === \false || $data === null) {
$this->buffer->write($data);
$length -= \strlen($data);