protected function DataCollector::varToString

Converts a PHP variable to a string.

Parameters

mixed $var A PHP variable:

Return value

string The string representation of the variable

1 call to DataCollector::varToString()
RequestDataCollector::collect in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
Collects data for the given Request and Response.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php, line 42

Class

DataCollector
DataCollector.

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

protected function varToString($var) {
  if (is_object($var)) {
    return sprintf('Object(%s)', get_class($var));
  }
  if (is_array($var)) {
    $a = array();
    foreach ($var as $k => $v) {
      $a[] = sprintf('%s => %s', $k, $this
        ->varToString($v));
    }
    return sprintf("Array(%s)", implode(', ', $a));
  }
  if (is_resource($var)) {
    return sprintf('Resource(%s)', get_resource_type($var));
  }
  if (null === $var) {
    return 'null';
  }
  if (false === $var) {
    return 'false';
  }
  if (true === $var) {
    return 'true';
  }
  return (string) $var;
}