: 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;
* Reads from multiple streams, one after the other.
* This is a read-only stream decorator.
final class AppendStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
/** @var StreamInterface[] Streams being decorated */
private $seekable = \true;
* @param StreamInterface[] $streams Streams to decorate. Each stream must
public function __construct(array $streams = [])
foreach ($streams as $stream) {
$this->addStream($stream);
public function __toString() : string
return $this->getContents();
} catch (\Throwable $e) {
if (\PHP_VERSION_ID >= 70400) {
\trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
* Add a stream to the AppendStream
* @param StreamInterface $stream Stream to append. Must be readable.
* @throws \InvalidArgumentException if the stream is not readable
public function addStream(\YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream) : void
if (!$stream->isReadable()) {
throw new \InvalidArgumentException('Each stream must be readable');
// The stream is only seekable if all streams are seekable
if (!$stream->isSeekable()) {
$this->seekable = \false;
$this->streams[] = $stream;
public function getContents() : string
return \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::copyToString($this);
* Closes each attached stream.
public function close() : void
$this->pos = $this->current = 0;
foreach ($this->streams as $stream) {
* Detaches each attached stream.
* Returns null as it's not clear which underlying stream resource to return.
$this->pos = $this->current = 0;
foreach ($this->streams as $stream) {
public function tell() : int
* Tries to calculate the size by adding the size of each stream.
* If any of the streams do not return a valid number, then the size of the
* append stream cannot be determined and null is returned.
public function getSize() : ?int
foreach ($this->streams as $stream) {
public function eof() : bool
return !$this->streams || $this->current >= \count($this->streams) - 1 && $this->streams[$this->current]->eof();
public function rewind() : void
* Attempts to seek to the given position. Only supports SEEK_SET.
public function seek($offset, $whence = \SEEK_SET) : void
throw new \RuntimeException('This AppendStream is not seekable');
} elseif ($whence !== \SEEK_SET) {
throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
$this->pos = $this->current = 0;
foreach ($this->streams as $i => $stream) {
} catch (\Exception $e) {
throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e);
// Seek to the actual position by reading from each stream
while ($this->pos < $offset && !$this->eof()) {
$result = $this->read(\min(8096, $offset - $this->pos));
* Reads from all of the appended streams until the length is met or EOF.
public function read($length) : string
$total = \count($this->streams) - 1;
$progressToNext = \false;
// Progress to the next stream if needed.
if ($progressToNext || $this->streams[$this->current]->eof()) {
$progressToNext = \false;
if ($this->current === $total) {
$result = $this->streams[$this->current]->read($remaining);
$remaining = $length - \strlen($buffer);
$this->pos += \strlen($buffer);
public function isReadable() : bool
public function isWritable() : bool
public function isSeekable() : bool
public function write($string) : int
throw new \RuntimeException('Cannot write to an AppendStream');
public function getMetadata($key = null)