diff --git a/Zend/zend_types.h b/Zend/zend_types.h index c0efe2a6dcf..6f7fef32a0e 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -273,6 +273,9 @@ typedef struct { #define ZEND_TYPE_INIT_PTR_MASK(ptr, type_mask) \ { (void *) (ptr), (type_mask) } +#define ZEND_TYPE_INIT_UNION(ptr, extra_flags) \ + { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) } + #define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags) \ ZEND_TYPE_INIT_PTR(class_name, _ZEND_TYPE_NAME_BIT, allow_null, extra_flags) diff --git a/build/gen_stub.php b/build/gen_stub.php index 30b0b2fccd9..ecbad1eb194 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1460,7 +1460,7 @@ class PropertyInfo $typeMaskCode = $this->type->toArginfoType()->toTypeMask(); - $code .= "\tzend_type property_{$propertyName}_type = ZEND_TYPE_INIT_PTR(property_{$propertyName}_type_list, _ZEND_TYPE_LIST_BIT, 0, $typeMaskCode);\n"; + $code .= "\tzend_type property_{$propertyName}_type = ZEND_TYPE_INIT_UNION(property_{$propertyName}_type_list, $typeMaskCode);\n"; $typeCode = "property_{$propertyName}_type"; } else { $escapedClassName = $arginfoType->classTypes[0]->toEscapedName(); diff --git a/ext/reflection/tests/internal_property_union_type.phpt b/ext/reflection/tests/internal_property_union_type.phpt new file mode 100644 index 00000000000..b70c98f56f3 --- /dev/null +++ b/ext/reflection/tests/internal_property_union_type.phpt @@ -0,0 +1,12 @@ +--TEST-- +Union type on internal property +--EXTENSIONS-- +zend_test +--FILE-- +getType(); +echo $rt, "\n"; +?> +--EXPECT-- +stdClass|Iterator|null diff --git a/ext/reflection/tests/internal_static_property.phpt b/ext/reflection/tests/internal_static_property.phpt index 79ba666720a..bf4294d8dec 100644 --- a/ext/reflection/tests/internal_static_property.phpt +++ b/ext/reflection/tests/internal_static_property.phpt @@ -1,9 +1,7 @@ --TEST-- ReflectionProperty::get/setValue() on internal static property ---SKIPIF-- - +--EXTENSIONS-- +zend_test --FILE-- num_types = 2; property_classUnionProp_type_list->types[0] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classUnionProp_class_stdClass, 0, 0); property_classUnionProp_type_list->types[1] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classUnionProp_class_Iterator, 0, 0); - zend_type property_classUnionProp_type = ZEND_TYPE_INIT_PTR(property_classUnionProp_type_list, _ZEND_TYPE_LIST_BIT, 0, MAY_BE_NULL); + zend_type property_classUnionProp_type = ZEND_TYPE_INIT_UNION(property_classUnionProp_type_list, MAY_BE_NULL); zval property_classUnionProp_default_value; ZVAL_NULL(&property_classUnionProp_default_value); zend_string *property_classUnionProp_name = zend_string_init("classUnionProp", sizeof("classUnionProp") - 1, 1);