mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Split Packers
to hyperf/codec
(#5666)
This commit is contained in:
parent
ec4a2828d9
commit
cf25b8056e
@ -8,6 +8,7 @@
|
||||
|
||||
- [#5660](https://github.com/hyperf/hyperf/pull/5660) Split `hyperf/codec` from `hyperf/utils`.
|
||||
- [#5663](https://github.com/hyperf/hyperf/pull/5663) Split `hyperf/serializer` from `hyperf/utils`.
|
||||
- [#5666](https://github.com/hyperf/hyperf/pull/5666) Split `Packers` to `hyperf/codec`.
|
||||
|
||||
# v3.0.17 - 2023-04-19
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"doctrine/instantiator": "^1.2.0",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/contract": "~3.0.0",
|
||||
"hyperf/utils": "~3.0.0",
|
||||
"hyperf/process": "~3.0.0",
|
||||
|
@ -14,7 +14,7 @@ namespace Hyperf\Amqp;
|
||||
use Hyperf\Amqp\Listener\BeforeMainServerStartListener;
|
||||
use Hyperf\Amqp\Listener\MainWorkerStartListener;
|
||||
use Hyperf\Amqp\Packer\Packer;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
"php": ">=8.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"psr/event-dispatcher": "^1.0",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/contract": "~3.0.0",
|
||||
"hyperf/command": "~3.0.0",
|
||||
"hyperf/utils": "~3.0.0"
|
||||
|
@ -17,12 +17,12 @@ use Hyperf\AsyncQueue\Event\FailedHandle;
|
||||
use Hyperf\AsyncQueue\Event\QueueLength;
|
||||
use Hyperf\AsyncQueue\Event\RetryHandle;
|
||||
use Hyperf\AsyncQueue\MessageInterface;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
use Hyperf\Process\ProcessManager;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Throwable;
|
||||
|
@ -12,11 +12,11 @@ declare(strict_types=1);
|
||||
namespace HyperfTest\AsyncQueue;
|
||||
|
||||
use Hyperf\AsyncQueue\Driver\ChannelConfig;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\AsyncQueue\Stub\Redis;
|
||||
use HyperfTest\AsyncQueue\Stub\RedisDriverStub;
|
||||
use Mockery;
|
||||
|
@ -15,12 +15,12 @@ use Hyperf\AsyncQueue\Driver\ChannelConfig;
|
||||
use Hyperf\AsyncQueue\Driver\RedisDriver;
|
||||
use Hyperf\AsyncQueue\JobMessage;
|
||||
use Hyperf\AsyncQueue\Message;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Stringable\Str;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\AsyncQueue\Stub\DemoJob;
|
||||
use HyperfTest\AsyncQueue\Stub\DemoModel;
|
||||
use HyperfTest\AsyncQueue\Stub\DemoModelMeta;
|
||||
|
1
src/cache/composer.json
vendored
1
src/cache/composer.json
vendored
@ -18,6 +18,7 @@
|
||||
"php": ">=8.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"psr/simple-cache": "^1.0|^2.0|^3.0",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/contract": "~3.0.0",
|
||||
"hyperf/utils": "~3.0.0"
|
||||
},
|
||||
|
2
src/cache/publish/cache.php
vendored
2
src/cache/publish/cache.php
vendored
@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
return [
|
||||
'default' => [
|
||||
'driver' => Hyperf\Cache\Driver\RedisDriver::class,
|
||||
'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class,
|
||||
'packer' => Hyperf\Codec\Packer\PhpSerializerPacker::class,
|
||||
'prefix' => 'c:',
|
||||
],
|
||||
];
|
||||
|
2
src/cache/src/Driver/Driver.php
vendored
2
src/cache/src/Driver/Driver.php
vendored
@ -12,9 +12,9 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Cache\Driver;
|
||||
|
||||
use Hyperf\Cache\Exception\InvalidArgumentException;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\Utils\InteractsWithTime;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
abstract class Driver implements DriverInterface
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
namespace HyperfTest\Cache\Cases;
|
||||
|
||||
use Hyperf\Cache\Driver\CoroutineMemoryDriver;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
@ -13,12 +13,12 @@ namespace HyperfTest\Cache\Cases;
|
||||
|
||||
use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\FileSystemDriver;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Utils\Filesystem\Filesystem;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\Cache\Stub\Foo;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
2
src/cache/tests/Cases/RedisDriverTest.php
vendored
2
src/cache/tests/Cases/RedisDriverTest.php
vendored
@ -15,6 +15,7 @@ use DateInterval;
|
||||
use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\KeyCollectorInterface;
|
||||
use Hyperf\Cache\Driver\RedisDriver;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
@ -29,7 +30,6 @@ use Hyperf\Redis\Pool\RedisPool;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Redis\RedisProxy;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\Cache\Stub\Foo;
|
||||
use HyperfTest\Cache\Stub\SerializeRedisDriver;
|
||||
use Mockery;
|
||||
|
2
src/cache/tests/Stub/ContainerStub.php
vendored
2
src/cache/tests/Stub/ContainerStub.php
vendored
@ -13,6 +13,7 @@ namespace HyperfTest\Cache\Stub;
|
||||
|
||||
use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\RedisDriver;
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
@ -27,7 +28,6 @@ use Hyperf\Redis\Pool\RedisPool;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Redis\RedisProxy;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Mockery;
|
||||
|
||||
class ContainerStub
|
||||
|
27
src/codec/src/Packer/JsonPacker.php
Normal file
27
src/codec/src/Packer/JsonPacker.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Codec\Packer;
|
||||
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
|
||||
class JsonPacker implements PackerInterface
|
||||
{
|
||||
public function pack($data): string
|
||||
{
|
||||
return json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
public function unpack(string $data)
|
||||
{
|
||||
return json_decode($data, true);
|
||||
}
|
||||
}
|
27
src/codec/src/Packer/PhpSerializerPacker.php
Normal file
27
src/codec/src/Packer/PhpSerializerPacker.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace Hyperf\Codec\Packer;
|
||||
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
|
||||
class PhpSerializerPacker implements PackerInterface
|
||||
{
|
||||
public function pack($data): string
|
||||
{
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
public function unpack(string $data)
|
||||
{
|
||||
return unserialize($data);
|
||||
}
|
||||
}
|
36
src/codec/tests/Packer/JsonPackerTest.php
Normal file
36
src/codec/tests/Packer/JsonPackerTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
namespace HyperfTest\Codec\Packer;
|
||||
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class JsonPackerTest extends TestCase
|
||||
{
|
||||
public function testJsonEncodeAndDecode()
|
||||
{
|
||||
$packer = new JsonPacker();
|
||||
$this->assertSame('{"id":1}', $packer->pack(['id' => 1]));
|
||||
$this->assertSame('123123', $packer->pack(123123));
|
||||
$this->assertSame(['id' => 1], $packer->unpack('{"id":1}'));
|
||||
}
|
||||
|
||||
public function testJsonDecodeFailed()
|
||||
{
|
||||
$packer = new JsonPacker();
|
||||
$this->assertSame(null, $packer->unpack('{"id":1'));
|
||||
}
|
||||
}
|
@ -80,7 +80,7 @@ return [
|
||||
],
|
||||
'etcd' => [
|
||||
'driver' => Hyperf\ConfigEtcd\EtcdDriver::class,
|
||||
'packer' => Hyperf\Utils\Packer\JsonPacker::class,
|
||||
'packer' => Hyperf\Codec\Packer\JsonPacker::class,
|
||||
'namespaces' => [
|
||||
'/application',
|
||||
],
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace HyperfTest\ConfigCenter;
|
||||
|
||||
use Hyperf\Codec\Json;
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\ConfigCenter\DriverFactory;
|
||||
use Hyperf\ConfigEtcd;
|
||||
use Hyperf\ConfigNacos;
|
||||
@ -20,7 +21,6 @@ use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Etcd\KVInterface;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use Mockery;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/config-center": "~3.0.0",
|
||||
"hyperf/etcd": "~3.0.0",
|
||||
"hyperf/utils": "~3.0.0"
|
||||
|
@ -11,9 +11,9 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\ConfigEtcd;
|
||||
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\ConfigCenter\AbstractDriver;
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class EtcdDriver extends AbstractDriver
|
||||
|
@ -18,6 +18,7 @@
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/contract": "~3.0.0",
|
||||
"hyperf/engine": ">=1.3",
|
||||
"hyperf/load-balancer": "~3.0.0",
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\JsonRpc\Listener;
|
||||
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\BootApplication;
|
||||
use Hyperf\JsonRpc\DataFormatter;
|
||||
@ -21,7 +22,6 @@ use Hyperf\JsonRpc\Packer\JsonEofPacker;
|
||||
use Hyperf\JsonRpc\Packer\JsonLengthPacker;
|
||||
use Hyperf\JsonRpc\PathGenerator;
|
||||
use Hyperf\Rpc\ProtocolManager;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
|
||||
class RegisterProtocolListener implements ListenerInterface
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace HyperfTest\JsonRpc;
|
||||
|
||||
use Error;
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Context\Context;
|
||||
@ -41,7 +42,6 @@ use Hyperf\RpcServer\RequestDispatcher;
|
||||
use Hyperf\RpcServer\Router\DispatcherFactory;
|
||||
use Hyperf\Serializer\SerializerFactory;
|
||||
use Hyperf\Serializer\SymfonyNormalizer;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use HyperfTest\JsonRpc\Stub\CalculatorService;
|
||||
use InvalidArgumentException;
|
||||
use Mockery;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace HyperfTest\JsonRpc;
|
||||
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Context\Context;
|
||||
@ -38,7 +39,6 @@ use Hyperf\Rpc\Protocol;
|
||||
use Hyperf\Rpc\ProtocolManager;
|
||||
use Hyperf\RpcServer\Router\DispatcherFactory;
|
||||
use Hyperf\Serializer\SimpleNormalizer;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use HyperfTest\JsonRpc\Stub\CalculatorService;
|
||||
use Mockery;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace HyperfTest\JsonRpc;
|
||||
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
@ -31,7 +32,6 @@ use Hyperf\RpcClient\Exception\RequestException;
|
||||
use Hyperf\RpcClient\ProxyFactory;
|
||||
use Hyperf\Serializer\SerializerFactory;
|
||||
use Hyperf\Serializer\SymfonyNormalizer;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use HyperfTest\JsonRpc\Stub\CalculatorProxyServiceClient;
|
||||
use HyperfTest\JsonRpc\Stub\CalculatorServiceInterface;
|
||||
use HyperfTest\JsonRpc\Stub\IntegerValue;
|
||||
|
@ -18,6 +18,7 @@
|
||||
"php": ">=8.0",
|
||||
"psr/simple-cache": "^1.0|^2.0|^3.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/contract": "~3.0.0",
|
||||
"hyperf/db-connection": "~3.0.0",
|
||||
"hyperf/utils": "~3.0.0"
|
||||
|
@ -11,13 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\ModelCache\Handler;
|
||||
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Contract\Arrayable;
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\ModelCache\Config;
|
||||
use Hyperf\ModelCache\Exception\CacheException;
|
||||
use Hyperf\Redis\RedisProxy;
|
||||
use Hyperf\Utils\InteractsWithTime;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class RedisStringHandler implements HandlerInterface
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace HyperfTest\ModelCache\Stub;
|
||||
|
||||
use Hyperf\Codec\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
@ -44,7 +45,6 @@ use Hyperf\Pool\Channel;
|
||||
use Hyperf\Pool\PoolOption;
|
||||
use Hyperf\Redis\Pool\RedisPool;
|
||||
use Hyperf\Redis\RedisProxy;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Mockery;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
|
@ -22,6 +22,7 @@
|
||||
"php": ">=8.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"hyperf/codec": "~3.0.0",
|
||||
"hyperf/contract": "~3.0.0",
|
||||
"hyperf/http-message": "~3.0.0",
|
||||
"hyperf/http-server": "~3.0.0",
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Testing;
|
||||
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
@ -27,7 +28,6 @@ use Hyperf\HttpServer\Router\Dispatched;
|
||||
use Hyperf\HttpServer\Server;
|
||||
use Hyperf\Testing\HttpMessage\Upload\UploadedFile;
|
||||
use Hyperf\Utils\Filesystem\Filesystem;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
@ -12,11 +12,11 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Testing;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Hyperf\Codec\Packer\JsonPacker;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\Coroutine\Coroutine;
|
||||
use Hyperf\Guzzle\CoroutineHandler;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
|
@ -11,17 +11,9 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Utils\Packer;
|
||||
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
|
||||
class JsonPacker implements PackerInterface
|
||||
/**
|
||||
* @deprecated since 3.1. Use Hyperf\Codec\Packer\JsonPacker instead.
|
||||
*/
|
||||
class JsonPacker extends \Hyperf\Codec\Packer\JsonPacker
|
||||
{
|
||||
public function pack($data): string
|
||||
{
|
||||
return json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
public function unpack(string $data)
|
||||
{
|
||||
return json_decode($data, true);
|
||||
}
|
||||
}
|
||||
|
@ -11,17 +11,9 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Utils\Packer;
|
||||
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
|
||||
class PhpSerializerPacker implements PackerInterface
|
||||
/**
|
||||
* @deprecated since 3.1. Use Hyperf\Codec\Packer\PhpSerializerPacker instead.
|
||||
*/
|
||||
class PhpSerializerPacker extends \Hyperf\Codec\Packer\PhpSerializerPacker
|
||||
{
|
||||
public function pack($data): string
|
||||
{
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
public function unpack(string $data)
|
||||
{
|
||||
return unserialize($data);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user