Skip to content

Commit a02eb62

Browse files
committed
Refactor check for self/parent
1 parent e334504 commit a02eb62

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Zend/zend_compile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6310,20 +6310,20 @@ static zend_type zend_compile_typename(
63106310
for (uint32_t i = 0; i < list->children; i++) {
63116311
zend_ast *type_ast = list->child[i];
63126312
zend_type single_type = zend_compile_single_typename(type_ast);
6313-
zend_string *standard_type_str = zend_type_to_string(single_type);
63146313

63156314
/* An intersection of standard types cannot exist so invalidate it */
63166315
if (ZEND_TYPE_IS_ONLY_MASK(single_type)) {
6316+
zend_string *standard_type_str = zend_type_to_string(single_type);
63176317
zend_error_noreturn(E_COMPILE_ERROR,
63186318
"Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str));
6319+
zend_string_release_ex(standard_type_str, false);
63196320
}
63206321
/* Check for "self" and "parent" too */
6321-
if (zend_string_equals_literal_ci(standard_type_str, "self")
6322-
|| zend_string_equals_literal_ci(standard_type_str, "parent")) {
6322+
if (zend_string_equals_literal_ci(ZEND_TYPE_NAME(single_type), "self")
6323+
|| zend_string_equals_literal_ci(ZEND_TYPE_NAME(single_type), "parent")) {
63236324
zend_error_noreturn(E_COMPILE_ERROR,
6324-
"Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str));
6325+
"Type %s cannot be part of an intersection type", ZSTR_VAL(ZEND_TYPE_NAME(single_type)));
63256326
}
6326-
zend_string_release_ex(standard_type_str, false);
63276327

63286328
/* Add type to the type list */
63296329
type_list->types[type_list->num_types++] = single_type;

0 commit comments

Comments
 (0)