I am trying to mimic php's inbuilt usort function definition in my implementation below:
class heapSort {
static function hsort(array &$array, callable $cmp_function){
// logic
}
}
class utility{
static function mycomparator(){
// logic
}
}
$array = array(5,3,8,1);
$callback = array('utility','mycomparator');
heapSort::hsort($array, $callback);
While the variable $callback
is "callable" why do I get below fatal error?
Argument 2 passed to heapSort::hsort() must be an instance of callable.
More specifically, how do I make/typecast a $variable
to callable?