Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Jan 16, 2024
1 parent 4c7084e commit c203b2f
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 32 deletions.
15 changes: 11 additions & 4 deletions bin/hyperf.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf.
*
Expand All @@ -8,6 +10,11 @@
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\Contract\ApplicationInterface;
use Hyperf\Di\ClassLoader;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Application;

ini_set('display_errors', 'on');
ini_set('display_startup_errors', 'on');

Expand All @@ -21,10 +28,10 @@

// Self-called anonymous function that creates its own scope and keep the global namespace clean.
(function () {
Hyperf\Di\ClassLoader::init();
/** @var Psr\Container\ContainerInterface $container */
ClassLoader::init();
/** @var ContainerInterface $container */
$container = require BASE_PATH . '/config/container.php';
/** @var Symfony\Component\Console\Application $application */
$application = $container->get(Hyperf\Contract\ApplicationInterface::class);
/** @var Application $application */
$application = $container->get(ApplicationInterface::class);
$application->run();
})();
7 changes: 5 additions & 2 deletions config/autoload/annotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Resolver\ResolverDispatcher;

return [
'scan' => [
'paths' => [
Expand All @@ -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',
],
],
];
4 changes: 3 additions & 1 deletion config/autoload/async_queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* @contact [email protected]
* @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,
Expand Down
7 changes: 5 additions & 2 deletions config/autoload/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
* @contact [email protected]
* @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:',
],
];
4 changes: 3 additions & 1 deletion config/autoload/databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\ModelCache\Handler\RedisHandler;

use function Hyperf\Support\env;

return [
Expand All @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions config/autoload/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
* @contact [email protected]
* @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,
];
4 changes: 3 additions & 1 deletion config/autoload/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use App\Exception\Handler\BusinessExceptionHandler;

return [
'handler' => [
'http' => [
App\Exception\Handler\BusinessExceptionHandler::class,
BusinessExceptionHandler::class,
],
],
];
7 changes: 5 additions & 2 deletions config/autoload/listeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
* @contact [email protected]
* @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,
];
13 changes: 8 additions & 5 deletions config/autoload/logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
* @contact [email protected]
* @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',
Expand All @@ -30,7 +33,7 @@
],
'processors' => [
[
'class' => Log\AppendRequestIdProcessor::class,
'class' => AppendRequestIdProcessor::class,
],
],
],
Expand Down
4 changes: 3 additions & 1 deletion config/autoload/processes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\AsyncQueue\Process\ConsumerProcess;

return [
Hyperf\AsyncQueue\Process\ConsumerProcess::class,
ConsumerProcess::class,
];
15 changes: 10 additions & 5 deletions config/autoload/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'],
],
];
4 changes: 2 additions & 2 deletions test/HttpTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down
10 changes: 7 additions & 3 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* @contact [email protected]
* @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);
Expand 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);

0 comments on commit c203b2f

Please sign in to comment.