From 6a3f03d5b321e3c016af59fca369227072545998 Mon Sep 17 00:00:00 2001 From: Kit Loong Date: Thu, 27 Jun 2024 18:50:57 +0800 Subject: [PATCH] Add return type --- src/HttpLog/LogWriter.php | 10 ++++++++++ src/PerformanceLog/LogWriter.php | 12 ++++++++---- src/QueryLog/LogWriter.php | 7 +++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/HttpLog/LogWriter.php b/src/HttpLog/LogWriter.php index 7b41eff..da4d114 100644 --- a/src/HttpLog/LogWriter.php +++ b/src/HttpLog/LogWriter.php @@ -16,6 +16,16 @@ public function log(Request $request, string $uniqId): void Log::channel(config('app-logger.http.channel'))->info($message); } + /** + * @return array{ + * uniqid: string, + * method: string, + * uri: string, + * body: array, + * headers: array>, + * files: array + * } + */ protected function getMessages(Request $request, string $uniqId): array { $files = (new Collection(iterator_to_array($request->files))) diff --git a/src/PerformanceLog/LogWriter.php b/src/PerformanceLog/LogWriter.php index a0806ed..55cb9b9 100644 --- a/src/PerformanceLog/LogWriter.php +++ b/src/PerformanceLog/LogWriter.php @@ -37,10 +37,14 @@ public function log(Request $request, $response, string $uniqId): void } /** - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Http\Response $response - * @param string $uniqId - * @return array + * @return array{ + * uniqid: string, + * method: string, + * uri: string, + * status: int, + * time: string, + * memory: string + * } */ protected function getMessages(Request $request, $response, string $uniqId): array { diff --git a/src/QueryLog/LogWriter.php b/src/QueryLog/LogWriter.php index ffaa2ed..4a02878 100644 --- a/src/QueryLog/LogWriter.php +++ b/src/QueryLog/LogWriter.php @@ -17,6 +17,13 @@ public function log(): void }); } + /** + * @return array{ + * time: float, + * connection_name: string, + * sql: string + * } + */ protected function getMessages(QueryExecuted $query): array { $sql = $query->sql;