]> granicus.if.org Git - php/commitdiff
Implemented request #34857 (Change array_combine behaviour when called with
authorAdam Harvey <aharvey@php.net>
Fri, 27 Aug 2010 03:54:10 +0000 (03:54 +0000)
committerAdam Harvey <aharvey@php.net>
Fri, 27 Aug 2010 03:54:10 +0000 (03:54 +0000)
empty arrays). Patch by Joel Perras <joel.perras@gmail.com>.

NEWS
UPGRADING
ext/standard/array.c
ext/standard/tests/array/array_combine_error2.phpt
ext/standard/tests/array/array_combine_variation3.phpt
ext/standard/tests/array/array_combine_variation4.phpt
ext/standard/tests/array/array_combine_variation5.phpt

diff --git a/NEWS b/NEWS
index 5bae8b202e903960034b1c02ededf4f8f25e0c8e..6e52ca2477c00dabac375ae93f785067c2c344f6 100644 (file)
--- a/NEWS
+++ b/NEWS
    at gmail dot com, Pierre)
 - Implemented FR #42060 (Add paged Results support). (ando@OpenLDAP.org,
   iarenuno@eteo.mondragon.edu, jeanseb@au-fil-du.net, remy.saissy@gmail.com)
+- Implemented FR #34857 (Change array_combine behaviour when called with empty
+  arrays). (joel.perras@gmail.com)
 
 - Fixed PDO objects binary incompatibility. (Dmitry)
 
index e0a8bca7fe84ab6d7dbe21ab4c70c1a762e7a99b..a0d86d0b3cc1eaf291278cae36022abd32a1ae7e 100755 (executable)
--- a/UPGRADING
+++ b/UPGRADING
@@ -90,7 +90,8 @@ UPGRADE NOTES - PHP X.Y
 3. Changes made to existing functions
 =====================================
 
-- 
+- array_combine now returns array() instead of FALSE when two empty arrays are
+  provided as parameters.
 
 ===================================
 4. Changes made to existing methods
index 99b9e78c31b5a48c9eee3850a79c48c5016c41af..ee3c5ae75aa454d438350dda526d374f2da93eb0 100644 (file)
@@ -4481,13 +4481,12 @@ PHP_FUNCTION(array_combine)
                RETURN_FALSE;
        }
 
+       array_init_size(return_value, num_keys);
+
        if (!num_keys) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Both parameters should have at least 1 element");
-               RETURN_FALSE;
+               return;
        }
 
-       array_init_size(return_value, num_keys);
-
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(keys), &pos_keys);
        zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
        while (zend_hash_get_current_data_ex(Z_ARRVAL_P(keys), (void **)&entry_keys, &pos_keys) == SUCCESS &&
index c06fdb490a6e6ab9d2b1e8ccfee242aacc831dea..4224f1c8eb33a2b5207352f9ce340a2c7a83d729 100644 (file)
@@ -32,9 +32,8 @@ echo "Done";
 *** Testing array_combine() : error conditions specific to array_combine() ***
 
 -- Testing array_combine() function with empty arrays --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
 
 -- Testing array_combine() function with empty array for $keys argument --
 
index 51d8462d512a16266e73763469a72a50c6e760a2..03de632905cffacfa83932fe197ff4d2b19caf0b 100644 (file)
@@ -108,9 +108,8 @@ array(2) {
   bool(true)
 }
 -- Iteration 4 --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
 -- Iteration 5 --
 array(1) {
   [""]=>
index 02ec6efd22a1ec8783f01be140d5b6e42e468b38..bcd8428ceee191fa00f27480ff73e6a0bad0e743 100644 (file)
@@ -100,9 +100,8 @@ Warning: Illegal offset type in %s on line %d
 
 Warning: Illegal offset type in %s on line %d
 -- Iteration 1 --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
 -- Iteration 2 --
 array(1) {
   [0]=>
index c3d1d57aac5403fe3eaa7fc7a7b42a4f5d6f3278..4d9f18578629bc82e203b29a3fd08dbdf68dd59e 100644 (file)
@@ -82,9 +82,8 @@ echo "Done";
 --EXPECTF--
 *** Testing array_combine() : assoc array with diff values to both $keys and $values argument ***
 -- Iteration 1 --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
 -- Iteration 2 --
 array(1) {
   [0]=>