mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Use smart_str_append() if we have a zend_string* (#21414)
This commit is contained in:
committed by
GitHub
parent
4d528531be
commit
f40b356ad9
@@ -565,6 +565,7 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
|
||||
zend_object *zobj = Z_OBJ_P(expr);
|
||||
uint32_t *guard = zend_get_recursion_guard(zobj);
|
||||
zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(zobj);
|
||||
/* cut off on NULL byte ... class@anonymous */
|
||||
smart_str_appends(buf, ZSTR_VAL(class_name));
|
||||
zend_string_release_ex(class_name, 0);
|
||||
|
||||
|
||||
@@ -2160,7 +2160,7 @@ tail_call:
|
||||
break;
|
||||
case ZEND_AST_CONSTANT: {
|
||||
zend_string *name = zend_ast_get_constant_name(ast);
|
||||
smart_str_appendl(str, ZSTR_VAL(name), ZSTR_LEN(name));
|
||||
smart_str_append(str, name);
|
||||
break;
|
||||
}
|
||||
case ZEND_AST_OP_ARRAY:
|
||||
@@ -2210,7 +2210,7 @@ tail_call:
|
||||
smart_str_appendc(str, '&');
|
||||
}
|
||||
if (ast->kind != ZEND_AST_CLOSURE && ast->kind != ZEND_AST_ARROW_FUNC) {
|
||||
smart_str_appendl(str, ZSTR_VAL(decl->name), ZSTR_LEN(decl->name));
|
||||
smart_str_append(str, decl->name);
|
||||
}
|
||||
smart_str_appendc(str, '(');
|
||||
zend_ast_export_ex(str, decl->child[0], 0, indent);
|
||||
@@ -2268,7 +2268,7 @@ tail_call:
|
||||
}
|
||||
smart_str_appends(str, "class ");
|
||||
}
|
||||
smart_str_appendl(str, ZSTR_VAL(decl->name), ZSTR_LEN(decl->name));
|
||||
smart_str_append(str, decl->name);
|
||||
if (decl->flags & ZEND_ACC_ENUM && decl->child[4]) {
|
||||
smart_str_appends(str, ": ");
|
||||
zend_ast_export_type(str, decl->child[4], indent);
|
||||
|
||||
@@ -497,12 +497,12 @@ ZEND_METHOD(ErrorException, getSeverity)
|
||||
#define TRACE_APPEND_KEY(key) do { \
|
||||
tmp = zend_hash_find(ht, key); \
|
||||
if (tmp) { \
|
||||
if (Z_TYPE_P(tmp) != IS_STRING) { \
|
||||
if (UNEXPECTED(Z_TYPE_P(tmp) != IS_STRING)) { \
|
||||
zend_error(E_WARNING, "Value for %s is not a string", \
|
||||
ZSTR_VAL(key)); \
|
||||
smart_str_appends(str, "[unknown]"); \
|
||||
} else { \
|
||||
smart_str_appends(str, Z_STRVAL_P(tmp)); \
|
||||
smart_str_append(str, Z_STR_P(tmp)); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -532,6 +532,7 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */
|
||||
case IS_OBJECT: {
|
||||
zend_string *class_name = Z_OBJ_HANDLER_P(arg, get_class_name)(Z_OBJ_P(arg));
|
||||
smart_str_appends(str, "Object(");
|
||||
/* cut off on NULL byte ... class@anonymous */
|
||||
smart_str_appends(str, ZSTR_VAL(class_name));
|
||||
smart_str_appends(str, "), ");
|
||||
zend_string_release_ex(class_name, 0);
|
||||
@@ -573,7 +574,16 @@ static void _build_trace_string(smart_str *str, const HashTable *ht, uint32_t nu
|
||||
} else {
|
||||
smart_str_appends(str, "[internal function]: ");
|
||||
}
|
||||
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_CLASS));
|
||||
const zval *class_name = zend_hash_find(ht, ZSTR_KNOWN(ZEND_STR_CLASS));
|
||||
if (class_name) {
|
||||
if (UNEXPECTED(Z_TYPE_P(class_name) != IS_STRING)) {
|
||||
zend_error(E_WARNING, "Value for class is not a string");
|
||||
smart_str_appends(str, "[unknown]");
|
||||
} else {
|
||||
/* cut off on NULL byte ... class@anonymous */
|
||||
smart_str_appends(str, Z_STRVAL_P(class_name));
|
||||
}
|
||||
}
|
||||
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_TYPE));
|
||||
TRACE_APPEND_KEY(ZSTR_KNOWN(ZEND_STR_FUNCTION));
|
||||
smart_str_appendc(str, '(');
|
||||
|
||||
@@ -924,7 +924,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
|
||||
/* cut off on NULL byte ... class@anonymous */
|
||||
smart_str_appends(&str, ZSTR_VAL(fptr->common.scope->name));
|
||||
} else {
|
||||
smart_str_appendl(&str, ZSTR_VAL(fptr->common.scope->name), ZSTR_LEN(fptr->common.scope->name));
|
||||
smart_str_append(&str, fptr->common.scope->name);
|
||||
}
|
||||
smart_str_appends(&str, "::");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user