protected function objectToRawArray($data, bool
$onlyChanged = true, bool
$recursive = false
): ?array
{ if (method_exists($data, 'toRawArray'
)) { $properties =
$data->
toRawArray($onlyChanged,
$recursive);
} else { $mirror =
new ReflectionClass($data);
$props =
$mirror->
getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED
);
$properties =
[];
// Loop over each property,
// saving the name/value in a new array we can return.
foreach ($props as $prop) { // Must make protected values accessible.
$prop->
setAccessible(true
);