From 955a3b0e4f13f31d5835a1a360dd18ce02f21ef2 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 8 Jan 2026 10:51:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(compiler):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=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 - 将路径验证和赋值逻辑分离,提高代码可读性 - 使用临时变量存储realpath结果,避免重复调用 - 先验证路径存在性再进行赋值操作 --- bin/compiler.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/compiler.php b/bin/compiler.php index 4a274398..0c7de429 100755 --- a/bin/compiler.php +++ b/bin/compiler.php @@ -14,10 +14,11 @@ $path = $argv[1]; $translator = new Translator(ROOT_PATH); $translator->setIndent(' '); -$path = realpath($path); -if ($path === false) { +$realpath = realpath($path); +if ($realpath === false) { die("path not exists: $path\n"); } +$path = $realpath; if (is_dir($path)) { $scanner = new FileScanner($path);