Skip to content

Commit 47372df

Browse files
committed
Rename HAS_CLASS macro to IS_COMPLEX
1 parent 524711a commit 47372df

File tree

9 files changed

+24
-22
lines changed

9 files changed

+24
-22
lines changed

Zend/Optimizer/compact_literals.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static size_t type_num_classes(const zend_op_array *op_array, uint32_t arg_num)
7474
arg_info = op_array->arg_info - 1;
7575
}
7676

77-
if (ZEND_TYPE_HAS_CLASS(arg_info->type)) {
77+
if (ZEND_TYPE_IS_COMPLEX(arg_info->type)) {
7878
if (ZEND_TYPE_HAS_LIST(arg_info->type)) {
7979
return ZEND_TYPE_LIST(arg_info->type)->num_types;
8080
}

Zend/Optimizer/dfa_pass.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static inline bool can_elide_return_type_check(
313313
return 0;
314314
}
315315

316-
if (ZEND_TYPE_HAS_CLASS(info->type)) {
316+
if (ZEND_TYPE_IS_COMPLEX(info->type)) {
317317
if (!use_info->ce || !def_info->ce || !safe_instanceof(use_info->ce, def_info->ce)) {
318318
return 0;
319319
}

Zend/Optimizer/zend_inference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,7 @@ ZEND_API uint32_t zend_fetch_arg_info_type(const zend_script *script, zend_arg_i
22082208
}
22092209

22102210
tmp = zend_convert_type_declaration_mask(ZEND_TYPE_PURE_MASK(arg_info->type));
2211-
if (ZEND_TYPE_HAS_CLASS(arg_info->type)) {
2211+
if (ZEND_TYPE_IS_COMPLEX(arg_info->type)) {
22122212
tmp |= MAY_BE_OBJECT;
22132213
/* As we only have space to store one CE, we use a plain object type for class unions. */
22142214
if (ZEND_TYPE_HAS_NAME(arg_info->type)) {
@@ -2316,7 +2316,7 @@ static uint32_t zend_fetch_prop_type(const zend_script *script, zend_property_in
23162316
}
23172317
if (prop_info && ZEND_TYPE_IS_SET(prop_info->type)) {
23182318
uint32_t type = zend_convert_type_declaration_mask(ZEND_TYPE_PURE_MASK(prop_info->type));
2319-
if (ZEND_TYPE_HAS_CLASS(prop_info->type)) {
2319+
if (ZEND_TYPE_IS_COMPLEX(prop_info->type)) {
23202320
type |= MAY_BE_OBJECT;
23212321
if (pce) {
23222322
if (ZEND_TYPE_HAS_CE(prop_info->type)) {

Zend/zend_API.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,14 +2402,14 @@ static void zend_check_magic_method_return_type(const zend_class_entry *ce, cons
24022402
return;
24032403
}
24042404

2405-
bool has_class_type = ZEND_TYPE_HAS_CLASS(fptr->common.arg_info[-1].type);
2405+
bool is_complex_type = ZEND_TYPE_IS_COMPLEX(fptr->common.arg_info[-1].type);
24062406
uint32_t extra_types = ZEND_TYPE_PURE_MASK(fptr->common.arg_info[-1].type) & ~return_type;
24072407
if (extra_types & MAY_BE_STATIC) {
24082408
extra_types &= ~MAY_BE_STATIC;
2409-
has_class_type = 1;
2409+
is_complex_type = true;
24102410
}
24112411

2412-
if (extra_types || (has_class_type && return_type != MAY_BE_OBJECT)) {
2412+
if (extra_types || (is_complex_type && return_type != MAY_BE_OBJECT)) {
24132413
zend_error(error_type, "%s::%s(): Return type must be %s when declared",
24142414
ZSTR_VAL(ce->name), ZSTR_VAL(fptr->common.function_name),
24152415
ZSTR_VAL(zend_type_to_string((zend_type) ZEND_TYPE_INIT_MASK(return_type))));
@@ -2746,7 +2746,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
27462746
memcpy(new_arg_info, arg_info, sizeof(zend_arg_info) * num_args);
27472747
reg_function->common.arg_info = new_arg_info + 1;
27482748
for (i = 0; i < num_args; i++) {
2749-
if (ZEND_TYPE_HAS_CLASS(new_arg_info[i].type)) {
2749+
if (ZEND_TYPE_IS_COMPLEX(new_arg_info[i].type)) {
27502750
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(new_arg_info[i].type)
27512751
&& "Should be stored as simple name");
27522752
const char *class_name = ZEND_TYPE_LITERAL_NAME(new_arg_info[i].type);

Zend/zend_compile.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
24232423
/* }}} */
24242424

24252425
static size_t zend_type_get_num_classes(zend_type type) {
2426-
if (!ZEND_TYPE_HAS_CLASS(type)) {
2426+
if (!ZEND_TYPE_IS_COMPLEX(type)) {
24272427
return 0;
24282428
}
24292429
if (ZEND_TYPE_HAS_LIST(type)) {
@@ -6253,8 +6253,8 @@ static zend_type zend_compile_typename(
62536253
ZEND_TYPE_FULL_MASK(type) |= ZEND_TYPE_PURE_MASK(single_type);
62546254
ZEND_TYPE_FULL_MASK(single_type) &= ~_ZEND_TYPE_MAY_BE_MASK;
62556255

6256-
if (ZEND_TYPE_HAS_CLASS(single_type)) {
6257-
if (!ZEND_TYPE_HAS_CLASS(type)) {
6256+
if (ZEND_TYPE_IS_COMPLEX(single_type)) {
6257+
if (!ZEND_TYPE_IS_COMPLEX(type)) {
62586258
/* The first class type can be stored directly as the type ptr payload. */
62596259
ZEND_TYPE_SET_PTR(type, ZEND_TYPE_NAME(single_type));
62606260
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_NAME_BIT;
@@ -6327,7 +6327,7 @@ static zend_type zend_compile_typename(
63276327
/* Inform that the type is part of an intersection type */
63286328
ZEND_TYPE_FULL_MASK(single_type) |= _ZEND_TYPE_INTERSECTION_BIT;
63296329

6330-
if (!ZEND_TYPE_HAS_CLASS(type)) {
6330+
if (!ZEND_TYPE_IS_COMPLEX(type)) {
63316331
/* The first class type can be stored directly as the type ptr payload. */
63326332
ZEND_TYPE_SET_PTR(type, ZEND_TYPE_NAME(single_type));
63336333
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_NAME_BIT;
@@ -6391,19 +6391,19 @@ static zend_type zend_compile_typename(
63916391
zend_error_noreturn(E_COMPILE_ERROR, "Type mixed cannot be marked as nullable since mixed already includes null");
63926392
}
63936393

6394-
if ((type_mask & MAY_BE_OBJECT) && (ZEND_TYPE_HAS_CLASS(type) || (type_mask & MAY_BE_STATIC))) {
6394+
if ((type_mask & MAY_BE_OBJECT) && (ZEND_TYPE_IS_COMPLEX(type) || (type_mask & MAY_BE_STATIC))) {
63956395
zend_string *type_str = zend_type_to_string(type);
63966396
zend_error_noreturn(E_COMPILE_ERROR,
63976397
"Type %s contains both object and a class type, which is redundant",
63986398
ZSTR_VAL(type_str));
63996399
}
64006400

6401-
if ((type_mask & MAY_BE_VOID) && (ZEND_TYPE_HAS_CLASS(type) || type_mask != MAY_BE_VOID)) {
6401+
if ((type_mask & MAY_BE_VOID) && (ZEND_TYPE_IS_COMPLEX(type) || type_mask != MAY_BE_VOID)) {
64026402
zend_error_noreturn(E_COMPILE_ERROR, "Void can only be used as a standalone type");
64036403
}
64046404

64056405
if ((type_mask & (MAY_BE_NULL|MAY_BE_FALSE))
6406-
&& !ZEND_TYPE_HAS_CLASS(type) && !(type_mask & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
6406+
&& !ZEND_TYPE_IS_COMPLEX(type) && !(type_mask & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
64076407
if (type_mask == MAY_BE_NULL) {
64086408
zend_error_noreturn(E_COMPILE_ERROR, "Null can not be used as a standalone type");
64096409
} else {
@@ -7519,7 +7519,7 @@ static void zend_compile_enum_backing_type(zend_class_entry *ce, zend_ast *enum_
75197519
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_ENUM);
75207520
zend_type type = zend_compile_typename(enum_backing_type_ast, 0);
75217521
uint32_t type_mask = ZEND_TYPE_PURE_MASK(type);
7522-
if (ZEND_TYPE_HAS_CLASS(type) || (type_mask != MAY_BE_LONG && type_mask != MAY_BE_STRING)) {
7522+
if (ZEND_TYPE_IS_COMPLEX(type) || (type_mask != MAY_BE_LONG && type_mask != MAY_BE_STRING)) {
75237523
zend_string *type_string = zend_type_to_string(type);
75247524
zend_error_noreturn(E_COMPILE_ERROR,
75257525
"Enum backing type must be int or string, %s given",

Zend/zend_execute.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ static zend_always_inline bool i_zend_check_property_type(zend_property_info *in
954954
return 1;
955955
}
956956

957-
if (ZEND_TYPE_HAS_CLASS(info->type) && Z_TYPE_P(property) == IS_OBJECT
957+
if (ZEND_TYPE_IS_COMPLEX(info->type) && Z_TYPE_P(property) == IS_OBJECT
958958
&& zend_check_and_resolve_property_class_type(info, Z_OBJCE_P(property))) {
959959
return 1;
960960
}
@@ -1023,7 +1023,7 @@ static zend_always_inline bool zend_check_type_slow(
10231023
bool is_return_type, bool is_internal)
10241024
{
10251025
uint32_t type_mask;
1026-
if (ZEND_TYPE_HAS_CLASS(*type) && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
1026+
if (ZEND_TYPE_IS_COMPLEX(*type) && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
10271027
zend_class_entry *ce;
10281028
if (UNEXPECTED(ZEND_TYPE_HAS_LIST(*type))) {
10291029
zend_type *list_type;
@@ -3194,7 +3194,7 @@ static zend_always_inline int i_zend_verify_type_assignable_zval(
31943194
return 1;
31953195
}
31963196

3197-
if (ZEND_TYPE_HAS_CLASS(type) && zv_type == IS_OBJECT
3197+
if (ZEND_TYPE_IS_COMPLEX(type) && zv_type == IS_OBJECT
31983198
&& zend_check_and_resolve_property_class_type(info, Z_OBJCE_P(zv))) {
31993199
return 1;
32003200
}

Zend/zend_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ typedef struct {
161161
#define ZEND_TYPE_IS_SET(t) \
162162
(((t).type_mask & _ZEND_TYPE_MASK) != 0)
163163

164-
#define ZEND_TYPE_HAS_CLASS(t) \
164+
/* If a type is complex it means it's either a list with a union or intersection,
165+
* or the void pointer is a CE/Name */
166+
#define ZEND_TYPE_IS_COMPLEX(t) \
165167
((((t).type_mask) & _ZEND_TYPE_KIND_MASK) != 0)
166168

167169
#define ZEND_TYPE_HAS_CE(t) \

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ static zend_always_inline bool zend_jit_verify_type_common(zval *arg, zend_arg_i
13421342
{
13431343
uint32_t type_mask;
13441344

1345-
if (ZEND_TYPE_HAS_CLASS(arg_info->type) && Z_TYPE_P(arg) == IS_OBJECT) {
1345+
if (ZEND_TYPE_IS_COMPLEX(arg_info->type) && Z_TYPE_P(arg) == IS_OBJECT) {
13461346
zend_class_entry *ce;
13471347
if (ZEND_TYPE_HAS_LIST(arg_info->type)) {
13481348
zend_type *list_type;

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ static reflection_type_kind get_type_kind(zend_type type) {
13461346
return UNION_TYPE;
13471347
}
13481348

1349-
if (ZEND_TYPE_HAS_CLASS(type)) {
1349+
if (ZEND_TYPE_IS_COMPLEX(type)) {
13501350
if (type_mask_without_null != 0) {
13511351
return UNION_TYPE;
13521352
}

0 commit comments

Comments
 (0)