Format the given value for display.

@param  mixed $val     The value to to convert for display.
@param  array $options Optional display options.
@return string
176953
public function displayVal($val, array $options = [])
    {
        if ($val === null || $val === '') {
            return '';
        }

        /** Parse multilingual values */
        if ($this->l10n()) {
            $propertyValue = $this->l10nVal($val, $options);
            if ($propertyValue === null) {
                return '';
            }
        } elseif ($val instanceof Translation) {
            $propertyValue = (string)$val;
        } else {
            $propertyValue = $val;
        }

        $separator = $this->multipleSeparator();

        /** Parse multiple values / ensure they are of array type. */
        if ($this->multiple()) {
            if (!is_array($propertyValue)) {
                $propertyValue = explode($separator, $propertyValue);
            }
        }

        if ($separator === ',') {
            $separator = ', ';
        }

        if (is_array($propertyValue)) {
            foreach ($propertyValue as &$value) {
                if (is_string($value)) {
                    $value = $this->choiceLabel($value);
                    if (!is_string($value)) {
                        $value = $this->l10nVal($value, $options);
                    }
                }
            }
            $propertyValue = implode($separator, $propertyValue);
        } elseif (is_string($propertyValue)) {
            $propertyValue = $this->choiceLabel($propertyValue);
            if (!is_string($propertyValue)) {
                $propertyValue = $this->l10nVal($propertyValue, $options);
            }
        }

        return $propertyValue;
    }
1080635
public function _toParam($val) {
		$res = [];
		foreach ($val as $key => $v) {
			$res[] = $key . $this->_config['keyValueSeparator'] . $v;
		}
		return implode($this->_config['separator'], $res);
	}
825527
public function renderOptionValueHint(Option $opt, $assign = true): string
    {
        $n = 'value';
        if ($opt->valueName) {
            $n = $opt->valueName;
        } elseif ($opt->isa) {
            $n = $opt->isa;
        }

        $c = $assign ? '=' : ' ';
        $n = $this->formatter->format($n, 'underline');

        if ($opt->isRequired()) {
            return "$c<$n>";
        }

        if ($opt->isOptional()) {
            return "{$c}[<$n>]";
        }

        return '';
    }
647478
public static function raw2xml($val)
    {
        if (is_array($val)) {
            foreach ($val as $k => $v) {
                $val[$k] = self::raw2xml($v);
            }
            return $val;
        }

        return htmlspecialchars($val, ENT_QUOTES, 'UTF-8');
    }
973132
public function debugVariableText($val)
    {
        // Check debug
        if (is_object($val) && ClassInfo::hasMethod($val, 'debug')) {
            return $val->debug();
        }

        // Format as array
        if (is_array($val)) {
            $result = '';
            foreach ($val as $key => $valueItem) {
                $keyText = Convert::raw2xml($key);
                $valueText = $this->debugVariableText($valueItem);
                $result .= "<li>{$keyText} = {$valueText}</li>\n";
            }
            return "<ul>\n{$result}</ul>\n";
        }

        // Format object
        if (is_object($val)) {
            return var_export($val, true);
        }

        // Format bool
        if (is_bool($val)) {
            return '(bool) ' . ($val ? 'true' : 'false');
        }

        // Format text
        $html = Convert::raw2xml($val);
        return "<pre style=\"font-family: Courier new, serif\">{$html}</pre>\n";
    }
766840
public function renderValue($value, array $options = []): string
    {
        $resolver = new OptionsResolver();
        $this->configureOptions($resolver);
        $options = $resolver->resolve($options);

        if ($value instanceof \DateTimeInterface) {
            if (null !== $options['date_format']) {
                return (string) $value->format($options['date_format']);
            }
            if ($value->format('H:i') === '00:00') {
                $options['time_type'] = \IntlDateFormatter::NONE;
            }
            $dateFormatter = new \IntlDateFormatter(
                $this->translator->getLocale(),
                $options['date_type'],
                $options['time_type']
            );

            return (string) $dateFormatter->format($value);
        }
        if (\is_int($value)) {
            return (string) $value;
        }
        if (\is_float($value)) {
            if (null !== $options['decimals'] || null !== $options['dec_point'] || null !== $options['thousands_sep']) {
                return number_format(
                    $value,
                    $options['decimals'] ?: 2,
                    $options['dec_point'] ?: '.',
                    $options['thousands_sep'] ?: ','
                );
            }
            $numberFormatter = new \NumberFormatter($this->translator->getLocale(), $options['number_format']);

            return (string) $numberFormatter->format($value);
        }
        if (\is_iterable($value)) {
            $items = [];
            /** @noinspection ForeachSourceInspection */
            foreach ($value as $key => $item) {
                $rendered = $this->renderValue($item, $options);
                if (!is_numeric($key)) {
                    $rendered = $key.$options['key_value_separator'].$rendered;
                }
                $items[] = $rendered;
            }

            return implode($options['array_glue'], $items);
        }
        if (\is_bool($value)) {
            if ($options['bool_use_translator']) {
                return (string) $this->translator->trans(
                    $value ? $options['bool_true'] : $options['bool_false']
                );
            }

            return $value ? $options['bool_true'] : $options['bool_false'];
        }

        return (string) $value;
    }
