Skip to content

Commit 19724b4

Browse files
committed
Rename HAS_CLASS macro to IS_COMPLEX
1 parent b03088c commit 19724b4

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
@@ -2401,14 +2401,14 @@ static void zend_check_magic_method_return_type(const zend_class_entry *ce, cons
24012401
return;
24022402
}
24032403

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

2411-
if (extra_types || (has_class_type && return_type != MAY_BE_OBJECT)) {
2411+
if (extra_types || (is_complex_type && return_type != MAY_BE_OBJECT)) {
24122412
zend_error(error_type, "%s::%s(): Return type must be %s when declared",
24132413
ZSTR_VAL(ce->name), ZSTR_VAL(fptr->common.function_name),
24142414
ZSTR_VAL(zend_type_to_string((zend_type) ZEND_TYPE_INIT_MASK(return_type))));
@@ -2745,7 +2745,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
27452745
memcpy(new_arg_info, arg_info, sizeof(zend_arg_info) * num_args);
27462746
reg_function->common.arg_info = new_arg_info + 1;
27472747
for (i = 0; i < num_args; i++) {
2748-
if (ZEND_TYPE_HAS_CLASS(new_arg_info[i].type)) {
2748+
if (ZEND_TYPE_IS_COMPLEX(new_arg_info[i].type)) {
27492749
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(new_arg_info[i].type)
27502750
&& "Should be stored as simple name");
27512751
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
@@ -2419,7 +2419,7 @@ static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
24192419
/* }}} */
24202420

24212421
static size_t zend_type_get_num_classes(zend_type type) {
2422-
if (!ZEND_TYPE_HAS_CLASS(type)) {
2422+
if (!ZEND_TYPE_IS_COMPLEX(type)) {
24232423
return 0;
24242424
}
24252425
if (ZEND_TYPE_HAS_LIST(type)) {
@@ -6249,8 +6249,8 @@ static zend_type zend_compile_typename(
62496249
ZEND_TYPE_FULL_MASK(type) |= ZEND_TYPE_PURE_MASK(single_type);
62506250
ZEND_TYPE_FULL_MASK(single_type) &= ~_ZEND_TYPE_MAY_BE_MASK;
62516251

6252-
if (ZEND_TYPE_HAS_CLASS(single_type)) {
6253-
if (!ZEND_TYPE_HAS_CLASS(type)) {
6252+
if (ZEND_TYPE_IS_COMPLEX(single_type)) {
6253+
if (!ZEND_TYPE_IS_COMPLEX(type)) {
62546254
/* The first class type can be stored directly as the type ptr payload. */
62556255
ZEND_TYPE_SET_PTR(type, ZEND_TYPE_NAME(single_type));
62566256
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_NAME_BIT;
@@ -6323,7 +6323,7 @@ static zend_type zend_compile_typename(
63236323
/* Inform that the type is part of an intersection type */
63246324
ZEND_TYPE_FULL_MASK(single_type) |= _ZEND_TYPE_INTERSECTION_BIT;
63256325

6326-
if (!ZEND_TYPE_HAS_CLASS(type)) {
6326+
if (!ZEND_TYPE_IS_COMPLEX(type)) {
63276327
/* The first class type can be stored directly as the type ptr payload. */
63286328
ZEND_TYPE_SET_PTR(type, ZEND_TYPE_NAME(single_type));
63296329
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_NAME_BIT;
@@ -6387,19 +6387,19 @@ static zend_type zend_compile_typename(
63876387
zend_error_noreturn(E_COMPILE_ERROR, "Type mixed cannot be marked as nullable since mixed already includes null");
63886388
}
63896389

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

6397-
if ((type_mask & MAY_BE_VOID) && (ZEND_TYPE_HAS_CLASS(type) || type_mask != MAY_BE_VOID)) {
6397+
if ((type_mask & MAY_BE_VOID) && (ZEND_TYPE_IS_COMPLEX(type) || type_mask != MAY_BE_VOID)) {
63986398
zend_error_noreturn(E_COMPILE_ERROR, "Void can only be used as a standalone type");
63996399
}
64006400

64016401
if ((type_mask & (MAY_BE_NULL|MAY_BE_FALSE))
6402-
&& !ZEND_TYPE_HAS_CLASS(type) && !(type_mask & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
6402+
&& !ZEND_TYPE_IS_COMPLEX(type) && !(type_mask & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
64036403
if (type_mask == MAY_BE_NULL) {
64046404
zend_error_noreturn(E_COMPILE_ERROR, "Null can not be used as a standalone type");
64056405
} else {
@@ -7515,7 +7515,7 @@ static void zend_compile_enum_backing_type(zend_class_entry *ce, zend_ast *enum_
75157515
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_ENUM);
75167516
zend_type type = zend_compile_typename(enum_backing_type_ast, 0);
75177517
uint32_t type_mask = ZEND_TYPE_PURE_MASK(type);
7518-
if (ZEND_TYPE_HAS_CLASS(type) || (type_mask != MAY_BE_LONG && type_mask != MAY_BE_STRING)) {
7518+
if (ZEND_TYPE_IS_COMPLEX(type) || (type_mask != MAY_BE_LONG && type_mask != MAY_BE_STRING)) {
75197519
zend_string *type_string = zend_type_to_string(type);
75207520
zend_error_noreturn(E_COMPILE_ERROR,
75217521
"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
@@ -925,7 +925,7 @@ static zend_always_inline bool i_zend_check_property_type(zend_property_info *in
925925
return 1;
926926
}
927927

928-
if (ZEND_TYPE_HAS_CLASS(info->type) && Z_TYPE_P(property) == IS_OBJECT
928+
if (ZEND_TYPE_IS_COMPLEX(info->type) && Z_TYPE_P(property) == IS_OBJECT
929929
&& zend_check_and_resolve_property_class_type(info, Z_OBJCE_P(property))) {
930930
return 1;
931931
}
@@ -994,7 +994,7 @@ static zend_always_inline bool zend_check_type_slow(
994994
bool is_return_type, bool is_internal)
995995
{
996996
uint32_t type_mask;
997-
if (ZEND_TYPE_HAS_CLASS(*type) && Z_TYPE_P(arg) == IS_OBJECT) {
997+
if (ZEND_TYPE_IS_COMPLEX(*type) && Z_TYPE_P(arg) == IS_OBJECT) {
998998
zend_class_entry *ce;
999999
if (ZEND_TYPE_HAS_LIST(*type)) {
10001000
zend_type *list_type;
@@ -3147,7 +3147,7 @@ static zend_always_inline int i_zend_verify_type_assignable_zval(
31473147
return 1;
31483148
}
31493149

3150-
if (ZEND_TYPE_HAS_CLASS(type) && zv_type == IS_OBJECT
3150+
if (ZEND_TYPE_IS_COMPLEX(type) && zv_type == IS_OBJECT
31513151
&& zend_check_and_resolve_property_class_type(info, Z_OBJCE_P(zv))) {
31523152
return 1;
31533153
}

Zend/zend_types.h

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

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

168170
#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
@@ -1341,7 +1341,7 @@ static zend_always_inline bool zend_jit_verify_type_common(zval *arg, zend_arg_i
13411341
{
13421342
uint32_t type_mask;
13431343

1344-
if (ZEND_TYPE_HAS_CLASS(arg_info->type) && Z_TYPE_P(arg) == IS_OBJECT) {
1344+
if (ZEND_TYPE_IS_COMPLEX(arg_info->type) && Z_TYPE_P(arg) == IS_OBJECT) {
13451345
zend_class_entry *ce;
13461346
if (ZEND_TYPE_HAS_LIST(arg_info->type)) {
13471347
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)