Dumps values.

@param mixed $value
@param bool  $interpolate

@return string

@throws RuntimeException
324185
private function dumpValue($value, $interpolate = true)
    {
        if (is_array($value)) {
            if ($value && $interpolate && false !== $param = array_search($value, $this->container->getParameterBag()->all(), true)) {
                return $this->dumpValue("%$param%");
            }
            $code = array();
            foreach ($value as $k => $v) {
                $code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate));
            }

            return sprintf('array(%s)', implode(', ', $code));
        } elseif ($value instanceof ArgumentInterface) {
            $scope = array($this->definitionVariables, $this->referenceVariables, $this->variableCount);
            $this->definitionVariables = $this->referenceVariables = null;

            try {
                if ($value instanceof ServiceClosureArgument) {
                    $value = $value->getValues()[0];
                    $code = $this->dumpValue($value, $interpolate);

                    if ($value instanceof TypedReference) {
                        $code = sprintf('$f = function (\\%s $v%s) { return $v; }; return $f(%s);', $value->getType(), ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $value->getInvalidBehavior() ? ' = null' : '', $code);
                    } else {
                        $code = sprintf('return %s;', $code);
                    }

                    return sprintf("function () {\n            %s\n        }", $code);
                }

                if ($value instanceof IteratorArgument) {
                    $operands = array(0);
                    $code = array();
                    $code[] = 'new RewindableGenerator(function () {';

                    if (!$values = $value->getValues()) {
                        $code[] = '            return new \EmptyIterator();';
                    } else {
                        $countCode = array();
                        $countCode[] = 'function () {';

                        foreach ($values as $k => $v) {
                            ($c = $this->getServiceConditionals($v)) ? $operands[] = "(int) ($c)" : ++$operands[0];
                            $v = $this->wrapServiceConditionals($v, sprintf("        yield %s => %s;\n", $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate)));
                            foreach (explode("\n", $v) as $v) {
                                if ($v) {
                                    $code[] = '    '.$v;
                                }
                            }
                        }

                        $countCode[] = sprintf('            return %s;', implode(' + ', $operands));
                        $countCode[] = '        }';
                    }

                    $code[] = sprintf('        }, %s)', count($operands) > 1 ? implode("\n", $countCode) : $operands[0]);

                    return implode("\n", $code);
                }
            } finally {
                list($this->definitionVariables, $this->referenceVariables, $this->variableCount) = $scope;
            }
        } elseif ($value instanceof Definition) {
            if (null !== $this->definitionVariables && $this->definitionVariables->contains($value)) {
                return $this->dumpValue($this->definitionVariables[$value], $interpolate);
            }
            if ($value->getMethodCalls()) {
                throw new RuntimeException('Cannot dump definitions which have method calls.');
            }
            if ($value->getProperties()) {
                throw new RuntimeException('Cannot dump definitions which have properties.');
            }
            if (null !== $value->getConfigurator()) {
                throw new RuntimeException('Cannot dump definitions which have a configurator.');
            }

            $arguments = array();
            foreach ($value->getArguments() as $argument) {
                $arguments[] = $this->dumpValue($argument);
            }

            if (null !== $value->getFactory()) {
                $factory = $value->getFactory();

                if (is_string($factory)) {
                    return sprintf('%s(%s)', $this->dumpLiteralClass($this->dumpValue($factory)), implode(', ', $arguments));
                }

                if (is_array($factory)) {
                    if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $factory[1])) {
                        throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $factory[1] ?: 'n/a'));
                    }

                    $class = $this->dumpValue($factory[0]);
                    if (is_string($factory[0])) {
                        return sprintf('%s::%s(%s)', $this->dumpLiteralClass($class), $factory[1], implode(', ', $arguments));
                    }

                    if ($factory[0] instanceof Definition) {
                        if (0 === strpos($class, 'new ')) {
                            return sprintf('(%s)->%s(%s)', $class, $factory[1], implode(', ', $arguments));
                        }

                        return sprintf("\\call_user_func(array(%s, '%s')%s)", $class, $factory[1], count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
                    }

                    if ($factory[0] instanceof Reference) {
                        return sprintf('%s->%s(%s)', $class, $factory[1], implode(', ', $arguments));
                    }
                }

                throw new RuntimeException('Cannot dump definition because of invalid factory');
            }

            $class = $value->getClass();
            if (null === $class) {
                throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
            }

            return sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), implode(', ', $arguments));
        } elseif ($value instanceof Variable) {
            return '$'.$value;
        } elseif ($value instanceof Reference) {
            $id = $this->container->normalizeId($value);
            if (null !== $this->referenceVariables && isset($this->referenceVariables[$id])) {
                return $this->dumpValue($this->referenceVariables[$id], $interpolate);
            }

            return $this->getServiceCall($id, $value);
        } elseif ($value instanceof Expression) {
            return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container'));
        } elseif ($value instanceof Parameter) {
            return $this->dumpParameter($value);
        } elseif (true === $interpolate && is_string($value)) {
            if (preg_match('/^%([^%]+)%$/', $value, $match)) {
                // we do this to deal with non string values (Boolean, integer, ...)
                // the preg_replace_callback converts them to strings
                return $this->dumpParameter($match[1]);
            } else {
                $replaceParameters = function ($match) {
                    return "'.".$this->dumpParameter($match[2]).".'";
                };

                $code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters, $this->export($value)));

                return $code;
            }
        } elseif (is_object($value) || is_resource($value)) {
            throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
        }

        return $this->export($value);
    }
