From c6c3184f7342264944cfa120d3fa9db9aa6fa6a1 Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 27 Feb 2026 09:20:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(think-library):=20trace=5Ffile=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=20Throwable=20?= =?UTF-8?q?=E4=BB=A5=E5=85=BC=E5=AE=B9=20PHP=20Error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 trace_file() 参数类型由 Exception 改为 \Throwable - 解决 Library::load() 等处捕获 Error 时传入 trace_file 触发的 TypeError - PHP 7+ 中 Error 与 Exception 均实现 Throwable,可统一记录到 trace 文件 Made-with: Cursor --- plugin/think-library/src/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/think-library/src/common.php b/plugin/think-library/src/common.php index 54b90cfff..bcfec241c 100644 --- a/plugin/think-library/src/common.php +++ b/plugin/think-library/src/common.php @@ -415,8 +415,9 @@ if (!function_exists('down_file')) { if (!function_exists('trace_file')) { /** * 输出异常数据到文件. + * @param \Throwable $exception 支持 Exception 与 Error(PHP 7+) */ - function trace_file(Exception $exception): bool + function trace_file(\Throwable $exception): bool { $path = Library::$sapp->getRuntimePath() . 'trace'; if (!is_dir($path)) {