From 84dcd30730439d20ff84855b21f3a67fb62ef588 Mon Sep 17 00:00:00 2001 From: Tigran Gabrielyan Date: Tue, 6 Aug 2013 15:37:20 -0700 Subject: [PATCH] Loop instead of duplicate code --- lib/Cake/Utility/Debugger.php | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index e1b5c2aec..28a819b80 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -591,24 +591,20 @@ class Debugger { 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); + $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[] = "[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; + $value = self::_export($property, $depth - 1, $indent); + $key = $reflectionProperty->name; + $props[] = sprintf('[%s] %s => %s', $visibility, $key, $value); + } } }