979307
protected function option($display, $value, $selected)
    {
        $selected = $this->getSelectedValue($value, $selected);

        $options = array('value' => $this->html->entities($value), 'selected' => $selected);

        return '<option'.$this->html->attributes($options).'>'.$this->html->entities($display).'</option>';
    }
376849
protected function formatValue($value)
    {
        if (\is_object($value)) {
            return sprintf('object(%s)', \get_class($value));
        }

        if (\is_string($value)) {
            return $value;
        }

        return preg_replace("/\n\s*/s", '', var_export($value, true));
    }
850809
public static function getCode($val)
    {
        switch($val) {
        case self::DKK:
            return 'dkk';
        case self::EUR:
            return 'eur';
        case self::NOK:
            return 'nok';
        case self::SEK:
            return 'sek';
        default:
            return null;
        }
    }
1060236
private function getFormat(array $options)
    {
        if (isset($options[self::PARAM_FORMAT])) {
            return $options[self::PARAM_FORMAT];
        } else {
            return $this->defaultFormat;
        }
    }
913893
public static function format($number, array $options = []) {
		$defaults = [
			'positive' => '+', 'signed' => false
		];
		$options += $defaults;
		$sign = '';
		if ($number > 0 && !empty($options['signed'])) {
			$sign = '+';
		}
		if (isset($options['signed'])) {
			unset($options['signed']);
		}
		return $sign . parent::format($number, $options);
	}
1315957
public function quoteOrNot($val)
    {
        return ((is_string($val) || is_numeric($val)) and !$this->isNotQuotable($val)) ? sprintf("'%s'", $val) : $val;
    }
554658
protected function htmlS($val)
    {
        if (is_array($val) || is_object($val)) {
            Throw new ViewException('It is not allowed to uses arrays or objects for htmlS() output.');
        }

        return htmlspecialchars($val, ENT_COMPAT, 'UTF-8');
    }
1220039
function (val) {
		var parseDate = this.options.parseDate,
			ret,
			key,
			format,
			match;

		if (parseDate) {
			ret = parseDate(val);
		}
			
		if (typeof val === 'string') {
			for (key in this.dateFormats) {
				format = this.dateFormats[key];
				match = val.match(format.regex);
				if (match) {
					ret = format.parser(match);
				}
			}
		}
		return ret;
	}
1184205
public function inputVal($val, array $options = [])
    {
        $val = $this->dateTimeVal($val);

        if ($val instanceof DateTimeInterface) {
            return $val->format('Y-m-d H:i:s');
        } else {
            return '';
        }
    }
420532
public static function renderOption($value, $label, $selected, $options = [])
    {
        if ($value === true) {
            // Handle the special case of a true value
            $value = "true";
        }
        $options = array_merge($options, ["value" => $value]);
        if ($selected) {
            $options['selected'] = true;
        }

        return sprintf("<option %s>%s</option>", html_params($options), $label);
    }
1255601
private function formatValue($value)
    {
        $attribute = $this->getAttributeModel();

        if ((int) $attribute->getDisplayPrecision() > 0) {
            $locale = $this->localeResolver->getLocale();
            $options = ['locale' => $locale, 'precision' => (int) $attribute->getDisplayPrecision()];
            $valueFormatter = new \Zend_Filter_NormalizedToLocalized($options);
            $value = $valueFormatter->filter($value);
        }

        if ((string) $attribute->getDisplayPattern() != "") {
            $value = sprintf((string) $attribute->getDisplayPattern(), $value);
        }

        return $value;
    }