Skip to content

Commit ac364dc

Browse files
committed
simplify resolution logic
1 parent f29972a commit ac364dc

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

Zend/zend_compile.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,57 +1180,29 @@ static zend_string *zend_resolve_const_name(zend_string *name, uint32_t type, bo
11801180
name, type, is_fully_qualified, 1, FC(imports_const));
11811181
}
11821182

1183-
static zend_string *get_namespace_from_scope(const zend_class_entry *scope)
1184-
{
1185-
ZEND_ASSERT(scope != NULL);
1186-
while (scope && scope->lexical_scope && scope->type != ZEND_NAMESPACE_CLASS) {
1187-
scope = scope->lexical_scope;
1188-
}
1189-
return zend_string_copy(scope->name);
1190-
}
1191-
1192-
static zend_string *get_scoped_name(zend_string *ns, zend_string *name)
1193-
{
1194-
name = zend_string_tolower(name);
1195-
if (ns && ZSTR_LEN(ns) && ZSTR_LEN(name) > ZSTR_LEN(ns) + 1 &&
1196-
memcmp(ZSTR_VAL(name), ZSTR_VAL(ns), ZSTR_LEN(ns)) == 0 &&
1197-
ZSTR_VAL(name)[ZSTR_LEN(ns)] == '\\') {
1198-
zend_string *ret = zend_string_init(ZSTR_VAL(name) + ZSTR_LEN(ns) + 1, ZSTR_LEN(name) - ZSTR_LEN(ns) - 1, 0);
1199-
zend_string_release(name);
1200-
return ret;
1201-
}
1202-
return name;
1203-
}
1204-
12051183
zend_string *zend_resolve_class_in_scope(zend_string *name, const zend_class_entry *scope)
12061184
{
1207-
zend_string *ns_name = get_namespace_from_scope(scope);
1208-
zend_string *original_suffix = get_scoped_name(ns_name, name);
1209-
zend_string_release(ns_name);
1210-
12111185
const zend_class_entry *current_scope = scope;
12121186

12131187
while (current_scope && current_scope->type != ZEND_NAMESPACE_CLASS) {
12141188
zend_string *try_name = zend_string_concat3(
12151189
ZSTR_VAL(current_scope->name), ZSTR_LEN(current_scope->name),
12161190
"\\", 1,
1217-
ZSTR_VAL(original_suffix), ZSTR_LEN(original_suffix));
1191+
ZSTR_VAL(name), ZSTR_LEN(name));
12181192

12191193
zend_string *lc_try_name = zend_string_tolower(try_name);
12201194

12211195
bool has_seen = zend_have_seen_symbol(lc_try_name, ZEND_SYMBOL_CLASS);
12221196
zend_string_release(lc_try_name);
12231197

12241198
if (has_seen) {
1225-
zend_string_release(original_suffix);
12261199
return try_name;
12271200
}
12281201
zend_string_release(try_name);
12291202

12301203
current_scope = current_scope->lexical_scope;
12311204
}
12321205

1233-
zend_string_release(original_suffix);
12341206
return NULL;
12351207
}
12361208

0 commit comments

Comments
 (0)