3 namespace Wikimedia\DebugInfo
;
10 * Convert an object to an array by casting, but filter the properties
11 * to make recursive dumping more feasible.
13 * phpcs:ignore MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam
14 * @param object $object
16 * @throws \ReflectionException
18 public static function objectToArray( $object ) {
19 $vars = (array)$object;
20 $class = new \
ReflectionClass( $object );
22 foreach ( $class->getProperties() as $property ) {
23 if ( AnnotationReader
::propertyHasAnnotation( $property, 'noVarDump' ) ) {
24 // Ref: zend_declare_typed_property(), zend_mangle_property_name()
25 if ( $property->isPrivate() ) {
26 $mangledName = "\0{$class->name}\0{$property->name}";
27 } elseif ( $property->isProtected() ) {
28 $mangledName = "\0*\0{$property->name}";
30 $mangledName = $property->name
;
32 if ( isset( $vars[$mangledName] ) && !is_scalar( $vars[$mangledName] ) ) {
33 $vars[$mangledName] = new Placeholder( $vars[$mangledName] );
37 $class = $class->getParentClass();