com php-src: Add RETURN_EMPTY_ARRAY() / RETVAL_EM PTY_ARRAY(): Zend/zend_API.h Zend/zend_builti n_functions.c ext/libxml/libxml.c ext/mysqli/mysqli
_nonapi.c ext/reflection/php_reflection.c ext/simpl exml/simplexml.c ext/spl/spl_fixedarray.c ext/sqlite 3/sqlite3.c ext/standard/array.c
| From: | Nikita Popov | Date: | Tue, 14 May 2019 12:59:10 +0000 |
| Subject: | com php-src: Add RETURN_EMPTY_ARRAY() / RETVAL_EM PTY_ARRAY(): Zend/zend_API.h Zend/zend_builti n_functions.c ext/libxml/libxml.c ext/mysqli/mysqli _nonapi.c ext/reflection/php_reflection.c ext/simpl exml/simplexml.c ext/spl/spl_fixedarray.c ext/sqlite 3/sqlite3.c ext/standard/array.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106188@lists.php.net to get a copy of this message | ||
Commit: 3f19f5112a7be3e4aa7ab1704d25de54645be373
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 14 May 2019 14:57:10 +0200
Parents: 7bc4bd0229d792718fd8d9aef1fed710d24607b5
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3f19f5112a7be3e4aa7ab1704d25de54645be373
Log:
Add RETURN_EMPTY_ARRAY() / RETVAL_EMPTY_ARRAY()
The usual wrappers around ZVAL_EMPTY_ARRAY()...
Changed paths:
M Zend/zend_API.h
M Zend/zend_builtin_functions.c
M ext/libxml/libxml.c
M ext/mysqli/mysqli_nonapi.c
M ext/reflection/php_reflection.c
M ext/simplexml/simplexml.c
M ext/spl/spl_fixedarray.c
M ext/sqlite3/sqlite3.c
M ext/standard/array..c
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 648dbe7..577feb0 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -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; } diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index cfc78db..b8b8257 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -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(); } } /* }}} */ diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index b8603fd..7471065 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -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(); } } /* }}} */ diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 78302a7..3ffa8d0 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -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 } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index f1037ef..86f66a4 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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); diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index e8ba1f5..7f94091 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1360,7 +1360,7 @@ SXE_METHOD(xpath) } } } else { - ZVAL_EMPTY_ARRAY(return_value); + RETVAL_EMPTY_ARRAY(); } xmlXPathFreeObject(retval); diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index ce93f2a..071826d 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -642,7 +642,7 @@ SPL_METHOD(SplFixedArray, toArray) } } } else { - ZVAL_EMPTY_ARRAY(return_value); + RETURN_EMPTY_ARRAY(); } } /* }}} */ diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 4f7d496..4d97279 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -679,7 +679,7 @@ PHP_METHOD(sqlite3, querySingle) if (!entire_row) { RETVAL_NULL(); } else { - ZVAL_EMPTY_ARRAY(return_value); + RETVAL_EMPTY_ARRAY(); } break; } diff --git a/ext/standard/array.c b/ext/standard/array.c index 7d41b99..34f1284 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -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);
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 648dbe7..577feb0 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -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; } diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index cfc78db..b8b8257 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -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(); } } /* }}} */ diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index b8603fd..7471065 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -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(); } } /* }}} */ diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 78302a7..3ffa8d0 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -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 } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index f1037ef..86f66a4 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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); diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index e8ba1f5..7f94091 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1360,7 +1360,7 @@ SXE_METHOD(xpath) } } } else { - ZVAL_EMPTY_ARRAY(return_value); + RETVAL_EMPTY_ARRAY(); } xmlXPathFreeObject(retval); diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index ce93f2a..071826d 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -642,7 +642,7 @@ SPL_METHOD(SplFixedArray, toArray) } } } else { - ZVAL_EMPTY_ARRAY(return_value); + RETURN_EMPTY_ARRAY(); } } /* }}} */ diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 4f7d496..4d97279 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -679,7 +679,7 @@ PHP_METHOD(sqlite3, querySingle) if (!entire_row) { RETVAL_NULL(); } else { - ZVAL_EMPTY_ARRAY(return_value); + RETVAL_EMPTY_ARRAY(); } break; } diff --git a/ext/standard/array.c b/ext/standard/array.c index 7d41b99..34f1284 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -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);