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/BufferStream.php +39 -21 18.4 → trunk View file →
@@ -1,6 +1,7 @@
1 1 <?php
2 2
3 +declare (strict_types=1);
3 4 namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
4 5
5 6 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
6 7 /**
@@ -9,37 +10,37 @@
9 10 *
10 11 * This stream returns a "hwm" metadata value that tells upstream consumers
11 12 * what the configured high water mark of the stream is, or the maximum
12 13 * preferred size of the buffer.
13 - *
14 - * @final
15 14 */
16 -class BufferStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
15 +final class BufferStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
17 16 {
17 + /** @var int */
18 18 private $hwm;
19 + /** @var string */
19 20 private $buffer = '';
20 21 /**
21 22 * @param int $hwm High water mark, representing the preferred maximum
22 23 * buffer size. If the size of the buffer exceeds the high
23 24 * water mark, then calls to write will continue to succeed
24 - * but will return false to inform writers to slow down
25 + * but will return 0 to inform writers to slow down
25 26 * until the buffer has been drained by reading from it.
26 27 */
27 - public function __construct($hwm = 16384)
28 + public function __construct(int $hwm = 16384)
28 29 {
29 30 $this->hwm = $hwm;
30 31 }
31 - public function __toString()
32 + public function __toString() : string
32 33 {
33 34 return $this->getContents();
34 35 }
35 - public function getContents()
36 + public function getContents() : string
36 37 {
37 38 $buffer = $this->buffer;
38 39 $this->buffer = '';
39 40 return $buffer;
40 41 }
41 - public function close()
42 + public function close() : void
42 43 {
43 44 $this->buffer = '';
44 45 }
45 46 public function detach()
@@ -46,37 +47,43 @@
46 47 {
47 48 $this->close();
48 49 return null;
49 50 }
50 - public function getSize()
51 + public function getSize() : ?int
51 52 {
52 53 return \strlen($this->buffer);
53 54 }
54 - public function isReadable()
55 + public function isReadable() : bool
55 56 {
56 57 return \true;
57 58 }
58 - public function isWritable()
59 + public function isWritable() : bool
59 60 {
60 61 return \true;
61 62 }
62 - public function isSeekable()
63 + public function isSeekable() : bool
63 64 {
64 65 return \false;
65 66 }
66 - public function rewind()
67 + public function rewind() : void
67 68 {
68 69 $this->seek(0);
69 70 }
70 - public function seek($offset, $whence = \SEEK_SET)
71 + public function seek($offset, $whence = \SEEK_SET) : void
71 72 {
73 + if (!\is_int($offset)) {
74 + \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));
75 + }
76 + if (!\is_int($whence)) {
77 + \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));
78 + }
72 79 throw new \RuntimeException('Cannot seek a BufferStream');
73 80 }
74 - public function eof()
81 + public function eof() : bool
75 82 {
76 83 return \strlen($this->buffer) === 0;
77 84 }
78 - public function tell()
85 + public function tell() : int
79 86 {
80 87 throw new \RuntimeException('Cannot determine the position of a BufferStream');
81 88 }
82 89 /**
@@ -81,10 +88,13 @@
81 88 }
82 89 /**
83 90 * Reads data from the buffer.
84 91 */
85 - public function read($length)
92 + public function read($length) : string
86 93 {
94 + if (!\is_int($length)) {
95 + \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));
96 + }
87 97 $currentLength = \strlen($this->buffer);
88 98 if ($length >= $currentLength) {
89 99 // No need to slice the buffer because we don't have enough data.
90 100 $result = $this->buffer;
@@ -98,20 +108,28 @@
98 108 }
99 109 /**
100 110 * Writes data to the buffer.
101 111 */
102 - public function write($string)
112 + public function write($string) : int
103 113 {
114 + if (!\is_string($string)) {
115 + \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));
116 + }
104 117 $this->buffer .= $string;
105 - // TODO: What should happen here?
106 118 if (\strlen($this->buffer) >= $this->hwm) {
107 - return \false;
119 + return 0;
108 120 }
109 121 return \strlen($string);
110 122 }
123 + /**
124 + * @return mixed
125 + */
111 126 public function getMetadata($key = null)
112 127 {
113 - if ($key == 'hwm') {
128 + if ($key !== null && !\is_string($key)) {
129 + \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));
130 + }
131 + if ($key === 'hwm') {
114 132 return $this->hwm;
115 133 }
116 134 return $key ? null : [];
117 135 }