Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../psr7/src
File: FnStream.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Psr7;
[2] Fix | Delete
[3] Fix | Delete
use Psr\Http\Message\StreamInterface;
[4] Fix | Delete
[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
* @final
[12] Fix | Delete
*/
[13] Fix | Delete
class FnStream implements StreamInterface
[14] Fix | Delete
{
[15] Fix | Delete
/** @var array */
[16] Fix | Delete
private $methods;
[17] Fix | Delete
[18] Fix | Delete
/** @var array Methods that must be implemented in the given array */
[19] Fix | Delete
private static $slots = ['__toString', 'close', 'detach', 'rewind',
[20] Fix | Delete
'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
[21] Fix | Delete
'isReadable', 'read', 'getContents', 'getMetadata'];
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* @param array $methods Hash of method name to a callable.
[25] Fix | Delete
*/
[26] Fix | Delete
public function __construct(array $methods)
[27] Fix | Delete
{
[28] Fix | Delete
$this->methods = $methods;
[29] Fix | Delete
[30] Fix | Delete
// Create the functions on the class
[31] Fix | Delete
foreach ($methods as $name => $fn) {
[32] Fix | Delete
$this->{'_fn_' . $name} = $fn;
[33] Fix | Delete
}
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Lazily determine which methods are not implemented.
[38] Fix | Delete
*
[39] Fix | Delete
* @throws \BadMethodCallException
[40] Fix | Delete
*/
[41] Fix | Delete
public function __get($name)
[42] Fix | Delete
{
[43] Fix | Delete
throw new \BadMethodCallException(str_replace('_fn_', '', $name)
[44] Fix | Delete
. '() is not implemented in the FnStream');
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* The close method is called on the underlying stream only if possible.
[49] Fix | Delete
*/
[50] Fix | Delete
public function __destruct()
[51] Fix | Delete
{
[52] Fix | Delete
if (isset($this->_fn_close)) {
[53] Fix | Delete
call_user_func($this->_fn_close);
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
[59] Fix | Delete
*
[60] Fix | Delete
* @throws \LogicException
[61] Fix | Delete
*/
[62] Fix | Delete
public function __wakeup()
[63] Fix | Delete
{
[64] Fix | Delete
throw new \LogicException('FnStream should never be unserialized');
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Adds custom functionality to an underlying stream by intercepting
[69] Fix | Delete
* specific method calls.
[70] Fix | Delete
*
[71] Fix | Delete
* @param StreamInterface $stream Stream to decorate
[72] Fix | Delete
* @param array $methods Hash of method name to a closure
[73] Fix | Delete
*
[74] Fix | Delete
* @return FnStream
[75] Fix | Delete
*/
[76] Fix | Delete
public static function decorate(StreamInterface $stream, array $methods)
[77] Fix | Delete
{
[78] Fix | Delete
// If any of the required methods were not provided, then simply
[79] Fix | Delete
// proxy to the decorated stream.
[80] Fix | Delete
foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
[81] Fix | Delete
$methods[$diff] = [$stream, $diff];
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
return new self($methods);
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
public function __toString()
[88] Fix | Delete
{
[89] Fix | Delete
return call_user_func($this->_fn___toString);
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
public function close()
[93] Fix | Delete
{
[94] Fix | Delete
return call_user_func($this->_fn_close);
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
public function detach()
[98] Fix | Delete
{
[99] Fix | Delete
return call_user_func($this->_fn_detach);
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
public function getSize()
[103] Fix | Delete
{
[104] Fix | Delete
return call_user_func($this->_fn_getSize);
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
public function tell()
[108] Fix | Delete
{
[109] Fix | Delete
return call_user_func($this->_fn_tell);
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
public function eof()
[113] Fix | Delete
{
[114] Fix | Delete
return call_user_func($this->_fn_eof);
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
public function isSeekable()
[118] Fix | Delete
{
[119] Fix | Delete
return call_user_func($this->_fn_isSeekable);
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
public function rewind()
[123] Fix | Delete
{
[124] Fix | Delete
call_user_func($this->_fn_rewind);
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
public function seek($offset, $whence = SEEK_SET)
[128] Fix | Delete
{
[129] Fix | Delete
call_user_func($this->_fn_seek, $offset, $whence);
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
public function isWritable()
[133] Fix | Delete
{
[134] Fix | Delete
return call_user_func($this->_fn_isWritable);
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
public function write($string)
[138] Fix | Delete
{
[139] Fix | Delete
return call_user_func($this->_fn_write, $string);
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
public function isReadable()
[143] Fix | Delete
{
[144] Fix | Delete
return call_user_func($this->_fn_isReadable);
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
public function read($length)
[148] Fix | Delete
{
[149] Fix | Delete
return call_user_func($this->_fn_read, $length);
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
public function getContents()
[153] Fix | Delete
{
[154] Fix | Delete
return call_user_func($this->_fn_getContents);
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
public function getMetadata($key = null)
[158] Fix | Delete
{
[159] Fix | Delete
return call_user_func($this->_fn_getMetadata, $key);
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function