From c0441f93778a7cc1af03719b129312a05f30ca17 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 15 Nov 2021 10:45:25 +0100 Subject: [PATCH 1/2] Replace SKIPIF with EXTENSIONS --- ext/reflection/tests/internal_static_property.phpt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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-- Date: Mon, 15 Nov 2021 11:03:03 +0100 Subject: [PATCH 2/2] Fix generation of property with class union type The generated type was missing the UNION bit. Add a ZEND_TYPE_INIT_UNION macro to hide the implementation details. --- Zend/zend_types.h | 3 +++ build/gen_stub.php | 2 +- .../tests/internal_property_union_type.phpt | 12 ++++++++++++ ext/zend_test/test_arginfo.h | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 ext/reflection/tests/internal_property_union_type.phpt diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 4a1232198fc..99f6b997a44 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/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index fd3b9756741..dcf2df117fa 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -252,7 +252,7 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e property_classUnionProp_type_list->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);