mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Eliminate uses of ZVAL_ZVAL and friends
Instead add RETURN_COPY(_VALUE) macros will the expected behavior. RETURN_ZVAL doesn't make any sense since PHP 7, but has stuck around, probably because the alternative was to write directly to the return_value variable.
This commit is contained in:
parent
5947437d47
commit
6811222422
10 changed files with 20 additions and 29 deletions
|
@ -652,6 +652,8 @@ END_EXTERN_C()
|
|||
#define RETVAL_ARR(r) ZVAL_ARR(return_value, r)
|
||||
#define RETVAL_EMPTY_ARRAY() ZVAL_EMPTY_ARRAY(return_value)
|
||||
#define RETVAL_OBJ(r) ZVAL_OBJ(return_value, r)
|
||||
#define RETVAL_COPY(zv) ZVAL_COPY(return_value, zv)
|
||||
#define RETVAL_COPY_VALUE(zv) ZVAL_COPY_VALUE(return_value, zv)
|
||||
#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor)
|
||||
#define RETVAL_FALSE ZVAL_FALSE(return_value)
|
||||
#define RETVAL_TRUE ZVAL_TRUE(return_value)
|
||||
|
@ -671,6 +673,8 @@ END_EXTERN_C()
|
|||
#define RETURN_ARR(r) do { RETVAL_ARR(r); return; } while (0)
|
||||
#define RETURN_EMPTY_ARRAY() do { RETVAL_EMPTY_ARRAY(); return; } while (0)
|
||||
#define RETURN_OBJ(r) do { RETVAL_OBJ(r); return; } while (0)
|
||||
#define RETURN_COPY(zv) do { RETVAL_COPY(zv); return; } while (0)
|
||||
#define RETURN_COPY_VALUE(zv) do { RETVAL_COPY_VALUE(zv); return; } while (0)
|
||||
#define RETURN_ZVAL(zv, copy, dtor) do { RETVAL_ZVAL(zv, copy, dtor); return; } while (0)
|
||||
#define RETURN_FALSE do { RETVAL_FALSE; return; } while (0)
|
||||
#define RETURN_TRUE do { RETVAL_TRUE; return; } while (0)
|
||||
|
|
|
@ -338,7 +338,7 @@ ZEND_METHOD(Closure, fromCallable)
|
|||
|
||||
if (Z_TYPE_P(callable) == IS_OBJECT && instanceof_function(Z_OBJCE_P(callable), zend_ce_closure)) {
|
||||
/* It's already a closure */
|
||||
RETURN_ZVAL(callable, 1, 0);
|
||||
RETURN_COPY(callable);
|
||||
}
|
||||
|
||||
/* create closure as if it were called from parent scope */
|
||||
|
|
|
@ -193,7 +193,7 @@ ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *ke
|
|||
zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_key, "key", &retval);
|
||||
|
||||
if (Z_TYPE(retval) != IS_UNDEF) {
|
||||
ZVAL_ZVAL(key, &retval, 1, 1);
|
||||
ZVAL_COPY_VALUE(key, &retval);
|
||||
} else {
|
||||
if (!EG(exception)) {
|
||||
zend_error(E_WARNING, "Nothing returned from %s::key()", ZSTR_VAL(iter->ce->name));
|
||||
|
|
|
@ -2382,11 +2382,9 @@ PHP_FUNCTION(oci_collection_element_get)
|
|||
|
||||
PHP_OCI_ZVAL_TO_COLLECTION(tmp, collection);
|
||||
|
||||
if (php_oci_collection_element_get(collection, element_index, &value)) {
|
||||
if (php_oci_collection_element_get(collection, element_index, return_value)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_ZVAL(&value, 1, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -1028,7 +1028,7 @@ PHP_FUNCTION(pcntl_signal_get_handler)
|
|||
}
|
||||
|
||||
if ((prev_handle = zend_hash_index_find(&PCNTL_G(php_signal_table), signo)) != NULL) {
|
||||
RETURN_ZVAL(prev_handle, 1, 0);
|
||||
RETURN_COPY(prev_handle);
|
||||
} else {
|
||||
RETURN_LONG((zend_long)SIG_DFL);
|
||||
}
|
||||
|
|
|
@ -2337,14 +2337,14 @@ PHP_FUNCTION(pg_last_notice)
|
|||
if ((notice = zend_hash_get_current_data(Z_ARRVAL_P(notices))) == NULL) {
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
RETURN_ZVAL(notice, 1, 0);
|
||||
RETURN_COPY(notice);
|
||||
} else {
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
break;
|
||||
case PGSQL_NOTICE_ALL:
|
||||
if (notices) {
|
||||
RETURN_ZVAL(notices, 1, 0);
|
||||
RETURN_COPY(notices);
|
||||
} else {
|
||||
array_init(return_value);
|
||||
return;
|
||||
|
|
|
@ -2278,7 +2278,7 @@ PHP_FUNCTION(socket_export_stream)
|
|||
/* Either we already exported a stream or the socket came from an import,
|
||||
* just return the existing stream */
|
||||
if (!Z_ISUNDEF(socket->zstream)) {
|
||||
RETURN_ZVAL(&socket->zstream, 1, 0);
|
||||
RETURN_COPY(&socket->zstream);
|
||||
}
|
||||
|
||||
/* Determine if socket is using a protocol with one of the default registered
|
||||
|
@ -2350,7 +2350,7 @@ PHP_FUNCTION(socket_export_stream)
|
|||
|
||||
php_stream_to_zval(stream, &socket->zstream);
|
||||
|
||||
RETURN_ZVAL(&socket->zstream, 1, 0);
|
||||
RETURN_COPY(&socket->zstream);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -2053,7 +2053,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
|
|||
{
|
||||
zend_fcall_info fci;
|
||||
zend_fcall_info_cache fcic;
|
||||
zval *zresource_ptr = &intern->u.file.zresource, retval;
|
||||
zval *zresource_ptr = &intern->u.file.zresource;
|
||||
int result;
|
||||
int num_args = pass_num_args + (arg2 ? 2 : 1);
|
||||
|
||||
|
@ -2070,11 +2070,9 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
|
|||
WRONG_PARAM_COUNT_WITH_RETVAL(FAILURE);
|
||||
}
|
||||
|
||||
ZVAL_UNDEF(&retval);
|
||||
|
||||
fci.size = sizeof(fci);
|
||||
fci.object = NULL;
|
||||
fci.retval = &retval;
|
||||
fci.retval = return_value;
|
||||
fci.param_count = num_args;
|
||||
fci.params = params;
|
||||
fci.no_separation = 1;
|
||||
|
@ -2086,10 +2084,8 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
|
|||
|
||||
result = zend_call_function(&fci, &fcic);
|
||||
|
||||
if (result == FAILURE || Z_ISUNDEF(retval)) {
|
||||
if (result == FAILURE || Z_ISUNDEF_P(return_value)) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
ZVAL_ZVAL(return_value, &retval, 0, 0);
|
||||
}
|
||||
|
||||
efree(params);
|
||||
|
|
|
@ -1271,8 +1271,7 @@ SPL_METHOD(RecursiveTreeIterator, key)
|
|||
}
|
||||
|
||||
if (object->flags & RTIT_BYPASS_KEY) {
|
||||
RETVAL_ZVAL(&key, 1, 1);
|
||||
return;
|
||||
RETURN_COPY_VALUE(&key);
|
||||
}
|
||||
|
||||
if (Z_TYPE(key) != IS_STRING) {
|
||||
|
@ -1842,7 +1841,6 @@ SPL_METHOD(RecursiveFilterIterator, __construct)
|
|||
SPL_METHOD(RecursiveFilterIterator, hasChildren)
|
||||
{
|
||||
spl_dual_it_object *intern;
|
||||
zval retval;
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
|
@ -1850,12 +1848,7 @@ SPL_METHOD(RecursiveFilterIterator, hasChildren)
|
|||
|
||||
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
|
||||
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "haschildren", &retval);
|
||||
if (Z_TYPE(retval) != IS_UNDEF) {
|
||||
RETURN_ZVAL(&retval, 0, 1);
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "haschildren", return_value);
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ proto RecursiveFilterIterator RecursiveFilterIterator::getChildren()
|
||||
|
|
|
@ -3970,7 +3970,7 @@ PHP_FUNCTION(array_keys)
|
|||
|
||||
/* Base case: empty input */
|
||||
if (!elem_count) {
|
||||
RETURN_ZVAL(input, 1, 0);
|
||||
RETURN_COPY(input);
|
||||
}
|
||||
|
||||
/* Initialize return array */
|
||||
|
@ -4086,7 +4086,7 @@ PHP_FUNCTION(array_values)
|
|||
/* Return vector-like packed arrays as-is */
|
||||
if (HT_IS_PACKED(arrval) && HT_IS_WITHOUT_HOLES(arrval) &&
|
||||
arrval->nNextFreeElement == arrlen) {
|
||||
RETURN_ZVAL(input, 1, 0);
|
||||
RETURN_COPY(input);
|
||||
}
|
||||
|
||||
/* Initialize return array */
|
||||
|
@ -6064,7 +6064,7 @@ PHP_FUNCTION(array_reduce)
|
|||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
zend_release_fcall_info_cache(&fci_cache);
|
||||
RETVAL_ZVAL(&result, 1, 1);
|
||||
RETURN_COPY_VALUE(&result);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue