From 45a4582d03d1582923868891080ffbbdd3214140 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 16 Apr 2026 17:48:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(php):=20=E6=B7=BB=E5=8A=A0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=B6=E6=89=93=E5=8D=B0=E5=9B=9E=E6=BA=AF=E8=B7=9F?= =?UTF-8?q?=E8=B8=AA=E7=9A=84=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 CompilerBase 类中新增 printBacktraceOnError 属性,默认值为 false - 修改错误处理逻辑,仅在 printBacktraceOnError 为 true 时调用 debug_print_backtrace() - 保持原有错误消息显示和程序退出功能不变 --- src/Php/CompilerBase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 6266b229..df5f3753 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -164,6 +164,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected string $ldflags = ''; protected int $floatPrecision = 17; protected bool $debugInfo = true; + protected bool $printBacktraceOnError = false; protected bool $noLiteralStrings = false; protected string $file; protected string $dir; @@ -2237,7 +2238,9 @@ class CompilerBase extends \PhpAot\Core\Translator throw new TestError($msg); } else { $this->climate->red("Fatal error: {$msg}"); - debug_print_backtrace(); + if ($this->printBacktraceOnError) { + debug_print_backtrace(); + } exit(255); } }