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: FnStream.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
* Compose stream implementations based on a hash of functions.
[7] Fix | Delete
*
[8] Fix | Delete
* Allows for easy testing and extension of a provided stream without needing
[9] Fix | Delete
* to create a concrete class for a simple extension point.
[10] Fix | Delete
*/
[11] Fix | Delete
#[\AllowDynamicProperties]
[12] Fix | Delete
final class FnStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
[13] Fix | Delete
{
[14] Fix | Delete
private const SLOTS = ['__toString', 'close', 'detach', 'rewind', 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', 'isReadable', 'read', 'getContents', 'getMetadata'];
[15] Fix | Delete
/** @var array<string, callable> */
[16] Fix | Delete
private $methods;
[17] Fix | Delete
/**
[18] Fix | Delete
* @param array<string, callable> $methods Hash of method name to a callable.
[19] Fix | Delete
*/
[20] Fix | Delete
public function __construct(array $methods)
[21] Fix | Delete
{
[22] Fix | Delete
$this->methods = $methods;
[23] Fix | Delete
// Create the functions on the class
[24] Fix | Delete
foreach ($methods as $name => $fn) {
[25] Fix | Delete
$this->{'_fn_' . $name} = $fn;
[26] Fix | Delete
}
[27] Fix | Delete
}
[28] Fix | Delete
/**
[29] Fix | Delete
* Lazily determine which methods are not implemented.
[30] Fix | Delete
*
[31] Fix | Delete
* @throws \BadMethodCallException
[32] Fix | Delete
*/
[33] Fix | Delete
public function __get(string $name) : void
[34] Fix | Delete
{
[35] Fix | Delete
throw new \BadMethodCallException(\str_replace('_fn_', '', $name) . '() is not implemented in the FnStream');
[36] Fix | Delete
}
[37] Fix | Delete
/**
[38] Fix | Delete
* The close method is called on the underlying stream only if possible.
[39] Fix | Delete
*/
[40] Fix | Delete
public function __destruct()
[41] Fix | Delete
{
[42] Fix | Delete
if (isset($this->_fn_close)) {
[43] Fix | Delete
($this->_fn_close)();
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
/**
[47] Fix | Delete
* An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
[48] Fix | Delete
*
[49] Fix | Delete
* @throws \LogicException
[50] Fix | Delete
*/
[51] Fix | Delete
public function __wakeup() : void
[52] Fix | Delete
{
[53] Fix | Delete
throw new \LogicException('FnStream should never be unserialized');
[54] Fix | Delete
}
[55] Fix | Delete
/**
[56] Fix | Delete
* Adds custom functionality to an underlying stream by intercepting
[57] Fix | Delete
* specific method calls.
[58] Fix | Delete
*
[59] Fix | Delete
* @param StreamInterface $stream Stream to decorate
[60] Fix | Delete
* @param array<string, callable> $methods Hash of method name to a closure
[61] Fix | Delete
*
[62] Fix | Delete
* @return FnStream
[63] Fix | Delete
*/
[64] Fix | Delete
public static function decorate(\YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream, array $methods)
[65] Fix | Delete
{
[66] Fix | Delete
// If any of the required methods were not provided, then simply
[67] Fix | Delete
// proxy to the decorated stream.
[68] Fix | Delete
foreach (\array_diff(self::SLOTS, \array_keys($methods)) as $diff) {
[69] Fix | Delete
/** @var callable $callable */
[70] Fix | Delete
$callable = [$stream, $diff];
[71] Fix | Delete
$methods[$diff] = $callable;
[72] Fix | Delete
}
[73] Fix | Delete
return new self($methods);
[74] Fix | Delete
}
[75] Fix | Delete
public function __toString() : string
[76] Fix | Delete
{
[77] Fix | Delete
try {
[78] Fix | Delete
/** @var string */
[79] Fix | Delete
return ($this->_fn___toString)();
[80] Fix | Delete
} catch (\Throwable $e) {
[81] Fix | Delete
if (\PHP_VERSION_ID >= 70400) {
[82] Fix | Delete
throw $e;
[83] Fix | Delete
}
[84] Fix | Delete
\trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
[85] Fix | Delete
return '';
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
public function close() : void
[89] Fix | Delete
{
[90] Fix | Delete
($this->_fn_close)();
[91] Fix | Delete
}
[92] Fix | Delete
public function detach()
[93] Fix | Delete
{
[94] Fix | Delete
return ($this->_fn_detach)();
[95] Fix | Delete
}
[96] Fix | Delete
public function getSize() : ?int
[97] Fix | Delete
{
[98] Fix | Delete
return ($this->_fn_getSize)();
[99] Fix | Delete
}
[100] Fix | Delete
public function tell() : int
[101] Fix | Delete
{
[102] Fix | Delete
return ($this->_fn_tell)();
[103] Fix | Delete
}
[104] Fix | Delete
public function eof() : bool
[105] Fix | Delete
{
[106] Fix | Delete
return ($this->_fn_eof)();
[107] Fix | Delete
}
[108] Fix | Delete
public function isSeekable() : bool
[109] Fix | Delete
{
[110] Fix | Delete
return ($this->_fn_isSeekable)();
[111] Fix | Delete
}
[112] Fix | Delete
public function rewind() : void
[113] Fix | Delete
{
[114] Fix | Delete
($this->_fn_rewind)();
[115] Fix | Delete
}
[116] Fix | Delete
public function seek($offset, $whence = \SEEK_SET) : void
[117] Fix | Delete
{
[118] Fix | Delete
($this->_fn_seek)($offset, $whence);
[119] Fix | Delete
}
[120] Fix | Delete
public function isWritable() : bool
[121] Fix | Delete
{
[122] Fix | Delete
return ($this->_fn_isWritable)();
[123] Fix | Delete
}
[124] Fix | Delete
public function write($string) : int
[125] Fix | Delete
{
[126] Fix | Delete
return ($this->_fn_write)($string);
[127] Fix | Delete
}
[128] Fix | Delete
public function isReadable() : bool
[129] Fix | Delete
{
[130] Fix | Delete
return ($this->_fn_isReadable)();
[131] Fix | Delete
}
[132] Fix | Delete
public function read($length) : string
[133] Fix | Delete
{
[134] Fix | Delete
return ($this->_fn_read)($length);
[135] Fix | Delete
}
[136] Fix | Delete
public function getContents() : string
[137] Fix | Delete
{
[138] Fix | Delete
return ($this->_fn_getContents)();
[139] Fix | Delete
}
[140] Fix | Delete
/**
[141] Fix | Delete
* @return mixed
[142] Fix | Delete
*/
[143] Fix | Delete
public function getMetadata($key = null)
[144] Fix | Delete
{
[145] Fix | Delete
return ($this->_fn_getMetadata)($key);
[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