Skip to content

Commit 4c10cc2

Browse files
committed
Don't use union to avoid initialization issues
1 parent dab47b2 commit 4c10cc2

File tree

13 files changed

+72
-76
lines changed

13 files changed

+72
-76
lines changed

Zend/zend.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,7 @@ static void function_copy_ctor(zval *zv) /* {{{ */
594594
for (i = 0 ; i < num_args; i++) {
595595
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
596596
zend_string *name = zend_string_dup(ZEND_TYPE_NAME(arg_info[i].type), 1);
597-
598-
new_arg_info[i].type =
599-
ZEND_TYPE_ENCODE_CLASS(
600-
name, ZEND_TYPE_ALLOW_NULL(arg_info[i].type));
597+
ZEND_TYPE_SET_PTR(new_arg_info[i].type, name);
601598
}
602599
}
603600
func->common.arg_info = new_arg_info + 1;
@@ -968,7 +965,7 @@ static void zend_resolve_property_types(void) /* {{{ */
968965
zend_class_entry *prop_ce = zend_hash_find_ptr(CG(class_table), lc_type_name);
969966

970967
ZEND_ASSERT(prop_ce && prop_ce->type == ZEND_INTERNAL_CLASS);
971-
prop_info->type = ZEND_TYPE_ENCODE_CE(prop_ce, ZEND_TYPE_ALLOW_NULL(prop_info->type));
968+
prop_info->type = (zend_type) ZEND_TYPE_INIT_CE(prop_ce, ZEND_TYPE_ALLOW_NULL(prop_info->type));
972969
zend_string_release(lc_type_name);
973970
zend_string_release(type_name);
974971
}

Zend/zend_API.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
20622062
}
20632063
if (ZEND_TYPE_IS_SET(info->type)) {
20642064
if (ZEND_TYPE_IS_CLASS(info->type)) {
2065-
const char *type_name = info->type.literal_name;
2065+
const char *type_name = ZEND_TYPE_LITERAL_NAME(info->type);
20662066
if (!scope && (!strcasecmp(type_name, "self") || !strcasecmp(type_name, "parent"))) {
20672067
zend_error_noreturn(E_CORE_ERROR, "Cannot declare a return type of %s outside of a class scope", type_name);
20682068
}
@@ -2143,9 +2143,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
21432143
reg_function->common.arg_info = new_arg_info + 1;
21442144
for (i = 0; i < num_args; i++) {
21452145
if (ZEND_TYPE_IS_CLASS(new_arg_info[i].type)) {
2146-
const char *class_name = new_arg_info[i].type.literal_name;
2147-
ZEND_TYPE_NAME(new_arg_info[i].type) =
2148-
zend_string_init_interned(class_name, strlen(class_name), 1);
2146+
const char *class_name = ZEND_TYPE_LITERAL_NAME(new_arg_info[i].type);
2147+
ZEND_TYPE_SET_PTR(new_arg_info[i].type,
2148+
zend_string_init_interned(class_name, strlen(class_name), 1));
21492149
}
21502150
}
21512151
}
@@ -3714,7 +3714,7 @@ ZEND_API int zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, ze
37143714

37153715
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */
37163716
{
3717-
return zend_declare_typed_property(ce, name, property, access_type, doc_comment, ZEND_TYPE_ENCODE_NONE());
3717+
return zend_declare_typed_property(ce, name, property, access_type, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE());
37183718
}
37193719
/* }}} */
37203720

Zend/zend_API.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,31 @@ typedef struct _zend_fcall_info_cache {
9696

9797
#define ZEND_FE_END { NULL, NULL, NULL, 0, 0 }
9898

99-
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, {}, pass_by_ref, 0},
100-
#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_ENCODE_CLASS_CONST(#classname, allow_null), pass_by_ref, 0 },
101-
#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, ZEND_TYPE_ENCODE_CODE(IS_ARRAY, allow_null), pass_by_ref, 0 },
102-
#define ZEND_ARG_CALLABLE_INFO(pass_by_ref, name, allow_null) { #name, ZEND_TYPE_ENCODE_CODE(IS_CALLABLE, allow_null), pass_by_ref, 0 },
103-
#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_ENCODE_CODE(type_hint, allow_null), pass_by_ref, 0 },
104-
#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name) { #name, {}, pass_by_ref, 1 },
105-
#define ZEND_ARG_VARIADIC_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_ENCODE_CODE(type_hint, allow_null), pass_by_ref, 1 },
106-
#define ZEND_ARG_VARIADIC_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_ENCODE_CLASS_CONST(#classname, allow_null), pass_by_ref, 1 },
99+
#define ZEND_ARG_INFO(pass_by_ref, name) { #name, ZEND_TYPE_INIT_NONE(), pass_by_ref, 0},
100+
#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_INIT_CLASS_CONST(#classname, allow_null), pass_by_ref, 0 },
101+
#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, ZEND_TYPE_INIT_CODE(IS_ARRAY, allow_null), pass_by_ref, 0 },
102+
#define ZEND_ARG_CALLABLE_INFO(pass_by_ref, name, allow_null) { #name, ZEND_TYPE_INIT_CODE(IS_CALLABLE, allow_null), pass_by_ref, 0 },
103+
#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_INIT_CODE(type_hint, allow_null), pass_by_ref, 0 },
104+
#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name) { #name, ZEND_TYPE_INIT_NONE(), pass_by_ref, 1 },
105+
#define ZEND_ARG_VARIADIC_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_INIT_CODE(type_hint, allow_null), pass_by_ref, 1 },
106+
#define ZEND_ARG_VARIADIC_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_INIT_CLASS_CONST(#classname, allow_null), pass_by_ref, 1 },
107107

108108
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
109109
static const zend_internal_arg_info name[] = { \
110-
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE_CLASS_CONST(#class_name, allow_null), return_reference, 0 },
110+
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_CLASS_CONST(#class_name, allow_null), return_reference, 0 },
111111

112112
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(name, class_name, allow_null) \
113113
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, 0, -1, class_name, allow_null)
114114

115115
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
116116
static const zend_internal_arg_info name[] = { \
117-
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE_CODE(type, allow_null), return_reference, 0 },
117+
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_CODE(type, allow_null), return_reference, 0 },
118118
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(name, type, allow_null) \
119119
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, type, allow_null)
120120

121121
#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args) \
122122
static const zend_internal_arg_info name[] = { \
123-
{ (const char*)(zend_uintptr_t)(required_num_args), {}, return_reference, 0 },
123+
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_NONE(), return_reference, 0 },
124124
#define ZEND_BEGIN_ARG_INFO(name, _unused) \
125125
ZEND_BEGIN_ARG_INFO_EX(name, {}, ZEND_RETURN_VALUE, -1)
126126
#define ZEND_END_ARG_INFO() };

Zend/zend_compile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5311,7 +5311,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
53115311
}
53125312

