Doc #64909 [NEW]: array_merge - Return value documentation incorrect/misleading

From: Date: Thu, 23 May 2013 14:04:28 +0000
Subject: Doc #64909 [NEW]: array_merge - Return value documentation incorrect/misleading
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9874@lists.php.net to get a copy of this message
From: tim dot hentenaar at gmail dot com Operating system: N/A PHP version: 5.4.15 Package: Documentation problem Bug Type: Documentation Problem Bug description:array_merge - Return value documentation incorrect/misleading 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 bug report at https://bugs.php.net/bug.php?id=64909&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64909&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64909&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64909&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64909&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64909&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64909&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64909&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64909&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64909&r=support Expected behavior: https://bugs.php.net/fix.php?id=64909&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64909&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64909&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64909&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64909&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64909&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64909&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64909&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64909&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64909&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64909&r=mysqlcfg

« previous php.doc.bugs (#9874) next »