Doc #64909 [Com]: array_merge - Return value documentation incorrect/misleading
| From: | pete at petermcdonald dot co dot uk | Date: | Fri, 24 May 2013 17:57:08 +0000 |
| Subject: | Doc #64909 [Com]: array_merge - Return value documentation incorrect/misleading | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9879@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64909&edit=1
ID: 64909
Comment by: pete at petermcdonald dot co dot uk
Reported by: tim dot hentenaar at gmail dot com
Summary: array_merge - Return value documentation
incorrect/misleading
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: N/A
PHP Version: 5.4.15
Block user comment: N
Private report: N
New Comment:
There is quite a large warning on the documentation advising that php5 MUST have
arrays passed to it. It might be worth adding to the note advising of unexpected
behaviour if array's are not passed but you have not adhered to the signature of
the function therefore unexpected behaviour is for want of a better phrase,
expected.
Previous Comments:
------------------------------------------------------------------------
[2013-05-23 14:04:28] tim dot hentenaar at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-merge#refsect1-
function.array-merge-returnvalues
---
"Return Values: Returns the resulting array."
The documentation for the return values of array_merge() is not entirely
correct. In fact, array_merge() will return NULL if one of its arguments is not
an array, along with giving a warning.
Either the documentation is wrong, and returning NULL is intended here, in which
case the documentation needs to be updated; or array_merge() should be made to
return an array (empty, or perhaps the initial array) in this case, since the
documentation indicates that array_merge() returns an array.
Test script:
---------------
<?php
# This shows that $r is actually assigned NULL.
$r = array_merge(array('a' => 'b'),1);
var_dump($r);
?>
Expected result:
----------------
That the variable $r should be an array, with or without the warning.
Actual result:
--------------
Warning: array_merge(): Argument #2 is not an array in
/home/tim/php/array_merge_test.php on line 4
NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64909&edit=1