Re: Add __toArray() method to objects that would be called on cast to array
| From: | Sebastian Bergmann | Date: | Thu, 16 Mar 2017 05:46:40 +0000 |
| Subject: | Re: Add __toArray() method to objects that would be called on cast to array | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98563@lists.php.net to get a copy of this message | ||
Am 15.03.2017 um 23:33 schrieb Marco Pivetta:
> Also the only way to get all properties from an instance of an inheritance tree.
I use the Reflection API in
https://github.com/sebastianbergmann/object-reflector/blob/master/src/ObjectReflector.php#L24
for retrieving inherited non-public attributes from an object by
traversing the inheritance chain using while ($reflector =
$reflector->getParentClass()).
I wish the ReflectionObject would allow access to all attributes of an
object no matter whether an attribute is declared in the class of the
object or in a parent class.