Encode array values as html special chars.

@param array  $params    Parameter to encode
@param string $removeKey If not empty the key is removed from result

@return array
352600
private static function htmlencodeParams(array $params, $removeKey = '')
    {
        if ($removeKey) {
            unset($params[$removeKey]);
        }

        return array_map(
            function ($val) {
                return htmlspecialchars($val, ENT_QUOTES);
            },
            $params
        );
    }
41245
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
        StringBuilder encodedParams = new StringBuilder();
        try {
            for (Map.Entry<String, String> entry : params.entrySet()) {
                encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding));
                encodedParams.append('=');
                encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding));
                encodedParams.append('&');
            }
            return encodedParams.toString().getBytes(paramsEncoding);
        } catch (UnsupportedEncodingException uee) {
            throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee);
        }
    }
497769
private static function parseInputToString($params)
    {
        return is_array($params) ? array_map(function ($item) {
            return trim(htmlspecialchars($item, ENT_QUOTES, 'UTF-8'));
        }, $params) : trim(htmlspecialchars($params, ENT_QUOTES, 'UTF-8'));
    }
1152420
public function writeTo(string $key, $data, array $params = []): bool
    {
        $result = false;

        if ($this->skipCache()) {
            $this->warnings[] = 'Skipping writing to cache';

            return $result;
        }

        $cachedData['data'] = $data;
        $raw = empty($params['raw']) ? false : (bool)$params['raw'];
        if ($raw) {
            if (!array_key_exists('data', $data)) {
                $this->errors[] = "Raw data is missing 'data' key";

                return $result;
            }
            $cachedData = $data;
        }

        $result = CakeCache::write($key, $cachedData, $this->getConfig());
        if (!$result) {
            $this->errors[] = 'Failed to write value to cache';
        }

        return $result;
    }
1260680
public function removeParams(array $removeParams)
    {
        $parts = $this->split($this->url);

        parse_str($parts['query'], $params);
        $params = array_diff_key($params, array_flip($removeParams));
        $parts['query'] = http_build_query($params);

        return $this->join($parts);
    }
1197314
public static function getAndRemove(
        array &$params,
        string $key,
        $default = null
    ) {
        $value = self::get(
            $params,
            $key,
            $default
        );

        self::remove(
            $params,
            $key
        );

        return $value;
    }
550687
public static function decodeParams($params)
    {
        if(!$params) {
            return [];
        }
        $paramsArrayList = json_decode(json_encode($params), true);
        $decodedParams = [];
        foreach($paramsArrayList as $paramKey=>$paramValue){
            if(is_array($paramValue)) {
                foreach($paramValue as $languageSlug=>$langParamValue){
                    if($languageSlug == App::getLocale()) {
                        $decodedParams[$paramKey] = $langParamValue;
                        break;
                    }else{
                        $decodedParams[$paramKey] = "";
                    }
                }
            }else{
                $decodedParams[$paramKey] = $paramValue;
            }
        }
        return $decodedParams;
    }
392769
public function encodeMethod($method, $params)
	{
		$string = $this->encoder->encodeMethod($method, $params);

		return $this->encrypt($string);
	}
1179502
protected function _escapeParams($params)
    {
        foreach ($params as $k => $v) {
            foreach (str_split($v) as $c) {
                if (!Horde_Mime_ContentParam_Decode::isAtextNonTspecial($c)) {
                    $params[$k] = '"' . addcslashes($v, '\\"') . '"';
                    break;
                }
            }
        }

        return $params;
    }
236847
public static function jsonStr($params = [])
    {
        $arr = [];

        array_walk($params, function($value, $key) use (&$arr) {
            $arr[] = "\"{$key}\":\"{$value}\"";
        });

        if (is_array($arr) || count($arr) > 0) {
            return '{' . implode(',', $arr) . '}';
        }

        return '';
    }
122859
public static function getSignatureString($params, $secret) {
        $values = array();
        self::extractParamValues($params, $values);
        sort($values, SORT_STRING);
        $string = $secret . implode('', $values);
        return $string;
    }
450611
private function decorateArrayValue(array $params) : string
    {
        $params_out = [];
        foreach($params as $key => $param) {
            if (is_string($key)){
                $params_out[] = "'$key' =>" . $this->decorateValue($param);
            }
            else{
                $params_out[] = $this->decorateValue($param);
            }
        }
        return '[' . implode(',',$params_out) . ']';
    }
111740
protected function implodeParams(array $params)
    {
        $s = '';

        foreach ($params as $header => $value) {
            $s .= trim($header) . ": " . trim($value) . "\r\n";
        }

        return $s;
    }
291800
public static function encode($data, String $key = NULL, String $separator = NULL) : String
    {
        if( ! is_scalar($data) )
        {
            $data = (array) $data;
        }
        
        $word      = NULL;
        $key       = $key       ?: self::$key;
        $separator = $separator ?: self::$separator;
 
        foreach( $data as $k => $v )
        {
            $word .= self::_security($k).$key.self::_security($v).$separator;
        }

        return mb_substr($word, 0, -(mb_strlen($separator)));
    }
183429
protected static function _buildWriteParams($params = array()) {
		$writeParams['equalKeysOnly'] = (
			isset($params['equalKeysOnly']) &&
			empty($params['equalKeysOnly']) ? false : true
		);

		return $writeParams;
	}
1252935
private function parseParameter(string $key, string $value, &$params): string
    {
        if (isset($params[$key])) {
            $par = $params[$key];
            unset($params[$key]);

            $value = $value ? $value . '_' . $par : $par;
        }

        return static::makeParam($key, $value);
    }
391411
protected function get_error_message_params( $key, $params )
	{
		// do we have a label to replace the key?
		if ( isset( $this->labels[$key] ) )
		{
			$field = $this->labels[$key];
		} else {
			$field = ucfirst( str_replace( array( '_', '-' ), ' ', $key ) );
		}

		return array_merge( array( 'field' => $field ), $params );
	}