public static function createComparer($closure, $sortOrder, &$isReversed)
    {
        if ($closure === null) {
            $isReversed = false;
            return $sortOrder === SORT_DESC ? Functions::$compareStrictReversed : Functions::$compareStrict;
        }
        elseif (is_int($closure)) {
            switch ($closure) {
                case SORT_REGULAR:
                    return Functions::$compareStrict;
                case SORT_NUMERIC:
                    $isReversed = false;
                    return $sortOrder === SORT_DESC ? Functions::$compareIntReversed : Functions::$compareInt;
                case SORT_STRING:
                    return 'strcmp';
                case SORT_STRING | SORT_FLAG_CASE:
                    return 'strcasecmp';
                case SORT_LOCALE_STRING:
                    return 'strcoll';
                case SORT_NATURAL:
                    return 'strnatcmp';
                case SORT_NATURAL | SORT_FLAG_CASE:
                    return 'strnatcasecmp';
                default:
                    throw new \InvalidArgumentException("Unexpected sort flag: {$closure}.");
            }
        }
        return self::createLambda($closure, 'a,b');
    }
public static function createComparer($closure, $sortOrder, &$isReversed)
    {
        if ($closure === null) {
            $isReversed = false;
            return $sortOrder === SORT_DESC ? Functions::$compareStrictReversed : Functions::$compareStrict;
        }
        elseif (is_int($closure)) {
            switch ($closure) {
                case SORT_REGULAR:
                    return Functions::$compareStrict;
                case SORT_NUMERIC:
                    $isReversed = false;
                    return $sortOrder === SORT_DESC ? Functions::$compareIntReversed : Functions::$compareInt;
                case SORT_STRING:
                    return 'strcmp';
                case SORT_STRING | SORT_FLAG_CASE:
                    return 'strcasecmp';
                case SORT_LOCALE_STRING:
                    return 'strcoll';
                case SORT_NATURAL:
                    return 'strnatcmp';
                case SORT_NATURAL | SORT_FLAG_CASE:
                    return 'strnatcasecmp';
                default:
                    throw new \InvalidArgumentException("Unexpected sort flag: {$closure}.");
            }
        }
        return self::createLambda($closure, 'a,b');
    }
public static function createComparer ( $ closure , $ sortOrder , & $ isReversed ) { if ( $ closure === null ) { $ isReversed = false ; return $ sortOrder === SORT_DESC ? Functions :: $ compareStrictReversed : Functions :: $ compareStrict ; } elseif ( is_int ( $ closure ) ) { switch ( $ closure ) { case SORT_REGULAR : return Functions :: $ compareStrict ; case SORT_NUMERIC : $ isReversed = false ; return $ sortOrder === SORT_DESC ? Functions :: $ compareIntReversed : Functions :: $ compareInt ; case SORT_STRING : return 'strcmp' ; case SORT_STRING | SORT_FLAG_CASE : return 'strcasecmp' ; case SORT_LOCALE_STRING : return 'strcoll' ; case SORT_NATURAL : return 'strnatcmp' ; case SORT_NATURAL | SORT_FLAG_CASE : return 'strnatcasecmp' ; default : throw new \ InvalidArgumentException ( "Unexpected sort flag: {$closure}." ) ; } } return self :: createLambda ( $ closure , 'a,b' ) ; }
Convert string lambda or SORT_ flags to callable function. Sets isReversed to false if descending is reversed.
@param callable|int|null $closure
@param int $sortOrder
@param bool $isReversed
@return callable|string|null
@throws \InvalidArgumentException Incorrect lambda syntax.
@throws \InvalidArgumentException Incorrect SORT_ flags.
Convert string lambda or SORT_ flags to callable function . Sets isReversed to false if descending is reversed .