mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Loop instead of duplicate code
This commit is contained in:
parent
c01aacf72d
commit
84dcd30730
1 changed files with 13 additions and 17 deletions
|
@ -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);
|
||||
$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;
|
||||
$props[] = sprintf('[%s] %s => %s', $visibility, $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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue