Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../psr7/src
File: StreamWrapper.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
* Converts Guzzle streams into PHP stream resources.
[7] Fix | Delete
*
[8] Fix | Delete
* @final
[9] Fix | Delete
*/
[10] Fix | Delete
class StreamWrapper
[11] Fix | Delete
{
[12] Fix | Delete
/** @var resource */
[13] Fix | Delete
public $context;
[14] Fix | Delete
[15] Fix | Delete
/** @var StreamInterface */
[16] Fix | Delete
private $stream;
[17] Fix | Delete
[18] Fix | Delete
/** @var string r, r+, or w */
[19] Fix | Delete
private $mode;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Returns a resource representing the stream.
[23] Fix | Delete
*
[24] Fix | Delete
* @param StreamInterface $stream The stream to get a resource for
[25] Fix | Delete
*
[26] Fix | Delete
* @return resource
[27] Fix | Delete
*
[28] Fix | Delete
* @throws \InvalidArgumentException if stream is not readable or writable
[29] Fix | Delete
*/
[30] Fix | Delete
public static function getResource(StreamInterface $stream)
[31] Fix | Delete
{
[32] Fix | Delete
self::register();
[33] Fix | Delete
[34] Fix | Delete
if ($stream->isReadable()) {
[35] Fix | Delete
$mode = $stream->isWritable() ? 'r+' : 'r';
[36] Fix | Delete
} elseif ($stream->isWritable()) {
[37] Fix | Delete
$mode = 'w';
[38] Fix | Delete
} else {
[39] Fix | Delete
throw new \InvalidArgumentException('The stream must be readable, '
[40] Fix | Delete
. 'writable, or both.');
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Creates a stream context that can be used to open a stream as a php stream resource.
[48] Fix | Delete
*
[49] Fix | Delete
* @param StreamInterface $stream
[50] Fix | Delete
*
[51] Fix | Delete
* @return resource
[52] Fix | Delete
*/
[53] Fix | Delete
public static function createStreamContext(StreamInterface $stream)
[54] Fix | Delete
{
[55] Fix | Delete
return stream_context_create([
[56] Fix | Delete
'guzzle' => ['stream' => $stream]
[57] Fix | Delete
]);
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Registers the stream wrapper if needed
[62] Fix | Delete
*/
[63] Fix | Delete
public static function register()
[64] Fix | Delete
{
[65] Fix | Delete
if (!in_array('guzzle', stream_get_wrappers())) {
[66] Fix | Delete
stream_wrapper_register('guzzle', __CLASS__);
[67] Fix | Delete
}
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
public function stream_open($path, $mode, $options, &$opened_path)
[71] Fix | Delete
{
[72] Fix | Delete
$options = stream_context_get_options($this->context);
[73] Fix | Delete
[74] Fix | Delete
if (!isset($options['guzzle']['stream'])) {
[75] Fix | Delete
return false;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
$this->mode = $mode;
[79] Fix | Delete
$this->stream = $options['guzzle']['stream'];
[80] Fix | Delete
[81] Fix | Delete
return true;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
public function stream_read($count)
[85] Fix | Delete
{
[86] Fix | Delete
return $this->stream->read($count);
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
public function stream_write($data)
[90] Fix | Delete
{
[91] Fix | Delete
return (int) $this->stream->write($data);
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
public function stream_tell()
[95] Fix | Delete
{
[96] Fix | Delete
return $this->stream->tell();
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
public function stream_eof()
[100] Fix | Delete
{
[101] Fix | Delete
return $this->stream->eof();
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
public function stream_seek($offset, $whence)
[105] Fix | Delete
{
[106] Fix | Delete
$this->stream->seek($offset, $whence);
[107] Fix | Delete
[108] Fix | Delete
return true;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
public function stream_cast($cast_as)
[112] Fix | Delete
{
[113] Fix | Delete
$stream = clone($this->stream);
[114] Fix | Delete
[115] Fix | Delete
return $stream->detach();
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
public function stream_stat()
[119] Fix | Delete
{
[120] Fix | Delete
static $modeMap = [
[121] Fix | Delete
'r' => 33060,
[122] Fix | Delete
'rb' => 33060,
[123] Fix | Delete
'r+' => 33206,
[124] Fix | Delete
'w' => 33188,
[125] Fix | Delete
'wb' => 33188
[126] Fix | Delete
];
[127] Fix | Delete
[128] Fix | Delete
return [
[129] Fix | Delete
'dev' => 0,
[130] Fix | Delete
'ino' => 0,
[131] Fix | Delete
'mode' => $modeMap[$this->mode],
[132] Fix | Delete
'nlink' => 0,
[133] Fix | Delete
'uid' => 0,
[134] Fix | Delete
'gid' => 0,
[135] Fix | Delete
'rdev' => 0,
[136] Fix | Delete
'size' => $this->stream->getSize() ?: 0,
[137] Fix | Delete
'atime' => 0,
[138] Fix | Delete
'mtime' => 0,
[139] Fix | Delete
'ctime' => 0,
[140] Fix | Delete
'blksize' => 0,
[141] Fix | Delete
'blocks' => 0
[142] Fix | Delete
];
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
public function url_stat($path, $flags)
[146] Fix | Delete
{
[147] Fix | Delete
return [
[148] Fix | Delete
'dev' => 0,
[149] Fix | Delete
'ino' => 0,
[150] Fix | Delete
'mode' => 0,
[151] Fix | Delete
'nlink' => 0,
[152] Fix | Delete
'uid' => 0,
[153] Fix | Delete
'gid' => 0,
[154] Fix | Delete
'rdev' => 0,
[155] Fix | Delete
'size' => 0,
[156] Fix | Delete
'atime' => 0,
[157] Fix | Delete
'mtime' => 0,
[158] Fix | Delete
'ctime' => 0,
[159] Fix | Delete
'blksize' => 0,
[160] Fix | Delete
'blocks' => 0
[161] Fix | Delete
];
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function