public function __construct($var, $level, Options $options) { parent::__construct(self::TYPE_ID, array(), $level, $options); $this->length = count($var); if ($this->level < $this->options->getOption('array.max_nesting_level')) { foreach ($var as $k => $v) { $this->add($v, $k); } } }
public function __construct($var, $level, Options $options) { parent::__construct(self::TYPE_ID, $var, $level, $options); $this->resource_type = get_resource_type($var); if ($this->resource_type == 'stream') { $stream_vars = stream_get_meta_data($var); // prevent unix sistems getting stream in files if (isset($stream_vars['stream_type']) && $stream_vars['stream_type'] == 'STDIO') { $this->resource_type = 'file'; } } // is there a class to show the resource info? $include_class = $this->getIncludeClass($this->resource_type, 'resource'); if (class_exists($include_class)) { $custom_dumper = new $include_class($var); $this->resource_custom_data = $custom_dumper->dump($var); unset($custom_dumper); $custom_dumper = NULL; } }
public function __construct($level, Options $options) { parent::__construct(self::TYPE_ID, null, $level, $options); }
public function __construct($var, $level, Options $options) { parent::__construct(self::TYPE_ID, $var, $level, $options); $this->inspect_custom_data = true; $this->class_name = get_class($var); $this->tostring = null; if ($this->level < $this->options->getOption('object.max_nesting_level')) { $this->is_leaf = false; $reflection_class = new \ReflectionClass($this->class_name); // class info if ($this->options->getOption('object.show_classinfo')) { $this->class_file = $reflection_class->getFileName(); if (empty($this->class_file)) { $this->class_file = 'built-in'; } $this->class_interfaces = implode(', ', $reflection_class->getInterfaceNames()); $this->class_namespace = $reflection_class->getNamespaceName(); $class_parent_obj = $reflection_class->getParentClass(); if ($class_parent_obj) { $this->class_parent = $class_parent_obj->getName(); } else { $this->class_parent = ''; } unset($class_parent_obj); $class_parent_obj = NULL; } if ($this->options->getOption('object.show_data')) { // is there a class to show the object data? $include_class = $this->getIncludeClass($this->class_name, 'object'); if (class_exists($include_class)) { $custom_dumper = new $include_class($var); $this->object_custom_data = $custom_dumper->dump($var); $this->is_custom_data = TRUE; if (is_array($this->object_custom_data)) { $this->inspect_custom_data = $custom_dumper->getInspect(); } else { $this->inspect_custom_data = FALSE; } } else { $this->object_custom_data = (array) $var; $this->is_custom_data = FALSE; $this->inspect_custom_data = TRUE; } // Custom/array-cast data & name normalization if (!empty($this->object_custom_data) && is_array($this->object_custom_data)) { foreach ($this->object_custom_data as &$c) { $c = TFactory::factory($c, $this->level, $options); } } } // Class constants if ($this->options->getOption('object.show_constants')) { $this->class_constants = $reflection_class->getConstants(); if (!empty($this->class_constants)) { foreach ($this->class_constants as &$c) { $c = TFactory::factory($c, $this->level, $options); } } } // Object properties if ($this->options->getOption('object.show_properties')) { $object_properties = $reflection_class->getProperties(); $this->object_properties = array(); if (!empty($object_properties)) { foreach ($object_properties as $property) { if ($property->isPublic()) { $property_value = $property->getValue($this->value); $this->object_properties[$property->getName()] = TFactory::factory($property_value, $this->level, $options); } } } } // Class methods if ($this->options->getOption('object.show_methods')) { $this->class_methods = array(); $class_methods = $reflection_class->getMethods(); if (!empty($class_methods)) { foreach ($class_methods as $k => $v) { $method = $reflection_class->getMethod($v->name); if ($method->getName() == '__toString') { $this->tostring = $var->__toString(); } $method_syntax = ''; if ($method->isStatic()) { $method_syntax .= 'static '; } elseif ($method->isPublic()) { $method_syntax .= 'public '; } elseif ($method->isProtected()) { $method_syntax .= 'protected '; } elseif ($method->isPrivate()) { $method_syntax .= 'private '; } $method_syntax .= $method->getName(); $method_parameters = $method->getParameters(); $method_syntax .= '('; $method_parameters_result = array(); foreach ($method_parameters as $parameter) { $parameter_result = ''; $class = $parameter->getClass(); if ($class instanceof \ReflectionClass) { $parameter_result .= $class->getName() . ' '; } if ($parameter->isOptional()) { $parameter_result .= '['; } if ($parameter->isPassedByReference()) { $parameter_result .= '&'; } $parameter_result .= '$' . $parameter->getName(); $default = NULL; if ($parameter->isDefaultValueAvailable()) { $default = $parameter->getDefaultValue(); if ($default === null) { $default = 'NULL'; } elseif (is_bool($default)) { $default = $default ? 'TRUE' : 'FALSE'; } elseif (is_string($default)) { $default = '"' . htmlentities($default, ENT_COMPAT) . '"'; } elseif (is_array($default)) { $default = 'Array'; } $parameter_result .= ' = ' . $default; } if ($parameter->isOptional()) { $parameter_result .= ']'; } $method_parameters_result[] = $parameter_result; } $method_syntax .= implode(', ', $method_parameters_result); $method_syntax .= ')'; $this->class_methods[] = $method_syntax; } sort($this->class_methods, SORT_STRING); } } } else { $this->is_leaf = TRUE; } }
/** * Constructor * @param string $var * @param int $level * @param Options $options */ public function __construct($var, $level, Options $options) { $this->encoding = mb_detect_encoding($var); $this->length = mb_strlen($var, $this->_getEncodingForHtmlentities()); parent::__construct(self::TYPE_ID, $var, $level, $options); }