Bug #17654 Updated: array_merge() throws warning when supplied with 1 argument only
| From: | carlos at wfmh dot org dot pl | Date: | Sat, 08 Jun 2002 13:19:05 +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-9844@lists.php.net to get a copy of this message | ||
ID: 17654
Updated by: carlos@wfmh.org.pl
Reported By: carlos@wfmh.org.pl
Status: Open
Bug Type: Arrays related
Operating System: Linux GNU/Debian
PHP Version: 4.2.1
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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