mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Improve error message
This commit is contained in:
parent
3b2f56275a
commit
09e76476ef
4 changed files with 33 additions and 29 deletions
|
@ -3001,8 +3001,10 @@ int zend_recv_handler(ZEND_OPCODE_HANDLER_ARGS)
|
||||||
zend_uint arg_num = opline->op1.u.constant.value.lval;
|
zend_uint arg_num = opline->op1.u.constant.value.lval;
|
||||||
|
|
||||||
if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) {
|
if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) {
|
||||||
|
char *space;
|
||||||
|
char *class_name = get_active_class_name(&space TSRMLS_CC);
|
||||||
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC);
|
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC);
|
||||||
zend_error(E_WARNING, "Missing argument %ld for %s()", opline->op1.u.constant.value.lval, get_active_function_name(TSRMLS_C));
|
zend_error(E_WARNING, "Missing argument %ld for %s%s%s()", opline->op1.u.constant.value.lval, class_name, space, get_active_function_name(TSRMLS_C));
|
||||||
if (opline->result.op_type == IS_VAR) {
|
if (opline->result.op_type == IS_VAR) {
|
||||||
PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr);
|
PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ void execute_new_code(TSRMLS_D);
|
||||||
|
|
||||||
|
|
||||||
/* services */
|
/* services */
|
||||||
|
ZEND_API char *get_active_class_name(char **space TSRMLS_DC);
|
||||||
ZEND_API char *get_active_function_name(TSRMLS_D);
|
ZEND_API char *get_active_function_name(TSRMLS_D);
|
||||||
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
|
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
|
||||||
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
|
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
|
||||||
|
|
|
@ -297,6 +297,35 @@ void shutdown_executor(TSRMLS_D)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* return class name and "::" or "". */
|
||||||
|
ZEND_API char *get_active_class_name(char **space TSRMLS_DC)
|
||||||
|
{
|
||||||
|
if (!zend_is_executing(TSRMLS_C)) {
|
||||||
|
if (space) {
|
||||||
|
*space = "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
switch (EG(function_state_ptr)->function->type) {
|
||||||
|
case ZEND_USER_FUNCTION:
|
||||||
|
case ZEND_INTERNAL_FUNCTION:
|
||||||
|
{
|
||||||
|
zend_class_entry *ce = EG(function_state_ptr)->function->common.scope;
|
||||||
|
|
||||||
|
if (space) {
|
||||||
|
*space = ce ? "::" : "";
|
||||||
|
}
|
||||||
|
return ce ? ce->name : "";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (space) {
|
||||||
|
*space = "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ZEND_API char *get_active_function_name(TSRMLS_D)
|
ZEND_API char *get_active_function_name(TSRMLS_D)
|
||||||
{
|
{
|
||||||
if (!zend_is_executing(TSRMLS_C)) {
|
if (!zend_is_executing(TSRMLS_C)) {
|
||||||
|
|
28
main/main.c
28
main/main.c
|
@ -424,34 +424,6 @@ static int php_during_module_shutdown()
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ get_active_class_name */
|
|
||||||
static char *get_active_class_name(char **space TSRMLS_DC)
|
|
||||||
{
|
|
||||||
if (!zend_is_executing(TSRMLS_C)) {
|
|
||||||
if (space) {
|
|
||||||
*space = "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
switch (EG(function_state_ptr)->function->type) {
|
|
||||||
case ZEND_USER_FUNCTION:
|
|
||||||
case ZEND_INTERNAL_FUNCTION:
|
|
||||||
{
|
|
||||||
zend_class_entry *ce = EG(function_state_ptr)->function->common.scope;
|
|
||||||
|
|
||||||
if (space) {
|
|
||||||
*space = ce ? "::" : "";
|
|
||||||
}
|
|
||||||
return ce ? ce->name : "";
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
if (space) {
|
|
||||||
*space = "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ php_verror */
|
/* {{{ php_verror */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue