[2.0][DDC-404] Fixed issue that was failing to debug Proxies and DateTime objects
This commit is contained in:
parent
9d2c275618
commit
cce97067dd
1 changed files with 34 additions and 14 deletions
|
@ -59,7 +59,7 @@ final class Debug
|
||||||
ini_set('xdebug.var_display_max_depth', $maxDepth);
|
ini_set('xdebug.var_display_max_depth', $maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
$var = self::_dumpWithReflection($var, $maxDepth++);
|
$var = self::export($var, $maxDepth++);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
var_dump($var);
|
var_dump($var);
|
||||||
|
@ -71,7 +71,7 @@ final class Debug
|
||||||
ini_set('html_errors', 'Off');
|
ini_set('html_errors', 'Off');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _dumpWithReflection($var, $maxDepth)
|
public static function export($var, $maxDepth)
|
||||||
{
|
{
|
||||||
$return = null;
|
$return = null;
|
||||||
$isObj = is_object($var);
|
$isObj = is_object($var);
|
||||||
|
@ -85,20 +85,40 @@ final class Debug
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
foreach ($var as $k => $v) {
|
foreach ($var as $k => $v) {
|
||||||
$return[$k] = self::_dumpWithReflection($v, $maxDepth - 1);
|
$return[$k] = self::export($v, $maxDepth - 1);
|
||||||
}
|
}
|
||||||
} else if ($isObj) {
|
} else if ($isObj) {
|
||||||
$reflClass = new \ReflectionClass(get_class($var));
|
if ($var instanceof \DateTime) {
|
||||||
$return = new \stdclass();
|
$return = $var->format('c');
|
||||||
$return->{'__CLASS__'} = get_class($var);
|
} else {
|
||||||
|
$reflClass = new \ReflectionClass(get_class($var));
|
||||||
foreach ($reflClass->getProperties() as $reflProperty) {
|
$return = new \stdclass();
|
||||||
$reflProperty->setAccessible(true);
|
$return->{'__CLASS__'} = get_class($var);
|
||||||
|
|
||||||
$name = $reflProperty->getName();
|
if ($var instanceof \Doctrine\ORM\Proxy\Proxy && ! $var->__isInitialized__) {
|
||||||
$value = $reflProperty->getValue($var);
|
$reflProperty = $reflClass->getProperty('_identifier');
|
||||||
|
$reflProperty->setAccessible(true);
|
||||||
$return->$name = self::_dumpWithReflection($value, $maxDepth - 1);
|
|
||||||
|
foreach ($reflProperty->getValue($var) as $name => $value) {
|
||||||
|
$return->$name = self::export($value, $maxDepth - 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$excludeProperties = array();
|
||||||
|
|
||||||
|
if ($var instanceof \Doctrine\ORM\Proxy\Proxy) {
|
||||||
|
$excludeProperties = array('_entityPersister', '__isInitialized__', '_identifier');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($reflClass->getProperties() as $reflProperty) {
|
||||||
|
$name = $reflProperty->getName();
|
||||||
|
|
||||||
|
if ( ! in_array($name, $excludeProperties)) {
|
||||||
|
$reflProperty->setAccessible(true);
|
||||||
|
|
||||||
|
$return->$name = self::export($reflProperty->getValue($var), $maxDepth - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$return = $var;
|
$return = $var;
|
||||||
|
|
Loading…
Add table
Reference in a new issue