#25494 [Csd-Opn]: array_merge allowing false as argument (silent when non-array is passed)

2003-09-19 Thread et
 ID:   25494
 Updated by:   [EMAIL PROTECTED]
 Reported By:  enygma at phpdeveloper dot org
-Status:   Closed
+Status:   Open
 Bug Type: Arrays related
 Operating System: Any
 PHP Version:  4.3.2
 New Comment:

This behaviour IS documented for array_splice.
This behaviour IS documented in the type juggling chapter of the PHP
manual.
Additionally, it's the standard way for PHP to handle arguments of the
`wrong' type: It casts.
You don't consider it a bug that floor(3.2) returns float(3), do
you?
But you consider it a bug that array_merge() casts to array if it
doesn't get one?
Major inconsistency there.


Previous Comments:


[2003-09-18 15:06:06] [EMAIL PROTECTED]

It can't break BC if the behaviour was undocumented and 
hence undefined. So either document the behaviour or fix 
the bug. 
 
Anybody relying on undocumented 'features' should know 
they're at risk for having those behaviours changed.  
 
J 



[2003-09-18 06:45:48] [EMAIL PROTECTED]

It's still inconsistent, and `will throw a warning and fail in 5 for
non-array arguments' will break BC without a need for it.



[2003-09-18 06:08:03] [EMAIL PROTECTED]

Throwing an E_NOTICE error is not breaking anything.




[2003-09-18 05:56:38] [EMAIL PROTECTED]

This `fix' is inconsistent with array_splice, which allows you to add
non-array arguments. (This is also documented.)
Also, this `fix' breaks BC. Is this really needed?
I'd rather have those functions convert non-array arguments into arrays
and then perform their operations like array_splice() does.
This has to be documented of course.



[2003-09-11 13:57:55] [EMAIL PROTECTED]

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot 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 in short time.
 
Thank you for the report, and for helping us make PHP better.

array_merge() throws E_NOTICEs now in 4.3.x and will throw 
a warning and fail in 5 for non-array arguments.  
 
J 



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/25494

-- 
Edit this bug report at http://bugs.php.net/?id=25494edit=1


#25494 [Csd-Opn]: array_merge allowing false as argument (silent when non-array is passed)

2003-09-18 Thread et
 ID:   25494
 Updated by:   [EMAIL PROTECTED]
 Reported By:  enygma at phpdeveloper dot org
-Status:   Closed
+Status:   Open
 Bug Type: Arrays related
-Operating System: Red Hat Linux
+Operating System: Any
 PHP Version:  4.3.2
 New Comment:

This `fix' is inconsistent with array_splice, which allows you to add
non-array arguments. (This is also documented.)
Also, this `fix' breaks BC. Is this really needed?
I'd rather have those functions convert non-array arguments into arrays
and then perform their operations like array_splice() does.
This has to be documented of course.


Previous Comments:


[2003-09-11 13:57:55] [EMAIL PROTECTED]

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot 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 in short time.
 
Thank you for the report, and for helping us make PHP better.

array_merge() throws E_NOTICEs now in 4.3.x and will throw 
a warning and fail in 5 for non-array arguments.  
 
J 



[2003-09-11 12:11:09] [EMAIL PROTECTED]

Jay, it's an undocumented feature. If it is not documented and obscure
it's developer's risk to use it. So, I think this is a bug and a check
for the input parameter should be performed. A warning throwed in the
same way as array_intersect() does will be the consistent way.
Opening again :)



[2003-09-11 11:50:39] enygma at phpdeveloper dot org

it still seems silly to me that a string passed into an array function
was taken without so much as a warning. even more strange that it was
suddenly treated as an array and merged into the other valid array.

maybe a warning would be enough to deter this in the future?



[2003-09-11 11:42:26] [EMAIL PROTECTED]

If you use var_dump() in place of print_r(), you'd see 
that it's not a mysterious value, it's 'false'. The 
boolean value is being converted to an array index in 
array_merge(). (Any value would produce similar results -- 
$array1=4; would produce an array value of 
$last_array[0]==4.) 
 
array_intersect() does a type check before it does 
anything, which is why the warning comes up. 
 
While it seems inconsistent, I can't see this being 
changed because it would affect BC (albeit BC on a 
somewhat obscure, undocumented feature). Somebody correct 
me here if I'm wrong. So I'm bogusing it for now. 
 
J 



[2003-09-11 11:42:19] [EMAIL PROTECTED]

1. Please use var_dump() instead of print_r()
2. The value in the merged array is (bool) false



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/25494

-- 
Edit this bug report at http://bugs.php.net/?id=25494edit=1


#25494 [Csd-Opn]: array_merge allowing false as argument (silent when non-array is passed)

2003-09-18 Thread et
 ID:   25494
 Updated by:   [EMAIL PROTECTED]
 Reported By:  enygma at phpdeveloper dot org
-Status:   Closed
+Status:   Open
 Bug Type: Arrays related
 Operating System: Any
 PHP Version:  4.3.2
 New Comment:

It's still inconsistent, and `will throw a warning and fail in 5 for
non-array arguments' will break BC without a need for it.


Previous Comments:


[2003-09-18 06:08:03] [EMAIL PROTECTED]

Throwing an E_NOTICE error is not breaking anything.




[2003-09-18 05:56:38] [EMAIL PROTECTED]

This `fix' is inconsistent with array_splice, which allows you to add
non-array arguments. (This is also documented.)
Also, this `fix' breaks BC. Is this really needed?
I'd rather have those functions convert non-array arguments into arrays
and then perform their operations like array_splice() does.
This has to be documented of course.



[2003-09-11 13:57:55] [EMAIL PROTECTED]

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot 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 in short time.
 
Thank you for the report, and for helping us make PHP better.

array_merge() throws E_NOTICEs now in 4.3.x and will throw 
a warning and fail in 5 for non-array arguments.  
 
J 



[2003-09-11 12:11:09] [EMAIL PROTECTED]

Jay, it's an undocumented feature. If it is not documented and obscure
it's developer's risk to use it. So, I think this is a bug and a check
for the input parameter should be performed. A warning throwed in the
same way as array_intersect() does will be the consistent way.
Opening again :)



[2003-09-11 11:50:39] enygma at phpdeveloper dot org

it still seems silly to me that a string passed into an array function
was taken without so much as a warning. even more strange that it was
suddenly treated as an array and merged into the other valid array.

maybe a warning would be enough to deter this in the future?



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/25494

-- 
Edit this bug report at http://bugs.php.net/?id=25494edit=1