PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 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 All 129 releases
← All changes | vendor_prefixed/guzzlehttp/psr7/src/PumpStream.php +35 -14 27.9 → trunk View file →
@@ -6,18 +6,21 @@
6 6 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
7 7 /**
8 8 * Provides a read only stream that pumps data from a PHP callable.
9 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
10 + * When invoking the provided callable, the PumpStream will pass the suggested
11 + * number of bytes to read to the callable. The callable can choose to ignore
12 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.
13 + * returned by the callable is buffered internally until drained using the
14 + * read() function of the PumpStream. The callable MUST return false or null
15 + * when there is no more data to read.
16 + *
17 + * Userland callables that declare no parameters are tolerated by PHP, but
18 + * length-aware callables remain the recommended formal shape.
16 19 */
17 20 final class PumpStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
18 21 {
19 - /** @var callable(int): (string|false|null)|null */
22 + /** @var callable|null */
20 23 private $source;
21 24 /** @var int|null */
22 25 private $size;
23 26 /** @var int */
@@ -26,16 +29,19 @@
26 29 private $metadata;
27 30 /** @var BufferStream */
28 31 private $buffer;
29 32 /**
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.
33 + * @param (callable(): (string|false|null))|(callable(int): (string|false|null)) $source Source of the stream data. The callable receives
34 + * the suggested number of bytes to read, may ignore
35 + * that value, and may return fewer or more bytes.
36 + * Extra bytes are buffered. The callable MUST return
37 + * a string when called, or false|null on error or EOF.
38 + * Userland callables that declare no parameters are
39 + * tolerated by PHP, but length-aware callables remain
40 + * the recommended formal shape.
41 + * @param array{size?: int, metadata?: array} $options Stream options:
42 + * - metadata: Hash of metadata to use with stream.
43 + * - size: Size of the stream, if known.
38 44 */
39 45 public function __construct(callable $source, array $options = [])
40 46 {
41 47 $this->source = $source;
@@ -86,8 +92,14 @@
86 92 $this->seek(0);
87 93 }
88 94 public function seek($offset, $whence = \SEEK_SET) : void
89 95 {
96 + if (!\is_int($offset)) {
97 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.11', 'Passing %s to StreamInterface::seek() is deprecated; guzzlehttp/psr7 3.0 requires int for $offset.', \get_debug_type($offset));
98 + }
99 + if (!\is_int($whence)) {
100 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.11', 'Passing %s to StreamInterface::seek() is deprecated; guzzlehttp/psr7 3.0 requires int for $whence.', \get_debug_type($whence));
101 + }
90 102 throw new \RuntimeException('Cannot seek a PumpStream');
91 103 }
92 104 public function isWritable() : bool
93 105 {
@@ -94,8 +106,11 @@
94 106 return \false;
95 107 }
96 108 public function write($string) : int
97 109 {
110 + if (!\is_string($string)) {
111 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.11', 'Passing %s to StreamInterface::write() is deprecated; guzzlehttp/psr7 3.0 requires string for $string.', \get_debug_type($string));
112 + }
98 113 throw new \RuntimeException('Cannot write to a PumpStream');
99 114 }
100 115 public function isReadable() : bool
101 116 {
@@ -102,8 +117,11 @@
102 117 return \true;
103 118 }
104 119 public function read($length) : string
105 120 {
121 + if (!\is_int($length)) {
122 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.11', 'Passing %s to StreamInterface::read() is deprecated; guzzlehttp/psr7 3.0 requires int for $length.', \get_debug_type($length));
123 + }
106 124 $data = $this->buffer->read($length);
107 125 $readLen = \strlen($data);
108 126 $this->tellPos += $readLen;
109 127 $remaining = $length - $readLen;
@@ -126,8 +144,11 @@
126 144 * @return mixed
127 145 */
128 146 public function getMetadata($key = null)
129 147 {
148 + if ($key !== null && !\is_string($key)) {
149 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/psr7', '2.11', 'Passing %s to StreamInterface::getMetadata() is deprecated; guzzlehttp/psr7 3.0 requires string|null for $key.', \get_debug_type($key));
150 + }
130 151 if (!$key) {
131 152 return $this->metadata;
132 153 }
133 154 return $this->metadata[$key] ?? null;