From dc07fdb06839d3bb21b7e1e4006183e8c77738aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 22 Apr 2020 17:24:58 +0200 Subject: [PATCH] Remove deprecated APIs and mark ZlibFilterStream as internal only --- README.md | 60 ------------------- src/Compressor.php | 4 -- src/Decompressor.php | 4 -- src/ZlibFilterStream.php | 58 +----------------- ...orTest.php => DeflateDecompressorTest.php} | 6 +- ...essorTest.php => DelateCompressorTest.php} | 6 +- ...pressorTest.php => GzipCompressorTest.php} | 6 +- ...essorTest.php => GzipDecompressorTest.php} | 6 +- ...pressorTest.php => ZlibCompressorTest.php} | 6 +- ...essorTest.php => ZlibDecompressorTest.php} | 6 +- 10 files changed, 20 insertions(+), 142 deletions(-) rename tests/{ZlibFilterDeflateDecompressorTest.php => DeflateDecompressorTest.php} (89%) rename tests/{ZlibFilterDeflateCompressorTest.php => DelateCompressorTest.php} (87%) rename tests/{ZlibFilterGzipCompressorTest.php => GzipCompressorTest.php} (90%) rename tests/{ZlibFilterGzipDecompressorTest.php => GzipDecompressorTest.php} (90%) rename tests/{ZlibFilterZlibCompressorTest.php => ZlibCompressorTest.php} (88%) rename tests/{ZlibFilterZlibDecompressorTest.php => ZlibDecompressorTest.php} (90%) diff --git a/README.md b/README.md index d8cf1f4..5e6f927 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,6 @@ supporting compression and decompression of GZIP, ZLIB and raw DEFLATE formats. * [Usage](#usage) * [Compressor](#compressor) * [Decompressor](#decompressor) - * [ZlibFilterStream](#zlibfilterstream) - * [createCompressor()](#createcompressor) - * [createDecompressor()](#createdecompressor) * [Inconsistencies](#inconsistencies) * [Install](#install) * [Tests](#tests) @@ -137,10 +134,6 @@ $input->pipe($filterBadWords)->pipe($compressor)->pipe($output); For more details, see ReactPHP's [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface). -> Internally, it implements the deprecated `ZlibFilterStream` class only for - BC reasons. For best forwards compatibility, you should only rely on it - implementing the `DuplexStreamInterface`. - ### Decompressor The `Decompressor` class can be used to decompress a stream of data. @@ -169,59 +162,6 @@ $input->pipe($decompressor)->pipe($filterBadWords)->pipe($output); For more details, see ReactPHP's [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface). -> Internally, it implements the deprecated `ZlibFilterStream` class only for - BC reasons. For best forwards compatibility, you should only rely on it - implementing the `DuplexStreamInterface`. - -### ZlibFilterStream - -The deprecated `ZlibFilterStream` is a small wrapper around the underlying `zlib.deflate` and `zlib.inflate` -stream compression filters offered via `ext-zlib`. - -#### createCompressor() - -The following deprecated methods can be used to -create a `Compressor` instance with the respective encoding parameter: - -```php -// deprecated -$compressor = ZlibFilterStream::createGzipCompressor(); -$compressor = ZlibFilterStream::createDeflateCompressor(); -$compressor = ZlibFilterStream::createZlibCompressor(); -``` - -Using any of these methods is deprecated. -Instead, you should explicitly create a `Compressor` like this: - -```php -$encoding = ZLIB_ENCODING_GZIP; // or ZLIB_ENCODING_RAW or ZLIB_ENCODING_DEFLATE -$compressor = new Clue\React\Zlib\Compressor($encoding); -``` - -See also [`Compressor`](#compressor) for more details. - -#### createDecompressor() - -The following deprecated methods can be used to -create a `Decompressor` instanceof with the respective encoding parameter: - -```php -// deprecated -$decompressor = ZlibFilterStream::createGzipDecompressor(); -$decompressor = ZlibFilterStream::createDeflateDecompressor(); -$decompressor = ZlibFilterStream::createZlibDecompressor(); -``` - -Using any of these methods is deprecated. -Instead, you should explicitly create a `Decompressor` like this: - -```php -$encoding = ZLIB_ENCODING_GZIP; // or ZLIB_ENCODING_RAW or ZLIB_ENCODING_DEFLATE -$decompressor = new Clue\React\Zlib\Decompressor($encoding); -``` - -See also [`Compressor`](#compressor) for more details. - ### Inconsistencies The stream compression filters are not exactly the most commonly used features of PHP. diff --git a/src/Compressor.php b/src/Compressor.php index 22b518f..5cf7135 100644 --- a/src/Compressor.php +++ b/src/Compressor.php @@ -30,10 +30,6 @@ * * For more details, see ReactPHP's * [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface). - * - * > Internally, it implements the deprecated `ZlibFilterStream` class only for - * BC reasons. For best forwards compatibility, you should only rely on it - * implementing the `DuplexStreamInterface`. */ final class Compressor extends ZlibFilterStream { diff --git a/src/Decompressor.php b/src/Decompressor.php index 76667c4..cd05891 100644 --- a/src/Decompressor.php +++ b/src/Decompressor.php @@ -30,10 +30,6 @@ * * For more details, see ReactPHP's * [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface). - * - * > Internally, it implements the deprecated `ZlibFilterStream` class only for - * BC reasons. For best forwards compatibility, you should only rely on it - * implementing the `DuplexStreamInterface`. */ final class Decompressor extends ZlibFilterStream { diff --git a/src/ZlibFilterStream.php b/src/ZlibFilterStream.php index ea497c2..d53159e 100644 --- a/src/ZlibFilterStream.php +++ b/src/ZlibFilterStream.php @@ -3,7 +3,7 @@ namespace Clue\React\Zlib; /** - * Compressor and decompressor using PHP's zlib compression filters. + * [Internal] Compressor and decompressor using PHP's zlib compression filters. * * Supports the following compression formats: * @@ -11,67 +11,13 @@ * RFC 1951 (raw DEFLATE compressed format) * RFC 1950 (ZLIB compressed format) * + * @internal Should not be relied upon outside of this package. * @link http://php.net/manual/en/filters.compression.php - * @deprecated 0.2.2 External usage of `ZlibFilterStream` is deprecated, use `Compressor` or `Decompressor` instead. * @see Compressor * @see Decompressor */ class ZlibFilterStream extends TransformStream { - /** - * @deprecated - * @return self - */ - public static function createGzipCompressor($level = -1) - { - return new Compressor(ZLIB_ENCODING_GZIP, $level); - } - - /** - * @deprecated - * @return self - */ - public static function createGzipDecompressor() - { - return new Decompressor(ZLIB_ENCODING_GZIP); - } - - /** - * @deprecated - * @return self - */ - public static function createDeflateCompressor($level = -1) - { - return new Compressor(ZLIB_ENCODING_RAW, $level); - } - - /** - * @deprecated - * @return self - */ - public static function createDeflateDecompressor() - { - return new Decompressor(ZLIB_ENCODING_RAW); - } - - /** - * @deprecated - * @return self - */ - public static function createZlibCompressor($level = -1) - { - return new Compressor(ZLIB_ENCODING_DEFLATE, $level); - } - - /** - * @deprecated - * @return self - */ - public static function createZlibDecompressor() - { - return new Decompressor(ZLIB_ENCODING_DEFLATE); - } - private $filter; /** diff --git a/tests/ZlibFilterDeflateDecompressorTest.php b/tests/DeflateDecompressorTest.php similarity index 89% rename from tests/ZlibFilterDeflateDecompressorTest.php rename to tests/DeflateDecompressorTest.php index 84e5d96..63012f9 100644 --- a/tests/ZlibFilterDeflateDecompressorTest.php +++ b/tests/DeflateDecompressorTest.php @@ -1,14 +1,14 @@ decompressor = ZlibFilterStream::createDeflateDecompressor(); + $this->decompressor = new Decompressor(ZLIB_ENCODING_RAW); } public function testInflateEmpty() diff --git a/tests/ZlibFilterDeflateCompressorTest.php b/tests/DelateCompressorTest.php similarity index 87% rename from tests/ZlibFilterDeflateCompressorTest.php rename to tests/DelateCompressorTest.php index 2d4aa26..cc8af6a 100644 --- a/tests/ZlibFilterDeflateCompressorTest.php +++ b/tests/DelateCompressorTest.php @@ -1,14 +1,14 @@ compressor = ZlibFilterStream::createDeflateCompressor(); + $this->compressor = new Compressor(ZLIB_ENCODING_RAW); } public function testDeflateEmpty() diff --git a/tests/ZlibFilterGzipCompressorTest.php b/tests/GzipCompressorTest.php similarity index 90% rename from tests/ZlibFilterGzipCompressorTest.php rename to tests/GzipCompressorTest.php index 5c701a3..28fa560 100644 --- a/tests/ZlibFilterGzipCompressorTest.php +++ b/tests/GzipCompressorTest.php @@ -1,14 +1,14 @@ compressor = ZlibFilterStream::createGzipCompressor(); + $this->compressor = new Compressor(ZLIB_ENCODING_GZIP); } public function testCompressEmpty() diff --git a/tests/ZlibFilterGzipDecompressorTest.php b/tests/GzipDecompressorTest.php similarity index 90% rename from tests/ZlibFilterGzipDecompressorTest.php rename to tests/GzipDecompressorTest.php index 4730299..40277d1 100644 --- a/tests/ZlibFilterGzipDecompressorTest.php +++ b/tests/GzipDecompressorTest.php @@ -1,14 +1,14 @@ decompressor = ZlibFilterStream::createGzipDecompressor(); + $this->decompressor = new Decompressor(ZLIB_ENCODING_GZIP); } public function testDecompressEmpty() diff --git a/tests/ZlibFilterZlibCompressorTest.php b/tests/ZlibCompressorTest.php similarity index 88% rename from tests/ZlibFilterZlibCompressorTest.php rename to tests/ZlibCompressorTest.php index f218bba..2272438 100644 --- a/tests/ZlibFilterZlibCompressorTest.php +++ b/tests/ZlibCompressorTest.php @@ -1,14 +1,14 @@ compressor = ZlibFilterStream::createZlibCompressor(); + $this->compressor = new Compressor(ZLIB_ENCODING_DEFLATE); } public function testCompressEmpty() diff --git a/tests/ZlibFilterZlibDecompressorTest.php b/tests/ZlibDecompressorTest.php similarity index 90% rename from tests/ZlibFilterZlibDecompressorTest.php rename to tests/ZlibDecompressorTest.php index a6c1f9a..370004f 100644 --- a/tests/ZlibFilterZlibDecompressorTest.php +++ b/tests/ZlibDecompressorTest.php @@ -1,14 +1,14 @@ decompressor = ZlibFilterStream::createZlibDecompressor(); + $this->decompressor = new Decompressor(ZLIB_ENCODING_DEFLATE); } public function testDecompressEmpty()