refactor(php): 重构表达式字符串转换逻辑

- 将复杂的条件判断结构替换为统一的方法调用
- 提取类型检测和字符串转换逻辑到独立方法
- 简化代码结构并提高可读性
- 减少重复代码提升维护性
pull/1/head
韩天峰 3 months ago
parent a510801d24
commit bbbb3c948e
  1. 9
      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 . ');';
}
}

Loading…
Cancel
Save