Add RETURN_EMPTY_ARRAY() / RETVAL_EMPTY_ARRAY()

The usual wrappers around ZVAL_EMPTY_ARRAY()...
This commit is contained in:
Nikita Popov 2019-05-14 14:57:10 +02:00
parent 7bc4bd0229
commit 3f19f5112a
9 changed files with 27 additions and 37 deletions

View File

@ -614,6 +614,7 @@ END_EXTERN_C()
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
#define RETVAL_RES(r) ZVAL_RES(return_value, r)
#define RETVAL_ARR(r) ZVAL_ARR(return_value, r)
#define RETVAL_EMPTY_ARRAY(r) ZVAL_EMPTY_ARRAY(return_value)
#define RETVAL_OBJ(r) ZVAL_OBJ(return_value, r)
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
#define RETVAL_FALSE ZVAL_FALSE(return_value)
@ -632,6 +633,7 @@ END_EXTERN_C()
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
#define RETURN_RES(r) { RETVAL_RES(r); return; }
#define RETURN_ARR(r) { RETVAL_ARR(r); return; }
#define RETURN_EMPTY_ARRAY(r) { RETVAL_EMPTY_ARRAY(r); return; }
#define RETURN_OBJ(r) { RETVAL_OBJ(r); return; }
#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; }
#define RETURN_FALSE { RETVAL_FALSE; return; }

View File

@ -566,7 +566,7 @@ ZEND_FUNCTION(func_get_args)
} ZEND_HASH_FILL_END();
Z_ARRVAL_P(return_value)->nNumOfElements = arg_count;
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
}
/* }}} */

View File

@ -1060,7 +1060,7 @@ static PHP_FUNCTION(libxml_get_errors)
error = zend_llist_get_next(LIBXML(error_list));
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
}
/* }}} */

View File

@ -422,7 +422,7 @@ PHP_FUNCTION(mysqli_error_list)
add_next_index_zval(return_value, &single_error);
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
#else
if (mysql_errno(mysql->mysql)) {
@ -434,7 +434,7 @@ PHP_FUNCTION(mysqli_error_list)
add_assoc_string_ex(&single_error, "error", sizeof("error") - 1, mysql_error(mysql->mysql));
add_next_index_zval(return_value, &single_error);
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
#endif
}
@ -468,7 +468,7 @@ PHP_FUNCTION(mysqli_stmt_error_list)
add_next_index_zval(return_value, &single_error);
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
#else
if (mysql_stmt_errno(stmt->stmt)) {
@ -480,7 +480,7 @@ PHP_FUNCTION(mysqli_stmt_error_list)
add_assoc_string_ex(&single_error, "error", sizeof("error") - 1, mysql_stmt_error(stmt->stmt));
add_next_index_zval(return_value, &single_error);
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
#endif
}

View File

@ -1789,7 +1789,7 @@ ZEND_METHOD(reflection_function, getStaticVariables)
} ZEND_HASH_FOREACH_END();
zend_hash_copy(Z_ARRVAL_P(return_value), ht, zval_add_ref);
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
}
/* }}} */
@ -1977,8 +1977,7 @@ ZEND_METHOD(reflection_function, getParameters)
}
if (!num_args) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
array_init(return_value);
@ -4796,7 +4795,7 @@ ZEND_METHOD(reflection_class, getInterfaces)
zend_hash_update(Z_ARRVAL_P(return_value), ce->interfaces[i]->name, &interface);
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
}
/* }}} */
@ -4816,8 +4815,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames)
if (!ce->num_interfaces) {
/* Return an empty array if this class implements no interfaces */
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED);
@ -4843,8 +4841,7 @@ ZEND_METHOD(reflection_class, getTraits)
GET_REFLECTION_OBJECT_PTR(ce);
if (!ce->num_traits) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
array_init(return_value);
@ -4876,8 +4873,7 @@ ZEND_METHOD(reflection_class, getTraitNames)
GET_REFLECTION_OBJECT_PTR(ce);
if (!ce->num_traits) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
array_init(return_value);
@ -4918,7 +4914,7 @@ ZEND_METHOD(reflection_class, getTraitAliases)
i++;
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
}
/* }}} */
@ -5892,8 +5888,7 @@ ZEND_METHOD(reflection_extension, getDependencies)
if (!dep)
{
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
array_init(return_value);

View File

@ -1360,7 +1360,7 @@ SXE_METHOD(xpath)
}
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETVAL_EMPTY_ARRAY();
}
xmlXPathFreeObject(retval);

View File

@ -642,7 +642,7 @@ SPL_METHOD(SplFixedArray, toArray)
}
}
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETURN_EMPTY_ARRAY();
}
}
/* }}} */

View File

@ -679,7 +679,7 @@ PHP_METHOD(sqlite3, querySingle)
if (!entire_row) {
RETVAL_NULL();
} else {
ZVAL_EMPTY_ARRAY(return_value);
RETVAL_EMPTY_ARRAY();
}
break;
}

View File

@ -2665,8 +2665,7 @@ PHP_FUNCTION(array_fill)
}
}
} else if (EXPECTED(num == 0)) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
} else {
php_error_docref(NULL, E_WARNING, "Number of elements can't be negative");
RETURN_FALSE;
@ -3503,8 +3502,7 @@ PHP_FUNCTION(array_slice)
/* Clamp the offset.. */
if (offset > num_in) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
} else if (offset < 0 && (offset = (num_in + offset)) < 0) {
offset = 0;
}
@ -3517,8 +3515,7 @@ PHP_FUNCTION(array_slice)
}
if (length <= 0) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
/* Initialize returned array */
@ -4050,8 +4047,7 @@ PHP_FUNCTION(array_values)
/* Return empty input as is */
arrlen = zend_hash_num_elements(arrval);
if (!arrlen) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
/* Return vector-like packed arrays as-is */
@ -5456,8 +5452,7 @@ PHP_FUNCTION(array_diff)
RETURN_NULL();
}
}
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
} else if (num == 1) {
int found = 0;
zend_string *search_str, *tmp_search_str;
@ -5474,8 +5469,7 @@ PHP_FUNCTION(array_diff)
RETURN_NULL();
}
}
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
search_str = zval_get_tmp_string(value, &tmp_search_str);
@ -5501,7 +5495,7 @@ PHP_FUNCTION(array_diff)
zend_tmp_string_release(tmp_search_str);
if (found) {
ZVAL_EMPTY_ARRAY(return_value);
RETVAL_EMPTY_ARRAY();
} else {
ZVAL_COPY(return_value, &args[0]);
}
@ -6435,8 +6429,7 @@ PHP_FUNCTION(array_combine)
}
if (!num_keys) {
ZVAL_EMPTY_ARRAY(return_value);
return;
RETURN_EMPTY_ARRAY();
}
array_init_size(return_value, num_keys);