我在我的应用程序中收到一个奇怪的警告通知。我在usort
类中使用自定义函数。这是它的外观:
class Class_Name
{
function zstream_builder()
{
$array = some_array();
//sort posts by date DESC
usort($array, array('Class_Name', 'zstream_sorter')); // <- the notice is thrown on this line
return $array;
}
private static function zstream_sorter($key = 'sort_str_date')
{
return function ($a, $b) use ($key)
{
return strnatcmp($a[$key], $b[$key]);
};
}
}
这是我收到的通知:
Notice: Object of class Closure could not be converted to int in PATH_TO_FILE on line xx
有任何想法吗?