diff --git a/CHANGELOG-2.2.md b/CHANGELOG-2.2.md index ae4db60a0..ce952e709 100644 --- a/CHANGELOG-2.2.md +++ b/CHANGELOG-2.2.md @@ -15,6 +15,10 @@ - Changed the default priority of aspect to 0. - Changed the consumer tag of amqp to empty string. +## Deprecated + +- `Hyperf\Utils\Resource` will be deprecated in v2.3, please use `Hyperf\Utils\ResourceGenerator` instead. + ## Added - [#3589](https://github.com/hyperf/hyperf/pull/3589) Added DAG component. diff --git a/src/guzzle/src/RingPHP/CoroutineHandler.php b/src/guzzle/src/RingPHP/CoroutineHandler.php index a09365849..ce22fe5b1 100644 --- a/src/guzzle/src/RingPHP/CoroutineHandler.php +++ b/src/guzzle/src/RingPHP/CoroutineHandler.php @@ -16,7 +16,7 @@ use GuzzleHttp\Ring\Exception\RingException; use GuzzleHttp\Ring\Future\CompletedFutureArray; use Hyperf\Engine\Http\Client; use Hyperf\Engine\Http\RawResponse; -use Hyperf\Utils\Resource; +use Hyperf\Utils\ResourceGenerator; /** * Http handler that uses Swoole Coroutine as a transport layer. @@ -147,7 +147,7 @@ class CoroutineHandler 'effective_url' => $effectiveUrl, 'headers' => $response->headers, 'status' => $response->statusCode, - 'body' => Resource::from($response->body), + 'body' => ResourceGenerator::from($response->body), ]); } } diff --git a/src/utils/composer.json b/src/utils/composer.json index 8d348989c..b16aed97e 100644 --- a/src/utils/composer.json +++ b/src/utils/composer.json @@ -26,7 +26,8 @@ "symfony/var-dumper": "Required to use the dd function (^5.0).", "symfony/serializer": "Required to use SymfonyNormalizer (^5.0)", "symfony/property-access": "Required to use SymfonyNormalizer (^5.0)", - "hyperf/di": "Required to use ExceptionNormalizer" + "hyperf/di": "Required to use ExceptionNormalizer", + "nikic/php-parser": "Required to use PhpParser. (^4.0)" }, "autoload": { "files": [ diff --git a/src/utils/src/Resource.php b/src/utils/src/Resource.php index 7376b901b..92aa8223b 100644 --- a/src/utils/src/Resource.php +++ b/src/utils/src/Resource.php @@ -11,6 +11,9 @@ declare(strict_types=1); */ namespace Hyperf\Utils; +/** + * @deprecated v2.3, please use ResourceGenerator instead. + */ class Resource { /** diff --git a/src/utils/src/ResourceGenerator.php b/src/utils/src/ResourceGenerator.php new file mode 100644 index 000000000..ed7193d97 --- /dev/null +++ b/src/utils/src/ResourceGenerator.php @@ -0,0 +1,34 @@ +assertSame('1', fread($resource, 1)); $this->assertSame('23', fread($resource, 2)); $this->assertSame('123', fread($resource, 10)); @@ -34,7 +34,7 @@ class ResourceTest extends TestCase $data = str_repeat('1', 1024 * 1024); $memory = memory_get_usage(true); for ($i = 0; $i < 100; ++$i) { - Resource::fromMemory($data); + ResourceGenerator::fromMemory($data); $current = memory_get_usage(true); $leak = $current - $memory; $memory = $current;