Bug #17654 Updated: array_merge() throws warning when supplied with 1 argument only
| From: | derick@php.net | Date: | Sat, 29 Jun 2002 15:37:32 +0000 |
| Subject: | Bug #17654 Updated: array_merge() throws warning when supplied with 1 argument only | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12526@lists.php.net to get a copy of this message | ||
ID: 17654
Updated by: derick@php.net
Reported By: carlos@wfmh.org.pl
-Status: Open
+Status: Closed
Bug Type: Arrays related
Operating System: Linux GNU/Debian
PHP Version: 4.2.1
New Comment:
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2002-06-08 09:19:04] carlos@wfmh.org.pl
A few pro's for changing this permanently:
1. Is syntax $a = $a throwing any warning? Again, you may say it makes
no sense, but technically it's valid and it work, because there's no
real reason it should either throw any warning or refuse to work.
2. There's nothing that makes a array_merge($arr) call invalid, as
produced result is 100% valid as in $a=$a.
3. It does not influence PHP syntax nor causes bad programming
habbits.
4. Finally, 'fixing' this does not broke backward compatibility,
neither is a security issue ;)
I'd bet we could raise the contest and people could give enough dirty
examples of helpful use of potentially nonsense syntax during the
development process.
PS: The same applies to array_merge_recursive() I presume.
------------------------------------------------------------------------
[2002-06-08 08:34:44] sander@php.net
Don't know if we want to change this. I don't quite see the use of it.
Anyway, if you want to change it yourself look at line 1934 of
/ext/standard/array.c and change the 2 to 1 (in the function
php_array_merge_wrapper).
------------------------------------------------------------------------
[2002-06-08 08:16:39] carlos@wfmh.org.pl
array_merge() throws an "Wrong parameter count" if called with only 1
argument given. I consider it a bug, as there's no technical reason it
should act that way. One can say merging one array makes no sense,
which is correct from logical point of view, but from the ther side,
technical, there's nothing that I can imagine to prevent array_merge()
to handle this case w/o any error. Currently if I write a code that
utilises array_merge() and I plan it to scale later on, I can 't simply
write
$res = array_merge( $arr1 );
and expand the lists later on, if I get more arrays.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17654&edit=1