正在显示
7 个修改的文件
包含
17 行增加
和
11 行删除
| @@ -26,7 +26,8 @@ | @@ -26,7 +26,8 @@ | ||
| 26 | "wujunze/dingtalk-exception": "^2.2" | 26 | "wujunze/dingtalk-exception": "^2.2" |
| 27 | }, | 27 | }, |
| 28 | "require-dev": { | 28 | "require-dev": { |
| 29 | - "phpunit/phpunit": "^9.5.10" | 29 | + "phpunit/phpunit": "^9.5.10", |
| 30 | + "friendsofphp/php-cs-fixer": "^3.7" | ||
| 30 | }, | 31 | }, |
| 31 | "extra": { | 32 | "extra": { |
| 32 | "laravel": { | 33 | "laravel": { |
| @@ -42,7 +42,7 @@ class Dispatcher implements CallbackInterface | @@ -42,7 +42,7 @@ class Dispatcher implements CallbackInterface | ||
| 42 | */ | 42 | */ |
| 43 | public static function callback(): \Closure | 43 | public static function callback(): \Closure |
| 44 | { | 44 | { |
| 45 | - $that = new static; | 45 | + $that = new static(); |
| 46 | 46 | ||
| 47 | if ($dispatcher = $that->config()) { | 47 | if ($dispatcher = $that->config()) { |
| 48 | return $dispatcher; | 48 | return $dispatcher; |
| @@ -18,7 +18,7 @@ class ExceptionPush | @@ -18,7 +18,7 @@ class ExceptionPush | ||
| 18 | 18 | ||
| 19 | public function __construct() | 19 | public function __construct() |
| 20 | { | 20 | { |
| 21 | - $this->parser = new Parser; | 21 | + $this->parser = new Parser(); |
| 22 | 22 | ||
| 23 | $this->agents = static::getAgents(); | 23 | $this->agents = static::getAgents(); |
| 24 | } | 24 | } |
| @@ -36,7 +36,7 @@ class ExceptionPush | @@ -36,7 +36,7 @@ class ExceptionPush | ||
| 36 | $agents = []; | 36 | $agents = []; |
| 37 | 37 | ||
| 38 | foreach ($agentOpts as $agentName => $opts) { | 38 | foreach ($agentOpts as $agentName => $opts) { |
| 39 | - $agent = new $agentName; | 39 | + $agent = new $agentName(); |
| 40 | 40 | ||
| 41 | if (!is_array($opts)) { | 41 | if (!is_array($opts)) { |
| 42 | continue; | 42 | continue; |
| @@ -18,8 +18,14 @@ class Formatter implements CallbackInterface | @@ -18,8 +18,14 @@ class Formatter implements CallbackInterface | ||
| 18 | '时间:' . Carbon::now()->toDateTimeString(), '环境:' . config('app.env'), '项目:' . config('app.name'), | 18 | '时间:' . Carbon::now()->toDateTimeString(), '环境:' . config('app.env'), '项目:' . config('app.name'), |
| 19 | '参数:' . json_encode($context->getInput()), 'runtime:' . php_sapi_name(), '地址:' . $context->getPath(), | 19 | '参数:' . json_encode($context->getInput()), 'runtime:' . php_sapi_name(), '地址:' . $context->getPath(), |
| 20 | '请求方法:' . $context->getMethod(), 'IP:' . $context->getIp(), | 20 | '请求方法:' . $context->getMethod(), 'IP:' . $context->getIp(), |
| 21 | - '异常:' . sprintf('%s(%s)(code:%d):at %s:%d', $context->getException(), $context->getMessage(), | ||
| 22 | - $context->getCode(), $context->getFile(), $context->getLine()), | 21 | + '异常:' . sprintf( |
| 22 | + '%s(%s)(code:%d):at %s:%d', | ||
| 23 | + $context->getException(), | ||
| 24 | + $context->getMessage(), | ||
| 25 | + $context->getCode(), | ||
| 26 | + $context->getFile(), | ||
| 27 | + $context->getLine() | ||
| 28 | + ), | ||
| 23 | 'trace:' . implode(PHP_EOL, $context->getTrace()), | 29 | 'trace:' . implode(PHP_EOL, $context->getTrace()), |
| 24 | ]; | 30 | ]; |
| 25 | }; | 31 | }; |
| @@ -39,7 +45,7 @@ class Formatter implements CallbackInterface | @@ -39,7 +45,7 @@ class Formatter implements CallbackInterface | ||
| 39 | */ | 45 | */ |
| 40 | public static function callback(): \Closure | 46 | public static function callback(): \Closure |
| 41 | { | 47 | { |
| 42 | - $that = new static; | 48 | + $that = new static(); |
| 43 | 49 | ||
| 44 | if ($formatter = $that->config()) { | 50 | if ($formatter = $that->config()) { |
| 45 | return $formatter; | 51 | return $formatter; |
| @@ -43,8 +43,7 @@ class MonologHandler extends AbstractSyslogHandler | @@ -43,8 +43,7 @@ class MonologHandler extends AbstractSyslogHandler | ||
| 43 | $facility = LOG_USER, | 43 | $facility = LOG_USER, |
| 44 | $level = Logger::DEBUG, | 44 | $level = Logger::DEBUG, |
| 45 | bool $bubble = true | 45 | bool $bubble = true |
| 46 | - ) | ||
| 47 | - { | 46 | + ) { |
| 48 | parent::__construct($facility, $level, $bubble); | 47 | parent::__construct($facility, $level, $bubble); |
| 49 | 48 | ||
| 50 | $this->dispatcher = Dispatcher::callback(); | 49 | $this->dispatcher = Dispatcher::callback(); |
| @@ -14,7 +14,7 @@ if (!function_exists('closure')) { | @@ -14,7 +14,7 @@ if (!function_exists('closure')) { | ||
| 14 | [$class, $method] = $closure; | 14 | [$class, $method] = $closure; |
| 15 | 15 | ||
| 16 | return function () use ($class, $method) { | 16 | return function () use ($class, $method) { |
| 17 | - $handler = new $class; | 17 | + $handler = new $class(); |
| 18 | 18 | ||
| 19 | return call_user_func_array([$handler, $method], func_get_args()); | 19 | return call_user_func_array([$handler, $method], func_get_args()); |
| 20 | }; | 20 | }; |
| @@ -16,7 +16,7 @@ class Parser | @@ -16,7 +16,7 @@ class Parser | ||
| 16 | 16 | ||
| 17 | public function __construct() | 17 | public function __construct() |
| 18 | { | 18 | { |
| 19 | - $this->context = new Context; | 19 | + $this->context = new Context(); |
| 20 | 20 | ||
| 21 | $this->request = app(Request::class); | 21 | $this->request = app(Request::class); |
| 22 | } | 22 | } |
-
请 注册 或 登录 后发表评论