PluginProbe ʕ •ᴥ•ʔ
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 25.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v25.9
27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 19.1 19.10 19.11 19.12 19.13 19.14 19.2 19.3 19.4 19.5 19.5.1 19.6 19.6.1 19.7 19.7.1 19.7.2 19.8 19.9 20.0 20.1 20.10 20.11 20.12 20.13 20.2 20.2.1 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.8.1 21.9 21.9.1 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.8.1 24.9 25.0 25.1 25.2 25.3 25.3.1 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.1.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.1.1 27.2 27.3 27.4
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src / PumpStream.php
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src Last commit date
Exception 2 years ago AppendStream.php 2 years ago BufferStream.php 2 years ago CachingStream.php 2 years ago DroppingStream.php 2 years ago FnStream.php 2 years ago Header.php 2 years ago HttpFactory.php 2 years ago InflateStream.php 2 years ago LazyOpenStream.php 2 years ago LimitStream.php 2 years ago Message.php 2 years ago MessageTrait.php 2 years ago MimeType.php 2 years ago MultipartStream.php 2 years ago NoSeekStream.php 2 years ago PumpStream.php 2 years ago Query.php 2 years ago Request.php 2 years ago Response.php 2 years ago Rfc7230.php 2 years ago ServerRequest.php 2 years ago Stream.php 2 years ago StreamDecoratorTrait.php 2 years ago StreamWrapper.php 2 years ago UploadedFile.php 2 years ago Uri.php 2 years ago UriComparator.php 2 years ago UriNormalizer.php 2 years ago UriResolver.php 2 years ago Utils.php 2 years ago
PumpStream.php
150 lines
1 <?php
2
3 declare (strict_types=1);
4 namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
5
6 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
7 /**
8 * Provides a read only stream that pumps data from a PHP callable.
9 *
10 * When invoking the provided callable, the PumpStream will pass the amount of
11 * data requested to read to the callable. The callable can choose to ignore
12 * this value and return fewer or more bytes than requested. Any extra data
13 * returned by the provided callable is buffered internally until drained using
14 * the read() function of the PumpStream. The provided callable MUST return
15 * false when there is no more data to read.
16 */
17 final class PumpStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
18 {
19 /** @var callable(int): (string|false|null)|null */
20 private $source;
21 /** @var int|null */
22 private $size;
23 /** @var int */
24 private $tellPos = 0;
25 /** @var array */
26 private $metadata;
27 /** @var BufferStream */
28 private $buffer;
29 /**
30 * @param callable(int): (string|false|null) $source Source of the stream data. The callable MAY
31 * accept an integer argument used to control the
32 * amount of data to return. The callable MUST
33 * return a string when called, or false|null on error
34 * or EOF.
35 * @param array{size?: int, metadata?: array} $options Stream options:
36 * - metadata: Hash of metadata to use with stream.
37 * - size: Size of the stream, if known.
38 */
39 public function __construct(callable $source, array $options = [])
40 {
41 $this->source = $source;
42 $this->size = $options['size'] ?? null;
43 $this->metadata = $options['metadata'] ?? [];
44 $this->buffer = new \YoastSEO_Vendor\GuzzleHttp\Psr7\BufferStream();
45 }
46 public function __toString() : string
47 {
48 try {
49 return \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::copyToString($this);
50 } catch (\Throwable $e) {
51 if (\PHP_VERSION_ID >= 70400) {
52 throw $e;
53 }
54 \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
55 return '';
56 }
57 }
58 public function close() : void
59 {
60 $this->detach();
61 }
62 public function detach()
63 {
64 $this->tellPos = 0;
65 $this->source = null;
66 return null;
67 }
68 public function getSize() : ?int
69 {
70 return $this->size;
71 }
72 public function tell() : int
73 {
74 return $this->tellPos;
75 }
76 public function eof() : bool
77 {
78 return $this->source === null;
79 }
80 public function isSeekable() : bool
81 {
82 return \false;
83 }
84 public function rewind() : void
85 {
86 $this->seek(0);
87 }
88 public function seek($offset, $whence = \SEEK_SET) : void
89 {
90 throw new \RuntimeException('Cannot seek a PumpStream');
91 }
92 public function isWritable() : bool
93 {
94 return \false;
95 }
96 public function write($string) : int
97 {
98 throw new \RuntimeException('Cannot write to a PumpStream');
99 }
100 public function isReadable() : bool
101 {
102 return \true;
103 }
104 public function read($length) : string
105 {
106 $data = $this->buffer->read($length);
107 $readLen = \strlen($data);
108 $this->tellPos += $readLen;
109 $remaining = $length - $readLen;
110 if ($remaining) {
111 $this->pump($remaining);
112 $data .= $this->buffer->read($remaining);
113 $this->tellPos += \strlen($data) - $readLen;
114 }
115 return $data;
116 }
117 public function getContents() : string
118 {
119 $result = '';
120 while (!$this->eof()) {
121 $result .= $this->read(1000000);
122 }
123 return $result;
124 }
125 /**
126 * @return mixed
127 */
128 public function getMetadata($key = null)
129 {
130 if (!$key) {
131 return $this->metadata;
132 }
133 return $this->metadata[$key] ?? null;
134 }
135 private function pump(int $length) : void
136 {
137 if ($this->source !== null) {
138 do {
139 $data = ($this->source)($length);
140 if ($data === \false || $data === null) {
141 $this->source = null;
142 return;
143 }
144 $this->buffer->write($data);
145 $length -= \strlen($data);
146 } while ($length > 0);
147 }
148 }
149 }
150