Skip to content

Commit 22cc698

Browse files
committed
Address minor review comments
1 parent 8bb0f0c commit 22cc698

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

Zend/zend_compile.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6560,14 +6560,11 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
65606560
}
65616561
if (zend_string_equals_ci(ZEND_TYPE_NAME(type_list->types[i]), ZEND_TYPE_NAME(type))) {
65626562
zend_string *single_type_str = zend_type_to_string(type);
6563-
if (
6564-
ZEND_TYPE_IS_RELATIVE_SELF(type)
6565-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type)
6566-
) {
6563+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
65676564
if ( (
65686565
ZEND_TYPE_FULL_MASK(type)
65696566
& ZEND_TYPE_FULL_MASK(type_list->types[i])
6570-
& (_ZEND_TYPE_SELF_BIT|_ZEND_TYPE_PARENT_BIT)) != 0
6567+
& (_ZEND_TYPE_RELATIVE_TYPE_MASK)) != 0
65716568
) {
65726569
zend_error_noreturn(E_COMPILE_ERROR, "Duplicate type %s is redundant", ZSTR_VAL(single_type_str));
65736570
}
@@ -6576,10 +6573,7 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
65766573
zend_error_noreturn(E_COMPILE_ERROR, "%s resolves to %s which is redundant",
65776574
ZSTR_VAL(single_type_str), ZSTR_VAL(ZEND_TYPE_NAME(type))
65786575
);
6579-
} else if (
6580-
ZEND_TYPE_IS_RELATIVE_SELF(type_list->types[i])
6581-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type_list->types[i])
6582-
) {
6576+
} else if (ZEND_TYPE_IS_RELATIVE_TYPE(type_list->types[i])) {
65836577
/* zend_type_to_string() will return "self" or "parent" where the resolved type is stored in
65846578
* ZEND_TYPE_NAME() */
65856579
zend_error_noreturn(E_COMPILE_ERROR, "%s resolves to %s which is redundant",

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ static zend_type zend_resolve_single_type(zend_type type, const zend_class_entry
19861986
}
19871987

19881988
zend_type resolved_type = zend_resolve_name_type(single_type, ce);
1989-
if (zend_was_type_resolved(type, resolved_type)) {
1989+
if (zend_was_type_resolved(single_type, resolved_type)) {
19901990
if (!has_resolved_type) {
19911991
const zend_type_list *old_union_type_list = ZEND_TYPE_LIST(type);
19921992
union_type_list = zend_arena_alloc(&CG(arena), ZEND_TYPE_LIST_SIZE(old_union_type_list->num_types));

Zend/zend_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ typedef struct {
168168
(((t).type_mask & _ZEND_TYPE_MASK) != 0)
169169

170170

171+
/* To determine if the type resolved type was written with "self" or "parent" */
172+
#define ZEND_TYPE_IS_RELATIVE_TYPE(t) \
173+
((((t).type_mask) & _ZEND_TYPE_RELATIVE_TYPE_MASK) != 0)
171174
/* To determine if the type resolved type was written with "self" */
172175
#define ZEND_TYPE_IS_RELATIVE_SELF(t) \
173176
((((t).type_mask) & _ZEND_TYPE_SELF_BIT) != 0)

ext/reflection/php_reflection.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,9 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
13271327

13281328
typedef enum {
13291329
NAMED_TYPE = 0,
1330-
RELATIVE_TYPE = 3,
13311330
UNION_TYPE = 1,
1332-
INTERSECTION_TYPE = 2
1331+
INTERSECTION_TYPE = 2,
1332+
RELATIVE_TYPE = 3
13331333
} reflection_type_kind;
13341334

13351335
/* For backwards compatibility reasons, we need to return T|null style unions
@@ -1357,7 +1357,7 @@ static reflection_type_kind get_type_kind(zend_type type) {
13571357
}
13581358

13591359
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(type));
1360-
if (ZEND_TYPE_IS_RELATIVE_SELF(type) || ZEND_TYPE_IS_RELATIVE_PARENT(type)) {
1360+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
13611361
return RELATIVE_TYPE;
13621362
}
13631363
return NAMED_TYPE;
@@ -1370,7 +1370,6 @@ static reflection_type_kind get_type_kind(zend_type type) {
13701370
return UNION_TYPE;
13711371
}
13721372

1373-
/* "static" is a relative type */
13741373
if (type_mask_without_null == MAY_BE_STATIC) {
13751374
return RELATIVE_TYPE;
13761375
}
@@ -3142,7 +3141,7 @@ ZEND_METHOD(ReflectionRelativeClassType, resolveToNamedType)
31423141
}
31433142
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(intern->ce->name, allows_null, /*extra flags */ 0);
31443143
} else {
3145-
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_SELF(param->type) || ZEND_TYPE_IS_RELATIVE_PARENT(param->type));
3144+
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_TYPE(param->type));
31463145
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(param->type));
31473146
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(ZEND_TYPE_NAME(param->type), allows_null, /*extra flags */ 0);
31483147
}

0 commit comments

Comments
 (0)