Skip to content

Commit

Permalink
Loop instead of duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrang committed Aug 6, 2013
1 parent c01aacf commit 84dcd30
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions lib/Cake/Utility/Debugger.php
Expand Up @@ -591,24 +591,20 @@ protected static function _object($var, $depth, $indent) {
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$ref = new ReflectionObject($var);

$reflectionProperties = $ref->getProperties(ReflectionProperty::IS_PROTECTED);
foreach ($reflectionProperties as $reflectionProperty) {
$reflectionProperty->setAccessible(true);
$property = $reflectionProperty->getValue($var);

$value = self::_export($property, $depth - 1, $indent);
$key = $reflectionProperty->name;
$props[] = "[protected] $key => " . $value;
}

$reflectionProperties = $ref->getProperties(ReflectionProperty::IS_PRIVATE);
foreach ($reflectionProperties as $reflectionProperty) {
$reflectionProperty->setAccessible(true);
$property = $reflectionProperty->getValue($var);

$value = self::_export($property, $depth - 1, $indent);
$key = $reflectionProperty->name;
$props[] = "[private] $key => " . $value;
$filters = array(
ReflectionProperty::IS_PROTECTED => 'protected',
ReflectionProperty::IS_PRIVATE => 'private',
);
foreach ($filters as $filter => $visibility) {
$reflectionProperties = $ref->getProperties($filter);
foreach ($reflectionProperties as $reflectionProperty) {
$reflectionProperty->setAccessible(true);
$property = $reflectionProperty->getValue($var);

$value = self::_export($property, $depth - 1, $indent);
$key = $reflectionProperty->name;
$props[] = sprintf('[%s] %s => %s', $visibility, $key, $value);
}
}
}

Expand Down

0 comments on commit 84dcd30

Please sign in to comment.