I'm running through a set of arrays and objects for further processing.
If it's an object i use get_object_vars($obj)
to get its proberties. But if that object uses magic getters/setters, it returns an empty array. Here a little demo of the issue:
class Foo {
protected
$fields = array(
'foo'=>1,
'bar'=>2
);
function __get($key) {
return $this->fields[$key];
}
function __isset($key) {
return array_key_exists($key,$this->fields);
}
}
$foo = new Foo();
var_dump(get_object_vars($foo));
I want that get_object_vars
returns the $fields
key-value pairs. Is there any way to go, or any method to implement in Foo
to make it work?
thanks for any hint.