1--TEST-- 2Test usort() function : usage variations - malformed comparison function returning boolean 3--FILE-- 4<?php 5 6function ucmp($a, $b) { 7 return $a > $b; 8} 9 10$range = array(2, 4, 8, 16, 32, 64, 128); 11 12foreach ($range as $r) { 13 $backup = $array = range(0, $r); 14 shuffle($array); 15 usort($array, "ucmp"); 16 if ($array != $backup) { 17 var_dump($array); 18 var_dump($backup); 19 die("Array not sorted (usort)"); 20 } 21 22 shuffle($array); 23 $array = array_flip($array); 24 uksort($array, "ucmp"); 25 $array = array_keys($array); 26 if ($array != $backup) { 27 var_dump($array); 28 var_dump($backup); 29 die("Array not sorted (uksort)"); 30 } 31 32 shuffle($array); 33 $array = array_combine($array, $array); 34 uasort($array, "ucmp"); 35 $array = array_keys($array); 36 if ($array != $backup) { 37 var_dump($array); 38 var_dump($backup); 39 die("Array not sorted (uasort)"); 40 } 41} 42echo "okey"; 43 44?> 45--EXPECTF-- 46Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 47 48Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 49 50Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 51 52Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 53 54Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 55 56Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 57 58Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 59 60Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 61 62Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 63 64Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 65 66Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 67 68Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 69 70Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 71 72Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 73 74Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 75 76Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 77 78Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 79 80Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 81 82Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 83 84Deprecated: uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 85 86Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in %s on line %d 87okey 88