PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » PHP » PHP_Compat » Bug #9983

Function [array_udiff_uassoc()] is incorrectly implemented

Details

Submitted2007-01-30 23:01 UTC
Fromteague dot costas at amd dot com
Assignedarpad
StatusClosed
PackagePHP_Compat
PHP Version4.3.9
OSLinux
Roadmaps1.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