Skip to content

Commit 1910966

Browse files
committed
Address minor review comments
1 parent c0f0878 commit 1910966

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
@@ -6532,14 +6532,11 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
65326532
}
65336533
if (zend_string_equals_ci(ZEND_TYPE_NAME(type_list->types[i]), ZEND_TYPE_NAME(type))) {
65346534
zend_string *single_type_str = zend_type_to_string(type);
6535-
if (
6536-
ZEND_TYPE_IS_RELATIVE_SELF(type)
6537-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type)
6538-
) {
6535+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
65396536
if ( (
65406537
ZEND_TYPE_FULL_MASK(type)
65416538
& ZEND_TYPE_FULL_MASK(type_list->types[i])
6542-
& (_ZEND_TYPE_SELF_BIT|_ZEND_TYPE_PARENT_BIT)) != 0
6539+
& (_ZEND_TYPE_RELATIVE_TYPE_MASK)) != 0
65436540
) {
65446541
zend_error_noreturn(E_COMPILE_ERROR, "Duplicate type %s is redundant", ZSTR_VAL(single_type_str));
65456542
}
@@ -6548,10 +6545,7 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
65486545
zend_error_noreturn(E_COMPILE_ERROR, "%s resolves to %s which is redundant",
65496546
ZSTR_VAL(single_type_str), ZSTR_VAL(ZEND_TYPE_NAME(type))
65506547
);
6551-
} else if (
6552-
ZEND_TYPE_IS_RELATIVE_SELF(type_list->types[i])
6553-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type_list->types[i])
6554-
) {
6548+
} else if (ZEND_TYPE_IS_RELATIVE_TYPE(type_list->types[i])) {
65556549
/* zend_type_to_string() will return "self" or "parent" where the resolved type is stored in
65566550
* ZEND_TYPE_NAME() */
65576551
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
@@ -1955,7 +1955,7 @@ static zend_type zend_resolve_single_type(zend_type type, const zend_class_entry
19551955
}
19561956

19571957
zend_type resolved_type = zend_resolve_name_type(single_type, ce);
1958-
if (zend_was_type_resolved(type, resolved_type)) {
1958+
if (zend_was_type_resolved(single_type, resolved_type)) {
19591959
if (!has_resolved_type) {
19601960
const zend_type_list *old_union_type_list = ZEND_TYPE_LIST(type);
19611961
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
@@ -1329,9 +1329,9 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
13291329

13301330
typedef enum {
13311331
NAMED_TYPE = 0,
1332-
RELATIVE_TYPE = 3,
13331332
UNION_TYPE = 1,
1334-
INTERSECTION_TYPE = 2
1333+
INTERSECTION_TYPE = 2,
1334+
RELATIVE_TYPE = 3
13351335
} reflection_type_kind;
13361336

13371337
/* For backwards compatibility reasons, we need to return T|null style unions
@@ -1359,7 +1359,7 @@ static reflection_type_kind get_type_kind(zend_type type) {
13591359
}
13601360

13611361
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(type));
1362-
if (ZEND_TYPE_IS_RELATIVE_SELF(type) || ZEND_TYPE_IS_RELATIVE_PARENT(type)) {
1362+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
13631363
return RELATIVE_TYPE;
13641364
}
13651365
return NAMED_TYPE;
@@ -1372,7 +1372,6 @@ static reflection_type_kind get_type_kind(zend_type type) {
13721372
return UNION_TYPE;
13731373
}
13741374

1375-
/* "static" is a relative type */
13761375
if (type_mask_without_null == MAY_BE_STATIC) {
13771376
return RELATIVE_TYPE;
13781377
}
@@ -3144,7 +3143,7 @@ ZEND_METHOD(ReflectionRelativeClassType, resolveToNamedType)
31443143
}
31453144
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(intern->ce->name, allows_null, /*extra flags */ 0);
31463145
} else {
3147-
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_SELF(param->type) || ZEND_TYPE_IS_RELATIVE_PARENT(param->type));
3146+
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_TYPE(param->type));
31483147
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(param->type));
31493148
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(ZEND_TYPE_NAME(param->type), allows_null, /*extra flags */ 0);
31503149
}

0 commit comments

Comments
 (0)