Reputation: 22406
I tried:
$rc = new \ReflectionClass($this);
$rc->getProperties(ReflectionProperty::IS_PUBLIC || ReflectionProperty::IS_PRIVATE || ReflectionProperty::IS_PROTECTED)
But all that did was give me the one static
property that the class has. It has 3 private
and one static
. I just want to know how to weed out the static
ones.
Upvotes: 0
Views: 26
Reputation: 78994
Your static
properties are also public
, private
or protected
, so it returns them as well. You need to check each property with isStatic()
:
foreach($rc->getProperties() as $prop) {
if(!$prop->isStatic()) { // or $prop->isStatic() === false
$result[] = $prop;
}
}
getProperties()
defaults to all properties.
Upvotes: 1