This is a recurring pattern.
}
/* }}} */
-static zend_string *zend_create_method_string(zend_string *class_name, zend_string *method_name) {
- zend_string *callable_name = zend_string_alloc(
- ZSTR_LEN(class_name) + ZSTR_LEN(method_name) + sizeof("::") - 1, 0);
- char *ptr = ZSTR_VAL(callable_name);
- memcpy(ptr, ZSTR_VAL(class_name), ZSTR_LEN(class_name));
- ptr += ZSTR_LEN(class_name);
- memcpy(ptr, "::", sizeof("::") - 1);
- ptr += sizeof("::") - 1;
- memcpy(ptr, ZSTR_VAL(method_name), ZSTR_LEN(method_name) + 1);
- return callable_name;
-}
-
ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object) /* {{{ */
{
try_again:
switch (Z_TYPE_P(callable)) {
case IS_STRING:
if (object) {
- return zend_create_method_string(object->ce->name, Z_STR_P(callable));
+ return zend_create_member_string(object->ce->name, Z_STR_P(callable));
}
return zend_string_copy(Z_STR_P(callable));
}
if (Z_TYPE_P(obj) == IS_STRING) {
- return zend_create_method_string(Z_STR_P(obj), Z_STR_P(method));
+ return zend_create_member_string(Z_STR_P(obj), Z_STR_P(method));
} else if (Z_TYPE_P(obj) == IS_OBJECT) {
- return zend_create_method_string(Z_OBJCE_P(obj)->name, Z_STR_P(method));
+ return zend_create_member_string(Z_OBJCE_P(obj)->name, Z_STR_P(method));
} else {
return ZSTR_KNOWN(ZEND_STR_ARRAY_CAPITALIZED);
}
}
/* }}} */
+ZEND_API zend_string *zend_create_member_string(zend_string *class_name, zend_string *member_name) {
+ return zend_string_concat3(
+ ZSTR_VAL(class_name), ZSTR_LEN(class_name),
+ "::", sizeof("::") - 1,
+ ZSTR_VAL(member_name), ZSTR_LEN(member_name));
+}
+
zend_string *zend_concat_names(char *name1, size_t name1_len, char *name2, size_t name2_len) {
return zend_string_concat3(name1, name1_len, "\\", 1, name2, name2_len);
}
}
if (op_array && op_array->function_name) {
if (op_array->scope) {
- ZVAL_NEW_STR(zv, zend_string_concat3(
- ZSTR_VAL(op_array->scope->name), ZSTR_LEN(op_array->scope->name),
- "::", 2,
- ZSTR_VAL(op_array->function_name), ZSTR_LEN(op_array->function_name)));
+ ZVAL_NEW_STR(zv,
+ zend_create_member_string(op_array->scope->name, op_array->function_name));
} else {
ZVAL_STR_COPY(zv, op_array->function_name);
}
zend_string_addref(class_name);
}
- name = zend_string_concat3(
- ZSTR_VAL(class_name), ZSTR_LEN(class_name), "::", 2, ZSTR_VAL(const_name), ZSTR_LEN(const_name));
+ name = zend_create_member_string(class_name, const_name);
zend_ast_destroy(ast);
zend_string_release_ex(class_name, 0);
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce);
ZEND_API void zend_cleanup_internal_classes(void);
ZEND_API void zend_type_release(zend_type type, zend_bool persistent);
+ZEND_API zend_string *zend_create_member_string(zend_string *class_name, zend_string *member_name);
ZEND_API ZEND_COLD void zend_user_exception_handler(void);
zval *prop_name = &op_array->literals[op2];
zval *pos, tmp;
- zend_string *key = zend_string_concat3(
- Z_STRVAL_P(class_name), Z_STRLEN_P(class_name),
- "::", sizeof("::") - 1,
- Z_STRVAL_P(prop_name), Z_STRLEN_P(prop_name));
-
+ zend_string *key = zend_create_member_string(Z_STR_P(class_name), Z_STR_P(prop_name));
ZSTR_H(key) = zend_string_hash_func(key);
ZSTR_H(key) += kind;