public static function getRfl($obj, $propName, $default = null)
    {
        if (!is_object($obj)) {
            return $default;
        }

        try {
            $prop = new \ReflectionProperty($obj, $propName);
        } catch (\Exception $e) {
            return $default;
        }

        if ($prop->isPublic()) {
            return $obj->$propName;
        } else {
            $prop->setAccessible(true);

            return $prop->getValue($obj);
        }
    }
public static function getRfl($obj, $propName, $default = null)
    {
        if (!is_object($obj)) {
            return $default;
        }

        try {
            $prop = new \ReflectionProperty($obj, $propName);
        } catch (\Exception $e) {
            return $default;
        }

        if ($prop->isPublic()) {
            return $obj->$propName;
        } else {
            $prop->setAccessible(true);

            return $prop->getValue($obj);
        }
    }
public static function getRfl ( $ obj , $ propName , $ default = null ) { if ( ! is_object ( $ obj ) ) { return $ default ; } try { $ prop = new \ ReflectionProperty ( $ obj , $ propName ) ; } catch ( \ Exception $ e ) { return $ default ; } if ( $ prop -> isPublic ( ) ) { return $ obj -> $ propName ; } else { $ prop -> setAccessible ( true ) ; return $ prop -> getValue ( $ obj ) ; } }
Get object property value using reflection.

This method is slower then Obj::get.

@param object $obj      The object.
@param string $propName The property name.
@param mixed  $default  The default value to return if property name doesn't exist.

@return mixed|null
Get object property value using reflection .