| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\DebugInfo; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
class DumpUtils { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public static function objectToArray( $object ) { |
| 19 |
$vars = (array)$object; |
| 20 |
$class = new \ReflectionClass( $object ); |
| 21 |
while ( $class ) { |
| 22 |
foreach ( $class->getProperties() as $property ) { |
| 23 |
if ( AnnotationReader::propertyHasAnnotation( $property, 'noVarDump' ) ) { |
| 24 |
|
| 25 |
if ( $property->isPrivate() ) { |
| 26 |
$mangledName = "\0{$class->name}\0{$property->name}"; |
| 27 |
} elseif ( $property->isProtected() ) { |
| 28 |
$mangledName = "\0*\0{$property->name}"; |
| 29 |
} else { |
| 30 |
$mangledName = $property->name; |
| 31 |
} |
| 32 |
if ( isset( $vars[$mangledName] ) && !is_scalar( $vars[$mangledName] ) ) { |
| 33 |
$vars[$mangledName] = new Placeholder( $vars[$mangledName] ); |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
$class = $class->getParentClass(); |
| 38 |
} |
| 39 |
return $vars; |
| 40 |
} |
| 41 |
} |