From 68bd54c6c37b4d13e58b56073030975ce06740e9 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 10 Jun 2026 14:54:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8DPHP=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E4=B8=AD=E7=9A=84=E8=B7=AF=E5=BE=84=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=92=8C=E9=94=99=E8=AF=AF=E6=B6=88=E6=81=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加对空路径的验证并显示相应错误消息 - 修正路径判断逻辑使用严格比较操作符 - 在类解析中添加对枚举类型的处理 - 修复方法重写错误消息中类名的显示问题 --- src/Php/Translator.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 6cd9c0dd..86e2d132 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -1613,7 +1613,10 @@ CODE; protected function getAbsolutePath(string $path, string $projectDir): string { $path = trim($path); - if ($path[0] != '/') { + if ($path === '') { + $this->error('Source path must not be empty'); + } + if ($path[0] !== '/') { $absPath = $projectDir . '/' . $path; } else { $absPath = $path; @@ -1948,6 +1951,7 @@ CODE; switch ($type2) { case 'Stmt_Class': case 'Stmt_Trait': + case 'Stmt_Enum': $code .= $this->parseClass($v2); break; case 'Stmt_Const': @@ -2496,7 +2500,7 @@ CODE; _error: $this->fatalError($v, 'Cannot override private method `' . - $classDef->getNamespacedName(false) . '::' . $this->method . '()`'); + $extends . '::' . $this->method . '()`'); } } }