53135313
if (ast->kind == ZEND_AST_TYPE) {
5314-
return ZEND_TYPE_ENCODE_CODE(ast->attr, allow_null);
5314+
return (zend_type) ZEND_TYPE_INIT_CODE(ast->attr, allow_null);
53155315
} else {
53165316
zend_string *class_name = zend_ast_get_str(ast);
53175317
zend_uchar type = zend_lookup_builtin_type_by_name(class_name);
@@ -5325,7 +5325,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
53255325
if (type == IS_VOID && allow_null) {
53265326
zend_error_noreturn(E_COMPILE_ERROR, "Void type cannot be nullable");
53275327
}
5328-
return ZEND_TYPE_ENCODE_CODE(type, allow_null);
5328+
return (zend_type) ZEND_TYPE_INIT_CODE(type, allow_null);
53295329
} else {
53305330
uint32_t fetch_type = zend_get_class_fetch_type_ast(ast);
53315331
if (fetch_type == ZEND_FETCH_CLASS_DEFAULT) {
@@ -5336,7 +5336,7 @@ static zend_type zend_compile_typename(zend_ast *ast, zend_bool force_allow_null
53365336
zend_string_addref(class_name);
53375337
}
53385338

5339-
return ZEND_TYPE_ENCODE_CLASS(class_name, allow_null);
5339+
return (zend_type) ZEND_TYPE_INIT_CLASS(class_name, allow_null);
53405340
}
53415341
}
53425342
}
@@ -5452,7 +5452,7 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
54525452
arg_info->name = zend_string_copy(name);
54535453
arg_info->pass_by_reference = is_ref;
54545454
arg_info->is_variadic = is_variadic;
5455-
arg_info->type = ZEND_TYPE_ENCODE_NONE();
5455+
arg_info->type = (zend_type) ZEND_TYPE_INIT_NONE();
54565456

54575457
if (type_ast) {
54585458
uint32_t default_type = default_ast ? Z_TYPE(default_node.u.constant) : IS_UNDEF;
@@ -5983,7 +5983,7 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags) /
59835983
zend_string *name = zval_make_interned_string(zend_ast_get_zval(name_ast));
59845984
zend_string *doc_comment = NULL;
59855985
zval value_zv;
5986-
zend_type type = ZEND_TYPE_ENCODE_NONE();
5986+
zend_type type = ZEND_TYPE_INIT_NONE();
59875987

