From 6e593b3d467a9042468f859f0bf749116aef5768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8E=9F=E7=82=B9?= <467490186@qq.com> Date: Thu, 27 Aug 2026 14:17:49 +0800 Subject: [PATCH] fix(gen_stub): use toVarEscapedName for union type ZEND_TYPE_INIT_CLASS When generating arginfo for union/intersection types with 2+ class types, the ZEND_TYPE_INIT_CLASS macro was using toEscapedName() which preserves backslashes (e.g. yuandian\\Database\\Db\\Expression\\Raw), but C identifiers cannot contain backslashes. This caused compilation errors like: error: stray '\' in program Fix: use toVarEscapedName() which replaces namespace separators with underscores, consistent with the single-class-type branch (line 2901). --- src/gen_stub.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gen_stub.php b/src/gen_stub.php index c39335b6..c959fafb 100755 --- a/src/gen_stub.php +++ b/src/gen_stub.php @@ -2881,8 +2881,8 @@ abstract class VariableLike $code .= "\t{$variableLikeType}_{$variableLikeName}_type_list->num_types = $classTypeCount;\n"; foreach ($arginfoType->classTypes as $k => $classType) { - $escapedClassName = $classType->toEscapedName(); - $code .= "\t{$variableLikeType}_{$variableLikeName}_type_list->types[$k] = (zend_type) ZEND_TYPE_INIT_CLASS({$variableLikeType}_{$variableLikeName}_class_{$escapedClassName}, 0, 0);\n"; + $varEscapedClassName = $classType->toVarEscapedName(); + $code .= "\t{$variableLikeType}_{$variableLikeName}_type_list->types[$k] = (zend_type) ZEND_TYPE_INIT_CLASS({$variableLikeType}_{$variableLikeName}_class_{$varEscapedClassName}, 0, 0);\n"; } $typeMaskCode = $this->type->toArginfoType()->toTypeMask();