Skip to content

Commit d362cae

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix generation of property with class union type Replace SKIPIF with EXTENSIONS
2 parents 32ecdb5 + 68ca387 commit d362cae

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

Zend/zend_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ typedef struct {
273273
#define ZEND_TYPE_INIT_PTR_MASK(ptr, type_mask) \
274274
{ (void *) (ptr), (type_mask) }
275275

276+
#define ZEND_TYPE_INIT_UNION(ptr, extra_flags) \
277+
{ (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) }
278+
276279
#define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags) \
277280
ZEND_TYPE_INIT_PTR(class_name, _ZEND_TYPE_NAME_BIT, allow_null, extra_flags)
278281

build/gen_stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ public function getDeclaration(): string {
14601460

14611461
$typeMaskCode = $this->type->toArginfoType()->toTypeMask();
14621462

1463-
$code .= "\tzend_type property_{$propertyName}_type = ZEND_TYPE_INIT_PTR(property_{$propertyName}_type_list, _ZEND_TYPE_LIST_BIT, 0, $typeMaskCode);\n";
1463+
$code .= "\tzend_type property_{$propertyName}_type = ZEND_TYPE_INIT_UNION(property_{$propertyName}_type_list, $typeMaskCode);\n";
14641464
$typeCode = "property_{$propertyName}_type";
14651465
} else {
14661466
$escapedClassName = $arginfoType->classTypes[0]->toEscapedName();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Union type on internal property
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
$rp = new ReflectionProperty(_ZendTestClass::class, 'classUnionProp');
8+
$rt = $rp->getType();
9+
echo $rt, "\n";
10+
?>
11+
--EXPECT--
12+
stdClass|Iterator|null

ext/reflection/tests/internal_static_property.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
--TEST--
22
ReflectionProperty::get/setValue() on internal static property
3-
--SKIPIF--
4-
<?php
5-
if (!class_exists('_ZendTestClass')) die('skip zend_test extension required');
6-
?>
3+
--EXTENSIONS--
4+
zend_test
75
--FILE--
86
<?php
97

ext/zend_test/test_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e
260260
property_classUnionProp_type_list->num_types = 2;
261261
property_classUnionProp_type_list->types[0] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classUnionProp_class_stdClass, 0, 0);
262262
property_classUnionProp_type_list->types[1] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classUnionProp_class_Iterator, 0, 0);
263-
zend_type property_classUnionProp_type = ZEND_TYPE_INIT_PTR(property_classUnionProp_type_list, _ZEND_TYPE_LIST_BIT, 0, MAY_BE_NULL);
263+
zend_type property_classUnionProp_type = ZEND_TYPE_INIT_UNION(property_classUnionProp_type_list, MAY_BE_NULL);
264264
zval property_classUnionProp_default_value;
265265
ZVAL_NULL(&property_classUnionProp_default_value);
266266
zend_string *property_classUnionProp_name = zend_string_init("classUnionProp", sizeof("classUnionProp") - 1, 1);

0 commit comments

Comments
 (0)