private function FlattenException::flattenArgs

1 call to FlattenException::flattenArgs()
FlattenException::setTrace in drupal/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php

File

drupal/core/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php, line 242

Class

FlattenException
FlattenException wraps a PHP Exception to be able to serialize it.

Namespace

Symfony\Component\Debug\Exception

Code

private function flattenArgs($args, $level = 0) {
  $result = array();
  foreach ($args as $key => $value) {
    if (is_object($value)) {
      $result[$key] = array(
        'object',
        get_class($value),
      );
    }
    elseif (is_array($value)) {
      if ($level > 10) {
        $result[$key] = array(
          'array',
          '*DEEP NESTED ARRAY*',
        );
      }
      else {
        $result[$key] = array(
          'array',
          $this
            ->flattenArgs($value, ++$level),
        );
      }
    }
    elseif (null === $value) {
      $result[$key] = array(
        'null',
        null,
      );
    }
    elseif (is_bool($value)) {
      $result[$key] = array(
        'boolean',
        $value,
      );
    }
    elseif (is_resource($value)) {
      $result[$key] = array(
        'resource',
        get_resource_type($value),
      );
    }
    elseif ($value instanceof \__PHP_Incomplete_Class) {

      // Special case of object, is_object will return false
      $result[$key] = array(
        'incomplete-object',
        $this
          ->getClassNameFromIncomplete($value),
      );
    }
    else {
      $result[$key] = array(
        'string',
        (string) $value,
      );
    }
  }
  return $result;
}