$object = new class()
{
private $fooPrivate = 'barPrivate';
public $fooPublic = 'barPublic';
public static $fooStaticPublic = 'barStaticPublic';
public function getProperties(): array
{
return get_object_vars( $this );
}
};
$object->fooDynamic = 'barDynamic';
ReflectionClass
var_export(
( new ReflectionClass( $object ) )
->getProperties()
);
var_export(
( new ReflectionClass( $object ) )
->getProperties( ReflectionProperty::IS_PUBLIC )
);
ReflectionObject
var_export(
( new ReflectionObject( $object ) )
->getProperties()
);
var_export(
( new ReflectionObject( $object ) )
->getProperties( ReflectionProperty::IS_PUBLIC )
);
get_object_vars()
var_export(
get_object_vars( $object )
);
var_export(
$object->getProperties()
);
ReflectionClass::getProperties()ReflectionObject::getProperties()ReflectionClass::getProperties() ReflectionObject::getProperties()get_object_vars()