Inspired by the recent discussion on __toArray(), I'd like to propose the
addition of a get_mangled_object_properties() function, implemented in
This function returns the mangled object properties (duh...), which matches
the behavior of the (array) cast, with the difference that an overloaded
(array) cast will be ignored. To the best of my knowledge the only internal
class currently doing this is ArrayObject.
There are a couple of motivation for this:
- It makes it more obvious that code operates on mangled properties. This
allows clearly distinguishing (array) casts used for low-level object
introspection and (array) casts used for things like converting between
stdClass and arrays.
- It is more robust, because it is not affected by overloading. At least
in theory it allows us to introduce the __toArray() method proposed in the
other thread (though I don't personally endorse this).
- Longer term, it would allow us to change (array) to return non-mangled
(visibility-respecting) properties -- the current behavior is a WTF factor
for anyone who doesn't happen to work on serialization or dumping libraries.