Reflection properties Filter

php

Solution

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();
    }
);

Problem

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.

Original source