From 3c63ff2cfde5a1e7cff261d9a7b5451968e4875b Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Mon, 2 Feb 2026 16:09:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(stub):=20=E4=BC=98=E5=8C=96=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=89=93=E5=8D=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加对常量表达式类型的支持 - 实现整数常量的类型后缀处理 - 添加对PHP_INT_MIN和PHP_INT_MAX的特殊处理 - 保留原有表达式打印功能的兼容性 - 提升代码的可读性和维护性 --- bin/gen_stub.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/gen_stub.php b/bin/gen_stub.php index dd7d7a08..782ff014 100755 --- a/bin/gen_stub.php +++ b/bin/gen_stub.php @@ -2428,7 +2428,21 @@ class EvaluatedValue } $expr = preg_replace("/(^'|'$)/", '"', $expr); } else { - $expr = $prettyPrinter->prettyPrintExpr($this->expr); + if ($this->expr instanceof Expr\ConstFetch) { + $value = constant($this->expr->name->__toString()); + $expr = strval($value); + if (is_int($value)) { + if ($value === PHP_INT_MIN) { + $expr = 'LONG_MIN'; + } elseif ($value === PHP_INT_MAX) { + $expr = 'LONG_MAX'; + } else { + $expr = $expr . 'L'; + } + } + } else { + $expr = $prettyPrinter->prettyPrintExpr($this->expr); + } } return $expr[0] == '"' ? $expr : preg_replace('(\bnull\b)', 'NULL', str_replace('\\', '', $expr)); }