Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../vendor_p.../guzzleht.../psr7/src
File: PumpStream.php
<?php
[0] Fix | Delete
[1] Fix | Delete
declare (strict_types=1);
[2] Fix | Delete
namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
[3] Fix | Delete
[4] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
[5] Fix | Delete
/**
[6] Fix | Delete
* Provides a read only stream that pumps data from a PHP callable.
[7] Fix | Delete
*
[8] Fix | Delete
* When invoking the provided callable, the PumpStream will pass the amount of
[9] Fix | Delete
* data requested to read to the callable. The callable can choose to ignore
[10] Fix | Delete
* this value and return fewer or more bytes than requested. Any extra data
[11] Fix | Delete
* returned by the provided callable is buffered internally until drained using
[12] Fix | Delete
* the read() function of the PumpStream. The provided callable MUST return
[13] Fix | Delete
* false when there is no more data to read.
[14] Fix | Delete
*/
[15] Fix | Delete
final class PumpStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
[16] Fix | Delete
{
[17] Fix | Delete
/** @var callable(int): (string|false|null)|null */
[18] Fix | Delete
private $source;
[19] Fix | Delete
/** @var int|null */
[20] Fix | Delete
private $size;
[21] Fix | Delete
/** @var int */
[22] Fix | Delete
private $tellPos = 0;
[23] Fix | Delete
/** @var array */
[24] Fix | Delete
private $metadata;
[25] Fix | Delete
/** @var BufferStream */
[26] Fix | Delete
private $buffer;
[27] Fix | Delete
/**
[28] Fix | Delete
* @param callable(int): (string|false|null) $source Source of the stream data. The callable MAY
[29] Fix | Delete
* accept an integer argument used to control the
[30] Fix | Delete
* amount of data to return. The callable MUST
[31] Fix | Delete
* return a string when called, or false|null on error
[32] Fix | Delete
* or EOF.
[33] Fix | Delete
* @param array{size?: int, metadata?: array} $options Stream options:
[34] Fix | Delete
* - metadata: Hash of metadata to use with stream.
[35] Fix | Delete
* - size: Size of the stream, if known.
[36] Fix | Delete
*/
[37] Fix | Delete
public function __construct(callable $source, array $options = [])
[38] Fix | Delete
{
[39] Fix | Delete
$this->source = $source;
[40] Fix | Delete
$this->size = $options['size'] ?? null;
[41] Fix | Delete
$this->metadata = $options['metadata'] ?? [];
[42] Fix | Delete
$this->buffer = new \YoastSEO_Vendor\GuzzleHttp\Psr7\BufferStream();
[43] Fix | Delete
}
[44] Fix | Delete
public function __toString() : string
[45] Fix | Delete
{
[46] Fix | Delete
try {
[47] Fix | Delete
return \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::copyToString($this);
[48] Fix | Delete
} catch (\Throwable $e) {
[49] Fix | Delete
if (\PHP_VERSION_ID >= 70400) {
[50] Fix | Delete
throw $e;
[51] Fix | Delete
}
[52] Fix | Delete
\trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
[53] Fix | Delete
return '';
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
public function close() : void
[57] Fix | Delete
{
[58] Fix | Delete
$this->detach();
[59] Fix | Delete
}
[60] Fix | Delete
public function detach()
[61] Fix | Delete
{
[62] Fix | Delete
$this->tellPos = 0;
[63] Fix | Delete
$this->source = null;
[64] Fix | Delete
return null;
[65] Fix | Delete
}
[66] Fix | Delete
public function getSize() : ?int
[67] Fix | Delete
{
[68] Fix | Delete
return $this->size;
[69] Fix | Delete
}
[70] Fix | Delete
public function tell() : int
[71] Fix | Delete
{
[72] Fix | Delete
return $this->tellPos;
[73] Fix | Delete
}
[74] Fix | Delete
public function eof() : bool
[75] Fix | Delete
{
[76] Fix | Delete
return $this->source === null;
[77] Fix | Delete
}
[78] Fix | Delete
public function isSeekable() : bool
[79] Fix | Delete
{
[80] Fix | Delete
return \false;
[81] Fix | Delete
}
[82] Fix | Delete
public function rewind() : void
[83] Fix | Delete
{
[84] Fix | Delete
$this->seek(0);
[85] Fix | Delete
}
[86] Fix | Delete
public function seek($offset, $whence = \SEEK_SET) : void
[87] Fix | Delete
{
[88] Fix | Delete
throw new \RuntimeException('Cannot seek a PumpStream');
[89] Fix | Delete
}
[90] Fix | Delete
public function isWritable() : bool
[91] Fix | Delete
{
[92] Fix | Delete
return \false;
[93] Fix | Delete
}
[94] Fix | Delete
public function write($string) : int
[95] Fix | Delete
{
[96] Fix | Delete
throw new \RuntimeException('Cannot write to a PumpStream');
[97] Fix | Delete
}
[98] Fix | Delete
public function isReadable() : bool
[99] Fix | Delete
{
[100] Fix | Delete
return \true;
[101] Fix | Delete
}
[102] Fix | Delete
public function read($length) : string
[103] Fix | Delete
{
[104] Fix | Delete
$data = $this->buffer->read($length);
[105] Fix | Delete
$readLen = \strlen($data);
[106] Fix | Delete
$this->tellPos += $readLen;
[107] Fix | Delete
$remaining = $length - $readLen;
[108] Fix | Delete
if ($remaining) {
[109] Fix | Delete
$this->pump($remaining);
[110] Fix | Delete
$data .= $this->buffer->read($remaining);
[111] Fix | Delete
$this->tellPos += \strlen($data) - $readLen;
[112] Fix | Delete
}
[113] Fix | Delete
return $data;
[114] Fix | Delete
}
[115] Fix | Delete
public function getContents() : string
[116] Fix | Delete
{
[117] Fix | Delete
$result = '';
[118] Fix | Delete
while (!$this->eof()) {
[119] Fix | Delete
$result .= $this->read(1000000);
[120] Fix | Delete
}
[121] Fix | Delete
return $result;
[122] Fix | Delete
}
[123] Fix | Delete
/**
[124] Fix | Delete
* @return mixed
[125] Fix | Delete
*/
[126] Fix | Delete
public function getMetadata($key = null)
[127] Fix | Delete
{
[128] Fix | Delete
if (!$key) {
[129] Fix | Delete
return $this->metadata;
[130] Fix | Delete
}
[131] Fix | Delete
return $this->metadata[$key] ?? null;
[132] Fix | Delete
}
[133] Fix | Delete
private function pump(int $length) : void
[134] Fix | Delete
{
[135] Fix | Delete
if ($this->source !== null) {
[136] Fix | Delete
do {
[137] Fix | Delete
$data = ($this->source)($length);
[138] Fix | Delete
if ($data === \false || $data === null) {
[139] Fix | Delete
$this->source = null;
[140] Fix | Delete
return;
[141] Fix | Delete
}
[142] Fix | Delete
$this->buffer->write($data);
[143] Fix | Delete
$length -= \strlen($data);
[144] Fix | Delete
} while ($length > 0);
[145] Fix | Delete
}
[146] Fix | Delete
}
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function