I have a class with public, public static, private and private static properties and i'm trying to get only the public ones. I just can't get the filter right for some reason, i tried
ReflectionProperty::IS_PUBLIC & ~ReflectionProperty::IS_STATIC
or
ReflectionProperty::IS_PUBLIC & (ReflectionProperty::IS_PUBLIC | ~ReflectionProperty::IS_STATIC)
among other things but either i keep getting the static public or the private static ones.
You would need to query all publics and then filter the public statics out like this:
$ro = new ReflectionObject($obj);
$publics = array_filter(
$ro->getProperties(ReflectionProperty::IS_PUBLIC),
function(ReflectionProperty $prop) {
return !$prop->isStatic();
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With