← All changes
|
vendor_prefixed/guzzlehttp/psr7/src/AppendStream.php
+18
-0
27.9
→
trunk
View file →
| @@ -125,8 +125,14 @@ | ||
| 125 | 125 | * Attempts to seek to the given position. Only supports SEEK_SET. |
| 126 | 126 | */ |
| 127 | 127 | public function seek($offset, $whence = \SEEK_SET) : void |
| 128 | 128 | { |
| 129 | + if (!\is_int($offset)) { | |
| 130 | + \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)); | |
| 131 | + } | |
| 132 | + if (!\is_int($whence)) { | |
| 133 | + \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)); | |
| 134 | + } | |
| 129 | 135 | if (!$this->seekable) { |
| 130 | 136 | throw new \RuntimeException('This AppendStream is not seekable'); |
| 131 | 137 | } elseif ($whence !== \SEEK_SET) { |
| 132 | 138 | throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); |
| @@ -152,8 +158,14 @@ | ||
| 152 | 158 | * Reads from all of the appended streams until the length is met or EOF. |
| 153 | 159 | */ |
| 154 | 160 | public function read($length) : string |
| 155 | 161 | { |
| 162 | + if (!\is_int($length)) { | |
| 163 | + \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)); | |
| 164 | + } | |
| 165 | + if ($this->streams === []) { | |
| 166 | + return ''; | |
| 167 | + } | |
| 156 | 168 | $buffer = ''; |
| 157 | 169 | $total = \count($this->streams) - 1; |
| 158 | 170 | $remaining = $length; |
| 159 | 171 | $progressToNext = \false; |
| @@ -190,8 +202,11 @@ | ||
| 190 | 202 | return $this->seekable; |
| 191 | 203 | } |
| 192 | 204 | public function write($string) : int |
| 193 | 205 | { |
| 206 | + if (!\is_string($string)) { | |
| 207 | + \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)); | |
| 208 | + } | |
| 194 | 209 | throw new \RuntimeException('Cannot write to an AppendStream'); |
| 195 | 210 | } |
| 196 | 211 | /** |
| 197 | 212 | * @return mixed |
| @@ -197,7 +212,10 @@ | ||
| 197 | 212 | * @return mixed |
| 198 | 213 | */ |
| 199 | 214 | public function getMetadata($key = null) |
| 200 | 215 | { |
| 216 | + if ($key !== null && !\is_string($key)) { | |
| 217 | + \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)); | |
| 218 | + } | |
| 201 | 219 | return $key ? null : []; |
| 202 | 220 | } |
| 203 | 221 | } |