59885988
if (type_ast) {
59895989
type = zend_compile_typename(type_ast, 0);

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ static zend_bool zend_resolve_class_type(zend_type *type, zend_class_entry *self
937937
}
938938

939939
zend_string_release(name);
940-
*type = ZEND_TYPE_ENCODE_CE(ce, ZEND_TYPE_ALLOW_NULL(*type));
940+
*type = (zend_type) ZEND_TYPE_INIT_CE(ce, ZEND_TYPE_ALLOW_NULL(*type));
941941
return 1;
942942
}
943943

Zend/zend_types.h

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,13 @@ typedef void (*copy_ctor_func_t)(zval *pElement);
120120
* ZEND_TYPE_ENCODE_*() should be used for construction.
121121
*/
122122

123-
/* We could use the extra 32-bit of padding on 64-bit systems. */
124123
typedef struct {
125-
union {
126-
zend_class_entry *ce;
127-
zend_string *name;
128-
const char *literal_name;
129-
};
124+
/* Not using a union here, because there's no good way to initialize them
125+
* in a way that is supported in both C and C++ (designated initializers
126+
* are only supported since C++20). */
127+
void *ptr;
130128
uint32_t type_mask;
129+
/* TODO: We could use the extra 32-bit of padding on 64-bit systems. */
131130
} zend_type;
132131

133132
#define _ZEND_TYPE_MASK ((1u<<(IS_VOID+1))-1)
@@ -152,13 +151,19 @@ typedef struct {
152151
(((t.type_mask) & _ZEND_TYPE_NAME_BIT) != 0)
153152

154153
#define ZEND_TYPE_IS_ONLY_MASK(t) \
155-
((t).type_mask != 0 && (t).ce == NULL)
154+
((t).type_mask != 0 && (t).ptr == NULL)
156155

157156
#define ZEND_TYPE_NAME(t) \
158-
((t).name)
157+
((zend_string *) (t).ptr)
158+
159+
#define ZEND_TYPE_LITERAL_NAME(t) \
160+
((const char *) (t).ptr)
159161

160162
#define ZEND_TYPE_CE(t) \
161-
((t).ce)
163+
((zend_class_entry *) (t).ptr)
164+
165+
#define ZEND_TYPE_SET_PTR(t, _ptr) \
166+
((t).ptr = (_ptr))
162167

163168
#define ZEND_TYPE_MASK(t) \
164169
((t).type_mask)
@@ -172,31 +177,24 @@ typedef struct {
172177
#define ZEND_TYPE_ALLOW_NULL(t) \
173178
(((t).type_mask & _ZEND_TYPE_NULLABLE_BIT) != 0)
174179

175-
#define ZEND_TYPE_ENCODE_NONE() \
176-
(zend_type) {{0}}
180+
#define ZEND_TYPE_INIT_NONE() \
181+
{ NULL, 0 }
177182

178-
#define ZEND_TYPE_ENCODE_MASK(maybe_code) \
179-
(zend_type) { {}, (maybe_code) }
183+
#define ZEND_TYPE_INIT_MASK(_type_mask) \
184+
{ NULL, (_type_mask) }
180185

181-
#define ZEND_TYPE_ENCODE_CODE(code, allow_null) \
182-
ZEND_TYPE_ENCODE_MASK(((code) == _IS_BOOL ? (MAY_BE_FALSE|MAY_BE_TRUE) : (1 << (code))) \
186+
#define ZEND_TYPE_INIT_CODE(code, allow_null) \
187+
ZEND_TYPE_INIT_MASK(((code) == _IS_BOOL ? (MAY_BE_FALSE|MAY_BE_TRUE) : (1 << (code))) \
183188
| ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0))
184189

185-
#define ZEND_TYPE_ENCODE_CE(_ce, allow_null) \
186-
(zend_type) { \
187-
{ .ce = (_ce) }, \
188-
_ZEND_TYPE_CE_BIT | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) \
189-
}
190-
191-
#define ZEND_TYPE_ENCODE_CLASS(class_name, allow_null) \
192-
(zend_type) { \
193-
{ .name = (class_name) }, \
194-
_ZEND_TYPE_NAME_BIT | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) \
195-
}
196-
197-
#define ZEND_TYPE_ENCODE_CLASS_CONST(class_name, allow_null) \
198-
{ { .literal_name = (class_name) }, \
199-
_ZEND_TYPE_NAME_BIT | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) }
190+
#define ZEND_TYPE_INIT_CE(_ce, allow_null) \
191+
{ (void *) (_ce), _ZEND_TYPE_CE_BIT | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) }
192+
193+
#define ZEND_TYPE_INIT_CLASS(class_name, allow_null) \
194+
{ (void *) (class_name), _ZEND_TYPE_NAME_BIT | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) }
195+
196+
#define ZEND_TYPE_INIT_CLASS_CONST(class_name, allow_null) \
197+
{ (void *) (class_name), _ZEND_TYPE_NAME_BIT | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) }
200198

