@@ -1047,16 +1047,36 @@ function (Expr $expr) use (&$defaultValueConstant) {
1047
1047
if ($ this ->type ) {
1048
1048
$ arginfoType = $ this ->type ->toArginfoType ();
1049
1049
if ($ arginfoType ->hasClassType ()) {
1050
- $ simpleType = $ this ->type ->tryToSimpleType ();
1051
-
1052
- $ className = $ arginfoType ->classTypes [0 ]->name ;
1053
- $ code .= " zend_string *property_ {$ propertyName }_class_ {$ className } = zend_string_init( \"$ className \", sizeof( \"$ className \")-1, 1); \n" ;
1054
- if ($ simpleType ) {
1055
- $ typeCode = "(zend_type) ZEND_TYPE_INIT_CLASS(property_ {$ propertyName }_class_ {$ className }, " . ((int ) $ this ->type ->isNullable ()) . ", 0) " ;
1056
- } elseif (count ($ arginfoType ->classTypes ) === 1 ) {
1057
- $ typeCode = "(zend_type) ZEND_TYPE_INIT_CLASS(property_ {$ propertyName }_class_ {$ className }, 0, " . $ arginfoType ->toTypeMask () . ") " ;
1050
+ if (count ($ arginfoType ->classTypes ) >= 2 ) {
1051
+ foreach ($ arginfoType ->classTypes as $ classType ) {
1052
+ $ className = $ classType ->name ;
1053
+ $ code .= "\tzend_string *property_ {$ propertyName }_class_ {$ className } = zend_string_init( \"$ className \", sizeof( \"$ className \") - 1, 1); \n" ;
1054
+ }
1055
+
1056
+ $ classTypeCount = count ($ arginfoType ->classTypes );
1057
+ $ code .= "\tzend_type_list *property_ {$ propertyName }_type_list = malloc(ZEND_TYPE_LIST_SIZE( $ classTypeCount)); \n" ;
1058
+ $ code .= "\tproperty_ {$ propertyName }_type_list->num_types = $ classTypeCount; \n" ;
1059
+
1060
+ foreach ($ arginfoType ->classTypes as $ k => $ classType ) {
1061
+ $ className = $ classType ->name ;
1062
+ $ code .= "\tproperty_ {$ propertyName }_type_list->types[ $ k] = (zend_type) ZEND_TYPE_INIT_CLASS(property_ {$ propertyName }_class_ {$ className }, 0, 0); \n" ;
1063
+ }
1064
+
1065
+ $ isNullable = $ this ->type ->isNullable ();
1066
+
1067
+ $ code .= "\tzend_type property_ {$ propertyName }_type = ZEND_TYPE_INIT_PTR(property_ {$ propertyName }_type_list, _ZEND_TYPE_LIST_BIT, $ isNullable, 0); \n" ;
1068
+ $ typeCode = "property_ {$ propertyName }_type " ;
1058
1069
} else {
1059
- throw new Exception ("Property $ this ->name has an unsupported union type " );
1070
+ $ simpleType = $ this ->type ->tryToSimpleType ();
1071
+
1072
+ $ className = $ arginfoType ->classTypes [0 ]->name ;
1073
+ $ code .= "\tzend_string *property_ {$ propertyName }_class_ {$ className } = zend_string_init( \"$ className \", sizeof( \"$ className \")-1, 1); \n" ;
1074
+
1075
+ if ($ simpleType ) {
1076
+ $ typeCode = "(zend_type) ZEND_TYPE_INIT_CLASS(property_ {$ propertyName }_class_ {$ className }, " . ((int )$ this ->type ->isNullable ()) . ", 0) " ;
1077
+ } else {
1078
+ $ typeCode = "(zend_type) ZEND_TYPE_INIT_CLASS(property_ {$ propertyName }_class_ {$ className }, 0, " . $ arginfoType ->toTypeMask () . ") " ;
1079
+ }
1060
1080
}
1061
1081
} else {
1062
1082
$ typeCode = "(zend_type) ZEND_TYPE_INIT_MASK( " . $ arginfoType ->toTypeMask () . ") " ;
0 commit comments