note 79062 deleted from language.oop5.magic by cmb
| From: | cmb@php.net | Date: | Sun, 10 Nov 2019 12:41:42 +0000 |
| Subject: | note 79062 deleted from language.oop5.magic by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212993@lists.php.net to get a copy of this message | ||
Note Submitter: andrew dot minerd at sellingsource dot com
----
Until __sleep is "fixed" (here's hoping), a function that will return ALL members of
a given object -- public, protected, AND private:
<?php
public function getPropertyNames(array $filter = NULL)
{
$rc = new ReflectionObject($this);
$names = array();
while ($rc instanceof ReflectionClass)
{
foreach ($rc->getProperties() as $prop)
{
if (!$filter || !in_array($prop->getName(), $filter))
$names[] = $prop->getName();
}
$rc = $rc->getParentClass();
}
return $names;
}
?>