PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/guzzlehttp/psr7/src/CachingStream.php +16 -16 1.2.0 → 1.4.2 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2
3 3 declare (strict_types=1);
4 -namespace Dudlewebs\WPMCS\GuzzleHttp\Psr7;
4 +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7;
5 5
6 -use Dudlewebs\WPMCS\Psr\Http\Message\StreamInterface;
6 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\StreamInterface;
7 7 /**
8 8 * Stream decorator that can cache previously read bytes from a sequentially
9 9 * read stream.
10 10 */
@@ -29,21 +29,21 @@
29 29 {
30 30 $this->remoteStream = $stream;
31 31 $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
32 32 }
33 - public function getSize(): ?int
33 + public function getSize() : ?int
34 34 {
35 35 $remoteSize = $this->remoteStream->getSize();
36 36 if (null === $remoteSize) {
37 37 return null;
38 38 }
39 - return max($this->stream->getSize(), $remoteSize);
39 + return \max($this->stream->getSize(), $remoteSize);
40 40 }
41 - public function rewind(): void
41 + public function rewind() : void
42 42 {
43 43 $this->seek(0);
44 44 }
45 - public function seek($offset, $whence = \SEEK_SET): void
45 + public function seek($offset, $whence = \SEEK_SET) : void
46 46 {
47 47 if ($whence === \SEEK_SET) {
48 48 $byte = $offset;
49 49 } elseif ($whence === \SEEK_CUR) {
@@ -69,13 +69,13 @@
69 69 // We can just do a normal seek since we've already seen this byte.
70 70 $this->stream->seek($byte);
71 71 }
72 72 }
73 - public function read($length): string
73 + public function read($length) : string
74 74 {
75 75 // Perform a regular read on any previously read data from the buffer
76 76 $data = $this->stream->read($length);
77 - $remaining = $length - strlen($data);
77 + $remaining = $length - \strlen($data);
78 78 // More data was requested so read from the remote stream
79 79 if ($remaining) {
80 80 // If data was written to the buffer in a position that would have
81 81 // been filled from the remote stream, then we must skip bytes on
@@ -82,11 +82,11 @@
82 82 // the remote stream to emulate overwriting bytes from that
83 83 // position. This mimics the behavior of other PHP stream wrappers.
84 84 $remoteData = $this->remoteStream->read($remaining + $this->skipReadBytes);
85 85 if ($this->skipReadBytes) {
86 - $len = strlen($remoteData);
87 - $remoteData = substr($remoteData, $this->skipReadBytes);
88 - $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
86 + $len = \strlen($remoteData);
87 + $remoteData = \substr($remoteData, $this->skipReadBytes);
88 + $this->skipReadBytes = \max(0, $this->skipReadBytes - $len);
89 89 }
90 90 $data .= $remoteData;
91 91 $this->stream->write($remoteData);
92 92 }
@@ -91,21 +91,21 @@
91 91 $this->stream->write($remoteData);
92 92 }
93 93 return $data;
94 94 }
95 - public function write($string): int
95 + public function write($string) : int
96 96 {
97 97 // When appending to the end of the currently read stream, you'll want
98 98 // to skip bytes from being read from the remote stream to emulate
99 99 // other stream wrappers. Basically replacing bytes of data of a fixed
100 100 // length.
101 - $overflow = strlen($string) + $this->tell() - $this->remoteStream->tell();
101 + $overflow = \strlen($string) + $this->tell() - $this->remoteStream->tell();
102 102 if ($overflow > 0) {
103 103 $this->skipReadBytes += $overflow;
104 104 }
105 105 return $this->stream->write($string);
106 106 }
107 - public function eof(): bool
107 + public function eof() : bool
108 108 {
109 109 return $this->stream->eof() && $this->remoteStream->eof();
110 110 }
111 111 /**
@@ -110,14 +110,14 @@
110 110 }
111 111 /**
112 112 * Close both the remote stream and buffer stream
113 113 */
114 - public function close(): void
114 + public function close() : void
115 115 {
116 116 $this->remoteStream->close();
117 117 $this->stream->close();
118 118 }
119 - private function cacheEntireStream(): int
119 + private function cacheEntireStream() : int
120 120 {
121 121 $target = new FnStream(['write' => 'strlen']);
122 122 Utils::copyToStream($this, $target);
123 123 return $this->tell();