Skip to content

Commit 71a7f6d

Browse files
committed
fix traits
1 parent 17fa07c commit 71a7f6d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Zend/zend_execute_API.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ static zend_class_entry *zend_resolve_nested_class(zend_string *requested_name,
11741174
const char *unqualified_name = strrchr(ZSTR_VAL(requested_name), '|');
11751175
if (unqualified_name == NULL) {
11761176
unqualified_name = strrchr(ZSTR_VAL(requested_name), '\\');
1177+
if (unqualified_name == NULL) {
1178+
// there is not a nested class here...
1179+
return NULL;
1180+
}
11771181
}
11781182

11791183
zend_string *inner_name = zend_string_init(unqualified_name + 1, ZSTR_LEN(requested_name) - (unqualified_name - ZSTR_VAL(requested_name) + 1), 0);
@@ -1299,10 +1303,13 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
12991303
/* Check to see if our current scope is an outer class; if it is, we need to check the outer class's
13001304
* namespace for the class we're looking for. */
13011305
if (!(flags & ZEND_FETCH_CLASS_NO_INNER)) {
1302-
if (!key) {
1303-
zend_string_release_ex(lc_name, 0);
1306+
ce = zend_resolve_nested_class(name, flags);
1307+
if (ce) {
1308+
if (!key) {
1309+
zend_string_release_ex(lc_name, 0);
1310+
}
1311+
return ce;
13041312
}
1305-
return zend_resolve_nested_class(name, flags);
13061313
}
13071314

13081315
if ((flags & ZEND_FETCH_CLASS_NO_AUTOLOAD) || zend_is_compiling()) {

Zend/zend_inheritance.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,9 +2635,7 @@ static void zend_traits_init_trait_structures(zend_class_entry *ce, zend_class_e
26352635
lcname = zend_string_tolower(cur_method_ref->method_name);
26362636
if (cur_method_ref->class_name) {
26372637
/* For all aliases with an explicit class name, resolve the class now. */
2638-
lc_trait_name = zend_string_tolower(cur_method_ref->class_name);
2639-
trait = zend_hash_find_ptr(EG(class_table), lc_trait_name);
2640-
zend_string_release_ex(lc_trait_name, 0);
2638+
trait = zend_fetch_class(cur_method_ref->class_name, ZEND_FETCH_CLASS_NO_AUTOLOAD);
26412639
if (!trait || !(trait->ce_flags & ZEND_ACC_LINKED)) {
26422640
zend_error_noreturn(E_COMPILE_ERROR, "Could not find trait %s", ZSTR_VAL(cur_method_ref->class_name));
26432641
}

0 commit comments

Comments
 (0)