From 2bfd171a249bf10c2f66a488217d5b5abaad917c Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 10 Jun 2026 13:46:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=E4=BD=9C?= =?UTF-8?q?=E7=94=A8=E5=9F=9F=E7=AE=A1=E7=90=86=E5=92=8C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正了 leaveScope 方法中的作用域级别递减顺序 - 将致命错误改为普通错误以处理浮点数到大整数的转换 - 使用严格相等比较修复数组变量检测逻辑 --- src/Php/Context/FunctionContext.php | 2 +- src/Php/Parser/TypeConversionTrait.php | 2 +- src/Php/Parser/TypeDetectionTrait.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Php/Context/FunctionContext.php b/src/Php/Context/FunctionContext.php index 66ac809b..7be2630a 100644 --- a/src/Php/Context/FunctionContext.php +++ b/src/Php/Context/FunctionContext.php @@ -96,7 +96,7 @@ class FunctionContext public function leaveScope(): void { - unset($this->scopeLayouts[$this->scopeLevel]); $this->scopeLevel--; + unset($this->scopeLayouts[$this->scopeLevel]); } } diff --git a/src/Php/Parser/TypeConversionTrait.php b/src/Php/Parser/TypeConversionTrait.php index 0dcd897b..cec3d0b8 100644 --- a/src/Php/Parser/TypeConversionTrait.php +++ b/src/Php/Parser/TypeConversionTrait.php @@ -76,7 +76,7 @@ trait TypeConversionTrait return 'php::toBigInt(' . $this->trimBrackets($expr) . ')'; } if ($fromType === self::TYPE_FLOAT) { - $this->fatalError(null, 'Cannot convert float to BigInt, use string or int instead'); + $this->error('Cannot convert float to BigInt, use string or int instead'); } if ($fromType === self::TYPE_STR) { return 'php::toBigInt(php::toString(' . $this->trimBrackets($expr) . '))'; diff --git a/src/Php/Parser/TypeDetectionTrait.php b/src/Php/Parser/TypeDetectionTrait.php index 84d917e3..8005dc41 100644 --- a/src/Php/Parser/TypeDetectionTrait.php +++ b/src/Php/Parser/TypeDetectionTrait.php @@ -138,7 +138,7 @@ trait TypeDetectionTrait protected function isArrayVar($var): bool { - return $this->isVarExpr($var) and $this->hasVar($var->name) and $this->getVarType($var->name) == self::TYPE_ARRAY; + return $this->isVarExpr($var) and $this->hasVar($var->name) and $this->getVarType($var->name) === self::TYPE_ARRAY; } }