62756
function interpolate (args) {
  var substr = this.match(rtplVars)
  var result = this
  var vars
  var argv

  if (isObject(args)) {
   argv = args
 } else if (Array.isArray(args)) {
   argv = argv = args
  } else if (arguments.length) {
   argv = [].slice.call(arguments)
  }

  if (substr == undefined || !Array.isArray(argv) && !isObject(argv)) {
   return this.toString()
  }

  vars = substr.map(function (str) {
   return str.replace(/(^[$#]\{)|(\}$)/g, '')
  })

  if (isObject(argv) || Array.isArray(argv)) {
   for (var i = 0, len = substr.length; i < len; i++) {
     result = result.replace(substr[i], argv[vars[i]])
   }
  }

  return result
}
560282
public static function encode($value, $options = 0)
    {
        $result = json_encode($value, (int) $options);
        // @codeCoverageIgnoreStart
        if ($result === false) {
            throw new \RuntimeException(static::$errorMessages[json_last_error()]);
        }
        // @codeCoverageIgnoreEnd

        return $result;
    }
345556
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value) {
            return $this->onNullFromPhp();
        }

        return $value->getValue();
    }
1289492
public function dump($value, int $output = self::OUTPUT_ECHO): string
    {
        switch ($output) {
            case self::OUTPUT_ECHO:
                echo $this->style->wrapContainer($this->dumpValue($value, '', 0));
                break;

            case self::OUTPUT_LOG:
                if (!empty($this->logger)) {
                    $this->logger->debug($this->dump($value, self::OUTPUT_RETURN));
                }
                break;

            case self::OUTPUT_RETURN:
                return $this->style->wrapContainer($this->dumpValue($value, '', 0));
        }

        //Nothing to return
        return '';
    }
637695
protected function dumpValue($value): string
    {
        if (null === $value) {
            return 'null';
        }

        if (false === $value) {
            return 'false';
        }
        if (true === $value) {
            return 'true';
        }

        if (\is_int($value) || \is_float($value)) {
            return (string)$value;
        }

        if (\is_string($value)) {
            return StringHelper::dumpString($value);
        }

        throw new \InvalidArgumentException('Unsupported data type:' . gettype($value));
    }
686146
public static function formatForTitle($value = "", $delimiters=['-','_'])
    {
        // if value passed as empty or is not a string then return false
        if (!is_string($value) || strlen($value) === 0) {
            return false;
        }

        /** @var string $cache Cache Value */
        $cache = self::cacheString($value, $delimiters);

        // check for cache
        if (isset(static::$formatForTitleCache[$cache])) {
            return static::$formatForTitleCache[$cache];
        }

        // change underscores to spaces
        $stripDelimiters = str_replace($delimiters, array_fill(0, count($delimiters), ' '), $value);

        return static::$formatForTitleCache[$cache] = Strings::titleCase($stripDelimiters);
    }
878064
public function dump($value) {
        Mage::register('turpentine_nocache_flag', true, true);
        $this->logValue($value);
        echo '<pre>'.PHP_EOL;
        var_dump($value);
        echo '</pre>'.PHP_EOL;
    }
1085462
public function convertToDatabaseValue($value, AbstractPlatform $platform) : ?string
    {
        if ($value instanceof DateTime) {
            $value->setTimezone($this->getUtc());
        }

        return parent::convertToDatabaseValue($value, $platform);
    }
648722
protected function packValue($value): string
    {
        if ($value instanceof DeclarationInterface) {
            //No indentation here
            return $value->render();
        }

        if (is_null($value)) {
            return "null";
        }

        if (is_bool($value)) {
            return ($value ? "true" : "false");
        }

        if (is_object($value) && method_exists($value, '__set_state')) {
            return var_export($value, true);
        }

        if (!is_string($value) && !is_numeric($value)) {
            throw new SerializeException("Unable to pack non scalar value");
        }

        if (is_string($value) && class_exists($value)) {
            $reflection = new \ReflectionClass($value);
            if ($value === $reflection->getName()) {
                return '\\' . $reflection->getName() . '::class';
            }
        }

        return var_export($value, true);
    }
1277804
public function dump($value) : string
    {
        if (! is_numeric($value))
            throw new DumpException($this, $value, self::ERROR);

        return ''. $value;
    }
854848
private function _dumpNode($key,$value,$indent) {
		// do some folding here, for blocks
		if (strpos($value,"\n") !== FALSE || strpos($value,": ") !== FALSE || strpos($value,"- ") !== FALSE) {
			$value = $this->_doLiteralBlock($value,$indent);
		} else {
			$value  = $this->_doFolding($value,$indent);
		}

		if (is_bool($value)) {
			$value = ($value) ? "true" : "false";
		}

		$spaces = str_repeat(' ',$indent);

		if (is_int($key)) {
			// It's a sequence
			$string = $spaces.'- '.$value."\n";
		} else {
			// It's mapped
			$string = $spaces.$key.': '.$value."\n";
		}
		return $string;
	}
208090
private function _interpolateCallback($matches)
	{
		$key = $matches[1];

		if (!isset($this->_interpolate[$key]))
		{
			throw new Exception(sprintf(
				"%s route needs '%s' value for '%s'",
				$this->_name,
				$key,
				$this->_template
			));
		}

		// percent encoding as per section 3.2 of URI Templates draft 9 July 2007,
		// and section 2.1 of http://www.faqs.org/rfcs/rfc3986
		return rawurlencode($this->_interpolate[$key]);
	}
446
public static function export($value)
	{
		if (!is_scalar($value))
		{
			throw new InvalidArgumentException(__METHOD__ . '() cannot export non-scalar values');
		}
		if (is_int($value))
		{
			return (string) $value;
		}
		if (is_float($value))
		{
			// Avoid locale issues by using sprintf()
			return preg_replace('(\\.?0+$)', '', sprintf('%F', $value));
		}

		return self::exportString((string) $value);
	}
69076
protected void addInterpolationValue(String name, String value) {
        interpolationValues.put(String.format("${%s}", name), value);
        interpolationValues.put(String.format("@{%s}", name), value);
    }
677715
function interpolate(str, context) {
  const opts = { ...context.options };

  let val = opts.apiurl + str.replace(/:([\w_]+)/g, (m, key) => {
    opts.params = union(opts.params, key);
    let val = get(opts, key);
    if (val !== void 0) {
      return val;
    }
    return key;
  });

  if (opts.method.toLowerCase() === 'get' && opts.paged !== false) {
    const obj = url.parse(val);
    const query = obj.query ? qs.parse(obj.query) : {};
    const noquery = omit(obj, ['query', 'search']);
    noquery.query = noquery.search = qs.stringify(Object.assign({ per_page: 100 }, opts.query, query));
    val = url.format(noquery);
  }

  val += /\?/.test(val) ? '&' : '?';
  val += (new Date()).getTime();
  return val;
}
291527
def dump_value(value)
      case value
      when Array
        # dump recursively
        value.map { |v| dump_value v }
      when String
        replace_interpolations value
      end
    end