From b4719a1466c0a07be786ed9950f34e8ccb39277a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 20 Jun 2022 23:29:23 +0200 Subject: [PATCH] Fix deprecation warnings in PHP 8.2 (#519) --- src/CachingStream.php | 5 +++++ src/DroppingStream.php | 3 +++ src/FnStream.php | 1 + src/InflateStream.php | 3 +++ src/LazyOpenStream.php | 1 + src/LimitStream.php | 3 +++ src/MultipartStream.php | 3 +++ src/NoSeekStream.php | 3 +++ tests/StreamDecoratorTraitTest.php | 3 +++ 9 files changed, 25 insertions(+) diff --git a/src/CachingStream.php b/src/CachingStream.php index 7a70ee94..f34722cf 100644 --- a/src/CachingStream.php +++ b/src/CachingStream.php @@ -20,6 +20,11 @@ final class CachingStream implements StreamInterface /** @var int Number of bytes to skip reading due to a write on the buffer */ private $skipReadBytes = 0; + /** + * @var StreamInterface + */ + private $stream; + /** * We will treat the buffer object as the body of the stream * diff --git a/src/DroppingStream.php b/src/DroppingStream.php index d78070ae..6e3d209d 100644 --- a/src/DroppingStream.php +++ b/src/DroppingStream.php @@ -17,6 +17,9 @@ final class DroppingStream implements StreamInterface /** @var int */ private $maxLength; + /** @var StreamInterface */ + private $stream; + /** * @param StreamInterface $stream Underlying stream to decorate. * @param int $maxLength Maximum size before dropping data. diff --git a/src/FnStream.php b/src/FnStream.php index c2156184..3a1a9512 100644 --- a/src/FnStream.php +++ b/src/FnStream.php @@ -12,6 +12,7 @@ * Allows for easy testing and extension of a provided stream without needing * to create a concrete class for a simple extension point. */ +#[\AllowDynamicProperties] final class FnStream implements StreamInterface { private const SLOTS = [ diff --git a/src/InflateStream.php b/src/InflateStream.php index 8e3cf171..8e00f1c3 100644 --- a/src/InflateStream.php +++ b/src/InflateStream.php @@ -21,6 +21,9 @@ final class InflateStream implements StreamInterface { use StreamDecoratorTrait; + /** @var StreamInterface */ + private $stream; + public function __construct(StreamInterface $stream) { $resource = StreamWrapper::getResource($stream); diff --git a/src/LazyOpenStream.php b/src/LazyOpenStream.php index 6b604296..5618331f 100644 --- a/src/LazyOpenStream.php +++ b/src/LazyOpenStream.php @@ -10,6 +10,7 @@ * Lazily reads or writes to a file that is opened only after an IO operation * take place on the stream. */ +#[\AllowDynamicProperties] final class LazyOpenStream implements StreamInterface { use StreamDecoratorTrait; diff --git a/src/LimitStream.php b/src/LimitStream.php index 9762d38a..fb223255 100644 --- a/src/LimitStream.php +++ b/src/LimitStream.php @@ -19,6 +19,9 @@ final class LimitStream implements StreamInterface /** @var int Limit the number of bytes that can be read */ private $limit; + /** @var StreamInterface */ + private $stream; + /** * @param StreamInterface $stream Stream to wrap * @param int $limit Total number of bytes to allow to be read diff --git a/src/MultipartStream.php b/src/MultipartStream.php index 24667075..3ae2c84a 100644 --- a/src/MultipartStream.php +++ b/src/MultipartStream.php @@ -17,6 +17,9 @@ final class MultipartStream implements StreamInterface /** @var string */ private $boundary; + /** @var StreamInterface */ + private $stream; + /** * @param array $elements Array of associative arrays, each containing a * required "name" key mapping to the form field, diff --git a/src/NoSeekStream.php b/src/NoSeekStream.php index 99e25b9e..161a224f 100644 --- a/src/NoSeekStream.php +++ b/src/NoSeekStream.php @@ -13,6 +13,9 @@ final class NoSeekStream implements StreamInterface { use StreamDecoratorTrait; + /** @var StreamInterface */ + private $stream; + public function seek($offset, $whence = SEEK_SET): void { throw new \RuntimeException('Cannot seek a NoSeekStream'); diff --git a/tests/StreamDecoratorTraitTest.php b/tests/StreamDecoratorTraitTest.php index 4e5a9092..e76118ef 100644 --- a/tests/StreamDecoratorTraitTest.php +++ b/tests/StreamDecoratorTraitTest.php @@ -12,6 +12,9 @@ class Str implements StreamInterface { use StreamDecoratorTrait; + + /** @var StreamInterface */ + private $stream; } /**