201199
typedef union _zend_value {
202200
zend_long lval; /* long value */

ext/com_dotnet/com_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name
319319
f.arg_info = ecalloc(bindptr.lpfuncdesc->cParams, sizeof(zend_arg_info));
320320

321321
for (i = 0; i < bindptr.lpfuncdesc->cParams; i++) {
322-
f.arg_info[i].type = ZEND_TYPE_ENCODE_NONE();
322+
f.arg_info[i].type = (zend_type) ZEND_TYPE_INIT_NONE();
323323
if (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) {
324324
f.arg_info[i].pass_by_reference = ZEND_SEND_BY_REF;
325325
}

ext/opcache/ZendAccelerator.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_int
602602
}
603603
for (i = 0 ; i < num_args; i++) {
604604
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
605-
ZEND_TYPE_NAME(arg_info[i].type) =
606-
new_interned_string(ZEND_TYPE_NAME(arg_info[i].type));
605+
ZEND_TYPE_SET_PTR(arg_info[i].type,
606+
new_interned_string(ZEND_TYPE_NAME(arg_info[i].type)));
607607
}
608608
}
609609
}
@@ -3580,7 +3580,7 @@ static zend_bool preload_try_resolve_property_types(zend_class_entry *ce)
35803580
}
35813581

35823582
zend_string_release(name);
3583-
prop->type = ZEND_TYPE_ENCODE_CE(p, ZEND_TYPE_ALLOW_NULL(prop->type));
3583+
prop->type = (zend_type) ZEND_TYPE_INIT_CE(p, ZEND_TYPE_ALLOW_NULL(prop->type));
35843584
} ZEND_HASH_FOREACH_END();
35853585
}
35863586

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static void zend_hash_clone_prop_info(HashTable *ht)
237237
zend_class_entry *ce = ZEND_TYPE_CE(prop_info->type);
238238
if (IN_ARENA(ce)) {
239239
ce = ARENA_REALLOC(ce);
240-
ZEND_TYPE_CE(prop_info->type) = ce;
240+
ZEND_TYPE_SET_PTR(prop_info->type, ce);
241241
}
242242
}
243243
}

ext/opcache/zend_file_cache.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra
501501
if (ZEND_TYPE_IS_CLASS(p->type)) {
502502
zend_string *type_name = ZEND_TYPE_NAME(p->type);
503503
SERIALIZE_STR(type_name);
504-
ZEND_TYPE_NAME(p->type) = type_name;
504+
ZEND_TYPE_SET_PTR(p->type, type_name);
505505
}
506506
p++;
507507
}
@@ -575,11 +575,11 @@ static void zend_file_cache_serialize_prop_info(zval *zv,
575575
if (ZEND_TYPE_IS_NAME(prop->type)) {
576576
zend_string *name = ZEND_TYPE_NAME(prop->type);
577577
SERIALIZE_STR(name);
578-
ZEND_TYPE_NAME(prop->type) = name;
578+
ZEND_TYPE_SET_PTR(prop->type, name);
579579
} else if (ZEND_TYPE_IS_CE(prop->type)) {
580580
zend_class_entry *ce = ZEND_TYPE_CE(prop->type);
581581
SERIALIZE_PTR(ce);
582-
ZEND_TYPE_CE(prop->type) = ce;
582+
ZEND_TYPE_SET_PTR(prop->type, ce);
583583
}
584584
}
585585
}
@@ -1198,7 +1198,7 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
11981198
if (ZEND_TYPE_IS_CLASS(p->type)) {
11991199
zend_string *type_name = ZEND_TYPE_NAME(p->type);
12001200
UNSERIALIZE_STR(type_name);
1201-
ZEND_TYPE_NAME(p->type) = type_name;
1201+
ZEND_TYPE_SET_PTR(p->type, type_name);
12021202
}
12031203
p++;
12041204
}
@@ -1272,11 +1272,11 @@ static void zend_file_cache_unserialize_prop_info(zval *zv,
12721272
if (ZEND_TYPE_IS_NAME(prop->type)) {
12731273
zend_string *name = ZEND_TYPE_NAME(prop->type);
12741274
UNSERIALIZE_STR(name);
1275-
ZEND_TYPE_NAME(prop->type) = name;
1275+
ZEND_TYPE_SET_PTR(prop->type, name);
12761276
} else if (ZEND_TYPE_IS_CE(prop->type)) {
12771277
zend_class_entry *ce = ZEND_TYPE_CE(prop->type);
12781278
UNSERIALIZE_PTR(ce);
1279-
ZEND_TYPE_CE(prop->type) = ce;
1279+
ZEND_TYPE_SET_PTR(prop->type, ce);
12801280
}
12811281
}
12821282
}

