Skip to content

Commit cb8a130

Browse files
committed
Refactor check for self/parent
1 parent 4a4b4f6 commit cb8a130

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
@@ -6312,20 +6312,20 @@ static zend_type zend_compile_typename(
63126312
for (uint32_t i = 0; i < list->children; i++) {
63136313
zend_ast *type_ast = list->child[i];
63146314
zend_type single_type = zend_compile_single_typename(type_ast);
6315-
zend_string *standard_type_str = zend_type_to_string(single_type);
63166315

63176316
/* An intersection of standard types cannot exist so invalidate it */
63186317
if (ZEND_TYPE_IS_ONLY_MASK(single_type)) {
6318+
zend_string *standard_type_str = zend_type_to_string(single_type);
63196319
zend_error_noreturn(E_COMPILE_ERROR,
63206320
"Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str));
6321+
zend_string_release_ex(standard_type_str, false);
63216322
}
63226323
/* Check for "self" and "parent" too */
6323-
if (zend_string_equals_literal_ci(standard_type_str, "self")
6324-
|| zend_string_equals_literal_ci(standard_type_str, "parent")) {
6324+
if (zend_string_equals_literal_ci(ZEND_TYPE_NAME(single_type), "self")
6325+
|| zend_string_equals_literal_ci(ZEND_TYPE_NAME(single_type), "parent")) {
63256326
zend_error_noreturn(E_COMPILE_ERROR,
6326-
"Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str));
6327+
"Type %s cannot be part of an intersection type", ZSTR_VAL(ZEND_TYPE_NAME(single_type)));
63276328
}
6328-
zend_string_release_ex(standard_type_str, false);
63296329

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

0 commit comments

Comments
 (0)