Home » PHP » PHP_Compat » Bug #9983
Function [array_udiff_uassoc()] is incorrectly implemented
Details
| Submitted | 2007-01-30 23:01 UTC |
|---|---|
| From | teague dot costas at amd dot com |
| Assigned | arpad |
| Status | Closed |
| Package | PHP_Compat |
| PHP Version | 4.3.9 |
| OS | Linux |
| Roadmaps | 1.6.0a1 |
Comments
[2007-01-30 23:01 UTC] teague dot costas at amd dot com
Description:
------------
The function [ array_udiff_uassoc() ] is incorrectly implemented. That is, it's the wrong function. The code is identical to the code for [ array_udiff_assoc() ] (note the missing "u"), which is a different function.
The PHP documentation will reveal the major difference--namely, that the [ uassoc ] version takes *two* callbacks: one for keys, one for values. PHP_Compat's version, however, takes only one--which is incorrect.
The given code (it's only one line) will cause the function to generate an "Argument #3 is not an array" error. (If the function [ compareArrayKeys() ] doesn't exist
Test script:
---------------
function compareArrayKeys($a, $b) {
return 0;
}
function compareArrayValues($a, $b) {
return 0;
}
array_udiff_uassoc(array(), array(), 'compareArrayValues', 'compareArrayKeys');
Expected result:
----------------
I expected to not get any warnings, and I expected the function to implement PHP5's [ array_udiff_uassoc() ].
Actual result:
--------------
Warning: array_udiff_uassoc() Argument #3 is not an array in /<...>/include/php/pear/PHP/Compat/Function/array_udiff_uassoc.php on line 56