private function ExceptionHandler::formatArgs

Formats an array as a string.

Parameters

array $args The argument array:

Return value

string

1 call to ExceptionHandler::formatArgs()
ExceptionHandler::getContent in drupal/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php
Gets the HTML content associated with the given exception.

File

drupal/core/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php, line 291

Class

ExceptionHandler
ExceptionHandler converts an exception to a Response object.

Namespace

Symfony\Component\Debug

Code

private function formatArgs(array $args) {
  $result = array();
  foreach ($args as $key => $item) {
    if ('object' === $item[0]) {
      $formattedValue = sprintf("<em>object</em>(%s)", $this
        ->abbrClass($item[1]));
    }
    elseif ('array' === $item[0]) {
      $formattedValue = sprintf("<em>array</em>(%s)", is_array($item[1]) ? $this
        ->formatArgs($item[1]) : $item[1]);
    }
    elseif ('string' === $item[0]) {
      $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset));
    }
    elseif ('null' === $item[0]) {
      $formattedValue = '<em>null</em>';
    }
    elseif ('boolean' === $item[0]) {
      $formattedValue = '<em>' . strtolower(var_export($item[1], true)) . '</em>';
    }
    elseif ('resource' === $item[0]) {
      $formattedValue = '<em>resource</em>';
    }
    else {
      $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), true));
    }
    $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
  }
  return implode(', ', $result);
}