← All changes
|
vendor_prefixed/guzzlehttp/psr7/src/BufferStream.php
+15
-0
27.5
→
trunk
View file →
| @@ -69,8 +69,14 @@ | ||
| 69 | 69 | $this->seek(0); |
| 70 | 70 | } |
| 71 | 71 | public function seek($offset, $whence = \SEEK_SET) : void |
| 72 | 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 | + } | |
| 73 | 79 | throw new \RuntimeException('Cannot seek a BufferStream'); |
| 74 | 80 | } |
| 75 | 81 | public function eof() : bool |
| 76 | 82 | { |
| @@ -84,8 +90,11 @@ | ||
| 84 | 90 | * Reads data from the buffer. |
| 85 | 91 | */ |
| 86 | 92 | public function read($length) : string |
| 87 | 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 | + } | |
| 88 | 97 | $currentLength = \strlen($this->buffer); |
| 89 | 98 | if ($length >= $currentLength) { |
| 90 | 99 | // No need to slice the buffer because we don't have enough data. |
| 91 | 100 | $result = $this->buffer; |
| @@ -101,8 +110,11 @@ | ||
| 101 | 110 | * Writes data to the buffer. |
| 102 | 111 | */ |
| 103 | 112 | public function write($string) : int |
| 104 | 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 | + } | |
| 105 | 117 | $this->buffer .= $string; |
| 106 | 118 | if (\strlen($this->buffer) >= $this->hwm) { |
| 107 | 119 | return 0; |
| 108 | 120 | } |
| @@ -112,8 +124,11 @@ | ||
| 112 | 124 | * @return mixed |
| 113 | 125 | */ |
| 114 | 126 | public function getMetadata($key = null) |
| 115 | 127 | { |
| 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 | + } | |
| 116 | 131 | if ($key === 'hwm') { |
| 117 | 132 | return $this->hwm; |
| 118 | 133 | } |
| 119 | 134 | return $key ? null : []; |