public static function reverseToArray($params)
    {
        $url = [];
        if ($params instanceof ServerRequest) {
            $url = $params->getQueryParams();
            $params = $params->getAttribute('params');
        } elseif (isset($params['url'])) {
            $url = $params['url'];
        }
        $pass = isset($params['pass']) ? $params['pass'] : [];

        unset(
            $params['pass'],
            $params['paging'],
            $params['models'],
            $params['url'],
            $url['url'],
            $params['autoRender'],
            $params['bare'],
            $params['requested'],
            $params['return'],
            $params['_Token'],
            $params['_matchedRoute'],
            $params['_name']
        );
        $params = array_merge($params, $pass);
        if (!empty($url)) {
            $params['?'] = $url;
        }

        return $params;
    }