Skip to content

Commit 0f0d697

Browse files
committed
Address minor review comments
1 parent e4e7b94 commit 0f0d697

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
@@ -6763,14 +6763,11 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
67636763
}
67646764
if (zend_string_equals_ci(ZEND_TYPE_NAME(type_list->types[i]), ZEND_TYPE_NAME(type))) {
67656765
zend_string *single_type_str = zend_type_to_string(type);
6766-
if (
6767-
ZEND_TYPE_IS_RELATIVE_SELF(type)
6768-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type)
6769-
) {
6766+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
67706767
if ( (
67716768
ZEND_TYPE_FULL_MASK(type)
67726769
& ZEND_TYPE_FULL_MASK(type_list->types[i])
6773-
& (_ZEND_TYPE_SELF_BIT|_ZEND_TYPE_PARENT_BIT)) != 0
6770+
& (_ZEND_TYPE_RELATIVE_TYPE_MASK)) != 0
67746771
) {
67756772
zend_error_noreturn(E_COMPILE_ERROR, "Duplicate type %s is redundant", ZSTR_VAL(single_type_str));
67766773
}
@@ -6779,10 +6776,7 @@ static void zend_is_type_list_redundant_by_single_type(zend_type_list *type_list
67796776
zend_error_noreturn(E_COMPILE_ERROR, "%s resolves to %s which is redundant",
67806777
ZSTR_VAL(single_type_str), ZSTR_VAL(ZEND_TYPE_NAME(type))
67816778
);
6782-
} else if (
6783-
ZEND_TYPE_IS_RELATIVE_SELF(type_list->types[i])
6784-
|| ZEND_TYPE_IS_RELATIVE_PARENT(type_list->types[i])
6785-
) {
6779+
} else if (ZEND_TYPE_IS_RELATIVE_TYPE(type_list->types[i])) {
67866780
/* zend_type_to_string() will return "self" or "parent" where the resolved type is stored in
67876781
* ZEND_TYPE_NAME() */
67886782
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
@@ -1338,9 +1338,9 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
13381338

13391339
typedef enum {
13401340
NAMED_TYPE = 0,
1341-
RELATIVE_TYPE = 3,
13421341
UNION_TYPE = 1,
1343-
INTERSECTION_TYPE = 2
1342+
INTERSECTION_TYPE = 2,
1343+
RELATIVE_TYPE = 3
13441344
} reflection_type_kind;
13451345

13461346
/* For backwards compatibility reasons, we need to return T|null style unions
@@ -1368,7 +1368,7 @@ static reflection_type_kind get_type_kind(zend_type type) {
13681368
}
13691369

13701370
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(type));
1371-
if (ZEND_TYPE_IS_RELATIVE_SELF(type) || ZEND_TYPE_IS_RELATIVE_PARENT(type)) {
1371+
if (ZEND_TYPE_IS_RELATIVE_TYPE(type)) {
13721372
return RELATIVE_TYPE;
13731373
}
13741374
return NAMED_TYPE;
@@ -1381,7 +1381,6 @@ static reflection_type_kind get_type_kind(zend_type type) {
13811381
return UNION_TYPE;
13821382
}
13831383

1384-
/* "static" is a relative type */
13851384
if (type_mask_without_null == MAY_BE_STATIC) {
13861385
return RELATIVE_TYPE;
13871386
}
@@ -3160,7 +3159,7 @@ ZEND_METHOD(ReflectionRelativeClassType, resolveToNamedType)
31603159
}
31613160
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(intern->ce->name, allows_null, /*extra flags */ 0);
31623161
} else {
3163-
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_SELF(param->type) || ZEND_TYPE_IS_RELATIVE_PARENT(param->type));
3162+
ZEND_ASSERT(ZEND_TYPE_IS_RELATIVE_TYPE(param->type));
31643163
ZEND_ASSERT(ZEND_TYPE_HAS_NAME(param->type));
31653164
resolved_type = (zend_type) ZEND_TYPE_INIT_CLASS(ZEND_TYPE_NAME(param->type), allows_null, /*extra flags */ 0);
31663165
}

0 commit comments

Comments
 (0)