From bbbb3c948e29ef9cb36924d72ee0644345376e00 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 2 Jun 2026 17:38:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E9=87=8D=E6=9E=84=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E5=AD=97=E7=AC=A6=E4=B8=B2=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将复杂的条件判断结构替换为统一的方法调用 - 提取类型检测和字符串转换逻辑到独立方法 - 简化代码结构并提高可读性 - 减少重复代码提升维护性 --- src/Php/CompilerBase.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index ba1dbbfa..8d469c32 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1810,14 +1810,7 @@ class CompilerBase extends \PhpAot\Core\Translator $this->fatalError($expr, 'Cannot echo assign expression'); } else { $type = $this->detectTypeOfExpr($expr); - $parsed = $this->parseExpr($expr); - if ($type === self::TYPE_BIGINT) { - $parsed = 'php::BigInt::toString(' . $parsed . ')'; - } elseif ($type === self::TYPE_BIGFLOAT) { - $parsed = 'php::BigFloat::toString(' . $parsed . ')'; - } elseif ($type === self::TYPE_DECIMAL) { - $parsed = 'php::Decimal::toString(' . $parsed . ')'; - } + $parsed = $this->convertExprToStringByType($this->parseExpr($expr), $type); $lines[] = 'php::echo(' . $parsed . ');'; } }