ext/opcache/zend_persist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
502502
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
503503
zend_string *type_name = ZEND_TYPE_NAME(arg_info[i].type);
504504
zend_accel_store_interned_string(type_name);
505-
ZEND_TYPE_NAME(arg_info[i].type) = type_name;
505+
ZEND_TYPE_SET_PTR(arg_info[i].type, type_name);
506506
}
507507
}
508508
if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
@@ -662,7 +662,7 @@ static void zend_persist_property_info(zval *zv)
662662
if (ZEND_TYPE_IS_NAME(prop->type)) {
663663
zend_string *class_name = ZEND_TYPE_NAME(prop->type);
664664
zend_accel_store_interned_string(class_name);
665-
ZEND_TYPE_NAME(prop->type) = class_name;
665+
ZEND_TYPE_SET_PTR(prop->type, class_name);
666666
}
667667
}
668668

@@ -942,7 +942,7 @@ static void zend_update_parent_ce(zend_class_entry *ce)
942942
if (ce->type == ZEND_USER_CLASS) {
943943
ce = zend_shared_alloc_get_xlat_entry(ce);
944944
if (ce) {
945-
ZEND_TYPE_CE(prop->type) = ce;
945+
ZEND_TYPE_SET_PTR(prop->type, ce);
946946
}
947947
}
948948
}

ext/opcache/zend_persist_calc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
225225
if (ZEND_TYPE_IS_CLASS(arg_info[i].type)) {
226226
zend_string *type_name = ZEND_TYPE_NAME(arg_info[i].type);
227227
ADD_INTERNED_STRING(type_name);
228-
ZEND_TYPE_NAME(arg_info[i].type) = type_name;
228+
ZEND_TYPE_SET_PTR(arg_info[i].type, type_name);
229229
}
230230
}
231231
}
@@ -305,7 +305,7 @@ static void zend_persist_property_info_calc(zval *zv)
305305
if (ZEND_TYPE_IS_NAME(prop->type)) {
306306
zend_string *class_name = ZEND_TYPE_NAME(prop->type);
307307
ADD_INTERNED_STRING(class_name);
308-
ZEND_TYPE_NAME(prop->type) = class_name;
308+
ZEND_TYPE_SET_PTR(prop->type, class_name);
309309
}
310310
if (ZCG(accel_directives).save_comments && prop->doc_comment) {
311311
ADD_STRING(prop->doc_comment);

ext/zend_test/test.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ PHP_MINIT_FUNCTION(zend_test)
219219
zval val;
220220
ZVAL_LONG(&val, 123);
221221
zend_declare_typed_property(
222-
zend_test_class, name, &val, ZEND_ACC_PUBLIC, NULL, ZEND_TYPE_ENCODE_CODE(IS_LONG, 0));
222+
zend_test_class, name, &val, ZEND_ACC_PUBLIC, NULL,
223+
(zend_type) ZEND_TYPE_INIT_CODE(IS_LONG, 0));
223224
zend_string_release(name);
224225
}
225226

@@ -230,7 +231,7 @@ PHP_MINIT_FUNCTION(zend_test)
230231
ZVAL_NULL(&val);
231232
zend_declare_typed_property(
232233
zend_test_class, name, &val, ZEND_ACC_PUBLIC, NULL,
233-
ZEND_TYPE_ENCODE_CLASS(class_name, 1));
234+
(zend_type) ZEND_TYPE_INIT_CLASS(class_name, 1));
234235
zend_string_release(name);
235236
}
236237

@@ -240,7 +241,7 @@ PHP_MINIT_FUNCTION(zend_test)
240241
ZVAL_LONG(&val, 123);
241242
zend_declare_typed_property(
242243
zend_test_class, name, &val, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC, NULL,
243-
ZEND_TYPE_ENCODE_CODE(IS_LONG, 0));
244+
(zend_type) ZEND_TYPE_INIT_CODE(IS_LONG, 0));
244245
zend_string_release(name);
245246
}
246247

0 commit comments

Comments
 (0)