diff --git a/app/Bootstrap/ServerStart.php b/app/Bootstrap/ServerStart.php index 7140ba5..c355be3 100644 --- a/app/Bootstrap/ServerStart.php +++ b/app/Bootstrap/ServerStart.php @@ -2,9 +2,7 @@ namespace App\Bootstrap; -use App\Service\SocketFDService; use Hyperf\Framework\Bootstrap\ServerStartCallback; -use Hashids\Hashids; use Swoole\Timer; use Hyperf\Redis\Redis; diff --git a/app/Exception/Handler/AppExceptionHandler.php b/app/Exception/Handler/AppExceptionHandler.php index a12b133..c36a66d 100644 --- a/app/Exception/Handler/AppExceptionHandler.php +++ b/app/Exception/Handler/AppExceptionHandler.php @@ -1,23 +1,15 @@ logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile())); $this->logger->error($throwable->getTraceAsString()); return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.')); } + /** + * @param Throwable $throwable + * @return bool + */ public function isValid(Throwable $throwable): bool { return true; diff --git a/app/Exception/Handler/JwtAuthExceptionHandler.php b/app/Exception/Handler/JwtAuthExceptionHandler.php index d794bc6..130c6e6 100644 --- a/app/Exception/Handler/JwtAuthExceptionHandler.php +++ b/app/Exception/Handler/JwtAuthExceptionHandler.php @@ -16,6 +16,8 @@ class JwtAuthExceptionHandler extends ExceptionHandler { public function handle(Throwable $throwable, ResponseInterface $response) { + +// echo $throwable->getMessage(); // 判断被捕获到的异常是希望被捕获的异常 if ($throwable instanceof TokenValidException) { // 格式化输出 @@ -27,7 +29,6 @@ class JwtAuthExceptionHandler extends ExceptionHandler // 阻止异常冒泡 $this->stopPropagation(); - return $response->withAddedHeader('content-type', 'application/json; charset=utf-8')->withStatus(401)->withBody(new SwooleStream($data)); } @@ -36,6 +37,9 @@ class JwtAuthExceptionHandler extends ExceptionHandler /** * 判断该异常处理器是否要对该异常进行处理 + * + * @param Throwable $throwable + * @return bool */ public function isValid(Throwable $throwable): bool { diff --git a/app/Exception/Handler/ValidateExceptionHandler.php b/app/Exception/Handler/ValidateExceptionHandler.php index a22f59d..082c70b 100644 --- a/app/Exception/Handler/ValidateExceptionHandler.php +++ b/app/Exception/Handler/ValidateExceptionHandler.php @@ -16,6 +16,11 @@ use Throwable; */ class ValidateExceptionHandler extends ExceptionHandler { + /** + * @param Throwable $throwable + * @param ResponseInterface $response + * @return ResponseInterface + */ public function handle(Throwable $throwable, ResponseInterface $response) { // 判断被捕获到的异常是希望被捕获的异常 @@ -38,6 +43,9 @@ class ValidateExceptionHandler extends ExceptionHandler /** * 判断该异常处理器是否要对该异常进行处理 + * + * @param Throwable $throwable + * @return bool */ public function isValid(Throwable $throwable): bool { diff --git a/app/Helper/Hash.php b/app/Helper/Hash.php index bdf85ae..9a14462 100644 --- a/app/Helper/Hash.php +++ b/app/Helper/Hash.php @@ -10,7 +10,7 @@ class Hash * @param string $value * @return string */ - public static function make($value) + public static function make(string $value) { return password_hash($value, PASSWORD_DEFAULT); } @@ -22,7 +22,7 @@ class Hash * @param string $hashedValue * @return bool */ - public static function check($value, $hashedValue) + public static function check(string $value, string $hashedValue) { return password_verify($value, $hashedValue); } diff --git a/app/Listener/DbQueryExecutedListener.php b/app/Listener/DbQueryExecutedListener.php index abe5a52..57c78fe 100644 --- a/app/Listener/DbQueryExecutedListener.php +++ b/app/Listener/DbQueryExecutedListener.php @@ -43,7 +43,7 @@ class DbQueryExecutedListener implements ListenerInterface } /** - * @param QueryExecuted $event + * @param object|QueryExecuted $event */ public function process(object $event) { diff --git a/app/Support/Response.php b/app/Support/Response.php index 61ff7dc..2a6c208 100644 --- a/app/Support/Response.php +++ b/app/Support/Response.php @@ -13,7 +13,7 @@ class Response * @Inject * @var ResponseInterface|mixed */ - protected $response; + private $response; /** * @param $data diff --git a/config/autoload/exceptions.php b/config/autoload/exceptions.php index 5c5c65e..927231c 100644 --- a/config/autoload/exceptions.php +++ b/config/autoload/exceptions.php @@ -13,9 +13,9 @@ return [ 'handler' => [ 'http' => [ Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class, - App\Exception\Handler\AppExceptionHandler::class, - App\Exception\Handler\ValidateExceptionHandler::class, App\Exception\Handler\JwtAuthExceptionHandler::class, + App\Exception\Handler\ValidateExceptionHandler::class, + App\Exception\Handler\AppExceptionHandler::class, ], ], ];