From c203b2fe65dc4e48a49e4944e897802bc93ef7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Tue, 16 Jan 2024 10:24:44 +0800 Subject: [PATCH] Format code --- bin/hyperf.php | 15 +++++++++++---- config/autoload/annotations.php | 7 +++++-- config/autoload/async_queue.php | 4 +++- config/autoload/cache.php | 7 +++++-- config/autoload/databases.php | 4 +++- config/autoload/dependencies.php | 13 ++++++++++--- config/autoload/exceptions.php | 4 +++- config/autoload/listeners.php | 7 +++++-- config/autoload/logger.php | 13 ++++++++----- config/autoload/processes.php | 4 +++- config/autoload/server.php | 15 ++++++++++----- test/HttpTestCase.php | 4 ++-- test/bootstrap.php | 10 +++++++--- 13 files changed, 75 insertions(+), 32 deletions(-) diff --git a/bin/hyperf.php b/bin/hyperf.php index e845849..6978a67 100644 --- a/bin/hyperf.php +++ b/bin/hyperf.php @@ -1,5 +1,7 @@ #!/usr/bin/env php get(Hyperf\Contract\ApplicationInterface::class); + /** @var Application $application */ + $application = $container->get(ApplicationInterface::class); $application->run(); })(); diff --git a/config/autoload/annotations.php b/config/autoload/annotations.php index cf4c101..c635126 100644 --- a/config/autoload/annotations.php +++ b/config/autoload/annotations.php @@ -9,6 +9,9 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Coroutine\Coroutine; +use Hyperf\Di\Resolver\ResolverDispatcher; + return [ 'scan' => [ 'paths' => [ @@ -18,8 +21,8 @@ 'mixin', ], 'class_map' => [ - Hyperf\Coroutine\Coroutine::class => BASE_PATH . '/app/Kernel/ClassMap/Coroutine.php', - Hyperf\Di\Resolver\ResolverDispatcher::class => BASE_PATH . '/app/Kernel/ClassMap/ResolverDispatcher.php', + Coroutine::class => BASE_PATH . '/app/Kernel/ClassMap/Coroutine.php', + ResolverDispatcher::class => BASE_PATH . '/app/Kernel/ClassMap/ResolverDispatcher.php', ], ], ]; diff --git a/config/autoload/async_queue.php b/config/autoload/async_queue.php index 4f90931..36bf691 100644 --- a/config/autoload/async_queue.php +++ b/config/autoload/async_queue.php @@ -9,9 +9,11 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\AsyncQueue\Driver\RedisDriver; + return [ 'default' => [ - 'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class, + 'driver' => RedisDriver::class, 'channel' => '{queue}', 'timeout' => 2, 'retry_seconds' => 5, diff --git a/config/autoload/cache.php b/config/autoload/cache.php index 471228c..48edb8e 100644 --- a/config/autoload/cache.php +++ b/config/autoload/cache.php @@ -9,10 +9,13 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Cache\Driver\RedisDriver; +use Hyperf\Codec\Packer\PhpSerializerPacker; + return [ 'default' => [ - 'driver' => Hyperf\Cache\Driver\RedisDriver::class, - 'packer' => Hyperf\Codec\Packer\PhpSerializerPacker::class, + 'driver' => RedisDriver::class, + 'packer' => PhpSerializerPacker::class, 'prefix' => 'c:', ], ]; diff --git a/config/autoload/databases.php b/config/autoload/databases.php index 2aa2566..6ffc83f 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -9,6 +9,8 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\ModelCache\Handler\RedisHandler; + use function Hyperf\Support\env; return [ @@ -31,7 +33,7 @@ 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60), ], 'cache' => [ - 'handler' => Hyperf\ModelCache\Handler\RedisHandler::class, + 'handler' => RedisHandler::class, 'cache_key' => '{mc:%s:m:%s}:%s:%s', 'prefix' => 'default', 'ttl' => 3600 * 24, diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index 497f966..74c2561 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -9,8 +9,15 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use App\Kernel\Event\EventDispatcherFactory; +use App\Kernel\Http\WorkerStartListener; +use App\Kernel\Log\LoggerFactory; +use Hyperf\Contract\StdoutLoggerInterface; +use Hyperf\Server\Listener\AfterWorkerStartListener; +use Psr\EventDispatcher\EventDispatcherInterface; + return [ - Hyperf\Contract\StdoutLoggerInterface::class => App\Kernel\Log\LoggerFactory::class, - Hyperf\Server\Listener\AfterWorkerStartListener::class => App\Kernel\Http\WorkerStartListener::class, - Psr\EventDispatcher\EventDispatcherInterface::class => App\Kernel\Event\EventDispatcherFactory::class, + StdoutLoggerInterface::class => LoggerFactory::class, + AfterWorkerStartListener::class => WorkerStartListener::class, + EventDispatcherInterface::class => EventDispatcherFactory::class, ]; diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index f63d2af..28b4a10 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -9,10 +9,12 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use App\Exception\Handler\BusinessExceptionHandler; + return [ 'handler' => [ 'http' => [ - App\Exception\Handler\BusinessExceptionHandler::class, + BusinessExceptionHandler::class, ], ], ]; diff --git a/config/autoload/listeners.php b/config/autoload/listeners.php index 8a2c7a2..d8c91d7 100644 --- a/config/autoload/listeners.php +++ b/config/autoload/listeners.php @@ -9,7 +9,10 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Command\Listener\FailToHandleListener; +use Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler; + return [ - Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::class, - Hyperf\Command\Listener\FailToHandleListener::class, + ErrorExceptionHandler::class, + FailToHandleListener::class, ]; diff --git a/config/autoload/logger.php b/config/autoload/logger.php index 1bb2978..ff28b3d 100644 --- a/config/autoload/logger.php +++ b/config/autoload/logger.php @@ -9,19 +9,22 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ -use App\Kernel\Log; +use App\Kernel\Log\AppendRequestIdProcessor; +use Monolog\Formatter\LineFormatter; +use Monolog\Handler\StreamHandler; +use Monolog\Level; return [ 'default' => [ 'handler' => [ - 'class' => Monolog\Handler\StreamHandler::class, + 'class' => StreamHandler::class, 'constructor' => [ 'stream' => BASE_PATH . '/runtime/logs/hyperf.log', - 'level' => Monolog\Level::Info, + 'level' => Level::Info, ], ], 'formatter' => [ - 'class' => Monolog\Formatter\LineFormatter::class, + 'class' => LineFormatter::class, 'constructor' => [ 'format' => null, 'dateFormat' => 'Y-m-d H:i:s', @@ -30,7 +33,7 @@ ], 'processors' => [ [ - 'class' => Log\AppendRequestIdProcessor::class, + 'class' => AppendRequestIdProcessor::class, ], ], ], diff --git a/config/autoload/processes.php b/config/autoload/processes.php index d907369..00543d3 100644 --- a/config/autoload/processes.php +++ b/config/autoload/processes.php @@ -9,6 +9,8 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\AsyncQueue\Process\ConsumerProcess; + return [ - Hyperf\AsyncQueue\Process\ConsumerProcess::class, + ConsumerProcess::class, ]; diff --git a/config/autoload/server.php b/config/autoload/server.php index b279dce..d8a9fde 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -10,12 +10,17 @@ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ use Hyperf\Engine\Constant\SocketType; +use Hyperf\Framework\Bootstrap\PipeMessageCallback; +use Hyperf\Framework\Bootstrap\ServerStartCallback; +use Hyperf\Framework\Bootstrap\WorkerExitCallback; +use Hyperf\Framework\Bootstrap\WorkerStartCallback; +use Hyperf\Server\CoroutineServer; use Hyperf\Server\Event; use Hyperf\Server\Server; return [ 'mode' => SWOOLE_BASE, - 'type' => Hyperf\Server\CoroutineServer::class, + 'type' => CoroutineServer::class, 'servers' => [ [ 'name' => 'http', @@ -40,9 +45,9 @@ 'package_max_length' => 2 * 1024 * 1024, ], 'callbacks' => [ - Event::ON_BEFORE_START => [Hyperf\Framework\Bootstrap\ServerStartCallback::class, 'beforeStart'], - Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], - Event::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'], - Event::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'], + Event::ON_BEFORE_START => [ServerStartCallback::class, 'beforeStart'], + Event::ON_WORKER_START => [WorkerStartCallback::class, 'onWorkerStart'], + Event::ON_PIPE_MESSAGE => [PipeMessageCallback::class, 'onPipeMessage'], + Event::ON_WORKER_EXIT => [WorkerExitCallback::class, 'onWorkerExit'], ], ]; diff --git a/test/HttpTestCase.php b/test/HttpTestCase.php index 1d36153..7b411f2 100644 --- a/test/HttpTestCase.php +++ b/test/HttpTestCase.php @@ -32,9 +32,9 @@ abstract class HttpTestCase extends TestCase */ protected $client; - public function __construct($name = null, array $data = [], $dataName = '') + public function __construct(string $name) { - parent::__construct($name, $data, $dataName); + parent::__construct($name); $this->client = make(Testing\Client::class); // $this->client = make(Testing\HttpClient::class, ['baseUri' => 'http://127.0.0.1:9501']); } diff --git a/test/bootstrap.php b/test/bootstrap.php index b438ee1..6d4593e 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -9,6 +9,10 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Contract\ApplicationInterface; +use Hyperf\Di\ClassLoader; +use Swoole\Runtime; + use function Hyperf\Support\swoole_hook_flags; error_reporting(E_ALL); @@ -19,10 +23,10 @@ require BASE_PATH . '/vendor/autoload.php'; -Swoole\Runtime::enableCoroutine(true, swoole_hook_flags()); +Runtime::enableCoroutine(true, swoole_hook_flags()); -Hyperf\Di\ClassLoader::init(); +ClassLoader::init(); $container = require BASE_PATH . '/config/container.php'; -$container->get(Hyperf\Contract\ApplicationInterface::class); +$container->get(ApplicationInterface::class);