← All changes
|
vendor_prefixed/guzzlehttp/psr7/src/DroppingStream.php
+10
-5
18.5.1
→
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 | /** |
| @@ -5,26 +6,30 @@ | ||
| 5 | 6 | use YoastSEO_Vendor\Psr\Http\Message\StreamInterface; |
| 6 | 7 | /** |
| 7 | 8 | * Stream decorator that begins dropping data once the size of the underlying |
| 8 | 9 | * stream becomes too full. |
| 9 | - * | |
| 10 | - * @final | |
| 11 | 10 | */ |
| 12 | -class DroppingStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface | |
| 11 | +final class DroppingStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface | |
| 13 | 12 | { |
| 14 | 13 | use StreamDecoratorTrait; |
| 14 | + /** @var int */ | |
| 15 | 15 | private $maxLength; |
| 16 | + /** @var StreamInterface */ | |
| 17 | + private $stream; | |
| 16 | 18 | /** |
| 17 | 19 | * @param StreamInterface $stream Underlying stream to decorate. |
| 18 | 20 | * @param int $maxLength Maximum size before dropping data. |
| 19 | 21 | */ |
| 20 | - public function __construct(\YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream, $maxLength) | |
| 22 | + public function __construct(\YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream, int $maxLength) | |
| 21 | 23 | { |
| 22 | 24 | $this->stream = $stream; |
| 23 | 25 | $this->maxLength = $maxLength; |
| 24 | 26 | } |
| 25 | - public function write($string) | |
| 27 | + public function write($string) : int | |
| 26 | 28 | { |
| 29 | + if (!\is_string($string)) { | |
| 30 | + \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)); | |
| 31 | + } | |
| 27 | 32 | $diff = $this->maxLength - $this->stream->getSize(); |
| 28 | 33 | // Begin returning 0 when the underlying stream is too large. |
| 29 | 34 | if ($diff <= 0) { |
| 30 | 35 | return 0; |