From c9d92e458182ab1faee30e47542a4a1911b46303 Mon Sep 17 00:00:00 2001 From: rango Date: Tue, 9 Jun 2026 18:36:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E6=9B=B4=E6=96=B0=E5=BA=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=BC=95=E7=94=A8=E5=92=8C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E6=B6=88=E6=81=AF=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 libmpdec.lib 和 libmpdec++.lib 替换为带版本号的 libmpdec-4.0.1.dll.lib 和 libmpdec++-4.0.1.dll.lib - 修改类型检查错误消息中的字符串拼接方式,使用 genCharPtr 方法处理函数名和类型字符串 - 修复返回值类型检查消息的字符串构造逻辑 --- src/Php/CompilerBase.php | 4 ++-- src/Php/Generator/TypeCheckGenerator.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index daf94763..173a14c3 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -2202,8 +2202,8 @@ class CompilerBase extends \PhpAot\Core\Translator $libraries[] = 'gmp.lib'; $libraries[] = 'gmpxx.lib'; $libraries[] = 'mpfr.lib'; - $libraries[] = 'libmpdec.lib'; - $libraries[] = 'libmpdec++.lib'; + $libraries[] = 'libmpdec-4.0.1.dll.lib'; + $libraries[] = 'libmpdec++-4.0.1.dll.lib'; } else { // Linux/macOS: extension 和 bin 模式都需要添加 php 库 $libraries[] = 'php'; diff --git a/src/Php/Generator/TypeCheckGenerator.php b/src/Php/Generator/TypeCheckGenerator.php index 31b14dbf..1c8e4843 100644 --- a/src/Php/Generator/TypeCheckGenerator.php +++ b/src/Php/Generator/TypeCheckGenerator.php @@ -139,8 +139,8 @@ trait TypeCheckGenerator $orExpr = implode(' || ', $conditions); $fnName = $this->functionDef->getNamespacedName(); - $msgExpr = 'php::concat(php::concat(php::Str("' . $fnName . '(): Argument #' . ($argIndex + 1) - . ' ($' . $varName . ') must be of type ' . $argInfo->typeStr . ', "), ' + $msgExpr = 'php::concat(php::concat(php::Str(' . $this->genCharPtr($fnName, true) . ' "(): Argument #' . ($argIndex + 1) + . ' ($' . $varName . ') must be of type " ' . $this->genCharPtr($argInfo->typeStr, true) . ' ", "), ' . $varName . '.typeStr()), php::Str(" given"))'; $code = $this->getIndent() . 'if (UNEXPECTED(!(' . $orExpr . '))) {' . PHP_EOL; @@ -174,8 +174,8 @@ trait TypeCheckGenerator $fnName = $this->functionDef->getNamespacedName(); $typeStr = $this->functionDef->returnTypeStr; - $msgExpr = 'php::concat(php::concat(php::Str("' . $fnName . '(): Return value must be of type ' - . $typeStr . ', "), ' . $varName . '.typeStr()), php::Str(" given"))'; + $msgExpr = 'php::concat(php::concat(php::Str(' . $this->genCharPtr($fnName, true) . ' "(): Return value must be of type " ' + . $this->genCharPtr($typeStr, true) . ' ", "), ' . $varName . '.typeStr()), php::Str(" given"))'; $code = $this->getIndent() . 'if (UNEXPECTED(!(' . $orExpr . '))) {' . PHP_EOL; $this->indentLevel++;