Skip to content

Commit 08648dd

Browse files
committed
Address minor review comments
1 parent 560b1d6 commit 08648dd

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
@@ -6791,14 +6791,11 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
67916791
}
67926792
if (zend_string_equals_ci(ZEND_TYPE_NAME(type_list->types[i]), ZEND_TYPE_NAME(type))) {
67936793
zend_string *single_type_str = zend_type_to_string(type);
6794-
if (
6795-
ZEND_TYPE_IS_RELATIVE_SELF(type)
6796-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type)
6797-
) {
6794+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
67986795
if ( (
67996796
ZEND_TYPE_FULL_MASK(type)
68006797
& ZEND_TYPE_FULL_MASK(type_list->types[i])
6801-
& (_ZEND_TYPE_SELF_BIT|_ZEND_TYPE_PARENT_BIT)) != 0
6798+
& (_ZEND_TYPE_RELATIVE_TYPE_MASK)) != 0
68026799
) {
68036800
zend_error_noreturn(E_COMPILE_ERROR, "Duplicate type %s is redundant", ZSTR_VAL(single_type_str));
68046801
}
@@ -6807,10 +6804,7 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
68076804
zend_error_noreturn(E_COMPILE_ERROR, "%s resolves to %s which is redundant",
68086805
ZSTR_VAL(single_type_str), ZSTR_VAL(ZEND_TYPE_NAME(type))
68096806
);
6810-
} else if (
6811-
ZEND_TYPE_IS_RELATIVE_SELF(type_list->types[i])
6812-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type_list->types[i])
6813-
) {
6807+
} else if (ZEND_TYPE_IS_RELATIVE_TYPE(type_list->types[i])) {
68146808
/* zend_type_to_string() will return "self" or "parent" where the resolved type is stored in
68156809
* ZEND_TYPE_NAME() */
68166810
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
@@ -2003,7 +2003,7 @@ static zend_type zend_resolve_single_type(zend_type type, const zend_class_entry
20032003
}
20042004

20052005
zend_type resolved_type = zend_resolve_name_type(single_type, ce);
2006-
if (zend_was_type_resolved(type, resolved_type)) {
2006+
if (zend_was_type_resolved(single_type, resolved_type)) {
20072007
if (!has_resolved_type) {
20082008
const zend_type_list *old_union_type_list = ZEND_TYPE_LIST(type);
20092009
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
@@ -171,6 +171,9 @@ typedef struct {
171171
(((t).type_mask & _ZEND_TYPE_MASK) != 0)
172172

173173

174+
/* To determine if the type resolved type was written with "self" or "parent" */
175+
#define ZEND_TYPE_IS_RELATIVE_TYPE(t) \
176+
((((t).type_mask) & _ZEND_TYPE_RELATIVE_TYPE_MASK) != 0)
174177
/* To determine if the type resolved type was written with "self" */
175178
#define ZEND_TYPE_IS_RELATIVE_SELF(t) \
176179
((((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
@@ -1367,9 +1367,9 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
13671367

13681368
typedef enum {
13691369
NAMED_TYPE = 0,
1370-
RELATIVE_TYPE = 3,
13711370
UNION_TYPE = 1,
1372-
INTERSECTION_TYPE = 2
1371+
INTERSECTION_TYPE = 2,
1372+
RELATIVE_TYPE = 3
13731373
} reflection_type_kind;
13741374

13751375
/* For backwards compatibility reasons, we need to return T|null style unions
@@ -1397,7 +1397,7 @@ static reflection_type_kind get_type_kind(zend_type type) {
13971397
}
13981398

13991399
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(type));
1400-
if (ZEND_TYPE_IS_RELATIVE_SELF(type) || ZEND_TYPE_IS_RELATIVE_PARENT(type)) {
1400+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
14011401
return RELATIVE_TYPE;
14021402
}
14031403
return NAMED_TYPE;
@@ -1410,7 +1410,6 @@ static reflection_type_kind get_type_kind(zend_type type) {
14101410
return UNION_TYPE;
14111411
}
14121412

1413-
/* "static" is a relative type */
14141413
if (type_mask_without_null == MAY_BE_STATIC) {
14151414
return RELATIVE_TYPE;
14161415
}
@@ -3189,7 +3188,7 @@ ZEND_METHOD(ReflectionRelativeClassType, resolveToNamedType)
31893188
}
31903189
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(intern->ce->name, allows_null, /*extra flags */ 0);
31913190
} else {
3192-
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_SELF(param->type) || ZEND_TYPE_IS_RELATIVE_PARENT(param->type));
3191+
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_TYPE(param->type));
31933192
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(param->type));
31943193
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(ZEND_TYPE_NAME(param->type), allows_null, /*extra flags */ 0);
31953194
}

0 commit comments

Comments
 (0)