You are here

private function FlattenException::flattenArgs in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/debug/Exception/FlattenException.php \Symfony\Component\HttpKernel\Exception\FlattenException::flattenArgs()
1 call to FlattenException::flattenArgs()
FlattenException::setTrace in vendor/symfony/debug/Exception/FlattenException.php

File

vendor/symfony/debug/Exception/FlattenException.php, line 254

Class

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

Namespace

Symfony\Component\HttpKernel\Exception

Code

private function flattenArgs($args, $level = 0, &$count = 0) {
  $result = array();
  foreach ($args as $key => $value) {
    if (++$count > 10000.0) {
      return array(
        'array',
        '*SKIPPED over 10000 entries*',
      );
    }
    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 + 1, $count),
        );
      }
    }
    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;
}