From 7b4eeefb19277b00f223af37d37272f2fdc4bf31 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 13 Mar 2026 15:29:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E5=90=8D=E7=A7=B0=E9=AA=8C=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在无效标识符错误消息中显示实际的目标名称 - 在保留关键字错误消息中显示实际的目标名称 - 添加目录名称冲突检查以防止覆盖现有目录 - 统一错误消息格式使用反引号包围目标名称 --- src/Php/Translator.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 9f8463c0..d0acb8bb 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -132,11 +132,16 @@ class Translator extends Preprocessor } $name = str_replace(['-', '*'], '_', $name); if (!preg_match('/^[a-zA-Z0-9_]+$/', $name)) { - $this->climate->red('The target name must be a valid identifier'); + $this->climate->red('The target name `' . $name . '` must be a valid identifier'); exit(1); } if (in_array($name, Constants::CPP_RESERVED_NAMES)) { - $this->climate->red('The target name [' . $name . '] must not be a reserved keyword'); + $this->climate->red('The target name `' . $name . '` must not be a reserved keyword'); + exit(1); + } + $realTargetPath = $this->rootPath . '/' . $name; + if (is_dir($realTargetPath)) { + $this->climate->red('The target name `' . $name . '` must not be a directory'); exit(1); } $this->targetName = $name;