动态的获得对象当前的私有属性值

用法:
```
$value=Tool::getPrivateValue('orWhere',$ap)
var_dump($value);
```

@param string $fieldName 要获取的属性名。
@param object $obj 从哪个对象里获取
@return mixed 对象的私有属性值。
199585
public static function getPrivateValue($fieldName, $obj)
    {
        $r = new \ReflectionObject($obj);

        while (true) {
            if (!$r->hasProperty($fieldName)) {
                $p = $r->getParentClass();
                if (!$p) {
                    break;
                } else {
                    $r = $p;
                }
            } else {
                break;
            }
        }
        $sec = $r->getProperty($fieldName);
        $sec->setAccessible(true);
        $value = $sec->getValue($obj);
        return $value;
    }
443741
public static function getPropertyValue($object,$propertyName)
    {
        $getter = "get" . ucfirst($propertyName);
        if (method_exists($object, $getter)) {
            return $object->$getter();
        }
        return null;
    }
218986
public static function getFieldValue($item,$field,$objectFieldAccess=false)
    {
        if(is_array($item) && array_key_exists($field, $item)){
            return $item[$field];
        }else if(is_object($item)){
            return ObjectUtil::getPropertyValue($item, $field,$objectFieldAccess);
        }
        return null;
    }
671983
public static function toPropertyValue($obj,$propertyName,$value)
    {
        if(property_exists($obj, $propertyName)){
            $obj->$propertyName=$value;
        }
    }
661234
public static <T extends Object> T setFieldValue(Object obj, Field field, T fieldValue) {
        Assert.notNull(obj, "obj不能为空");
        Assert.notNull(field, "field不能为空");

        try {
            field.set(obj, fieldValue);
        } catch (IllegalAccessException e) {
            String msg = StringUtils.format("类型[{0}]的字段[{1}]不允许设置", obj.getClass(),
                field.getName());
            log.error(msg);
            throw new ReflectException(msg, e);
        }
        return fieldValue;
    }
694913
public static void setPrivateField(final Object obj, final String name, final Object value) {
        try {
            final Field field = obj.getClass().getDeclaredField(name);
            field.setAccessible(true);
            field.set(obj, value);
        } catch (final Exception ex) {
            throw new RuntimeException("Couldn't set field '" + name + "' in class '" + obj.getClass() + "'", ex);
        }
    }
932185
public static function recursiveGetObjectVars($obj) {
		$arr = array();
		$_arr = is_object($obj) ? get_object_vars($obj) : $obj;

		foreach ($_arr as $key => $val) {
			$val = (is_array($val) || is_object($val)) ? self::recursiveGetObjectVars($val) : $val;

			// Transform boolean into 1 or 0 to make it safe across all Opauth HTTP transports
			if (is_bool($val)) $val = ($val) ? 1 : 0;

			$arr[$key] = $val;
		}

		return $arr;
	}
1287493
public static ObjectNode getObj(ObjectNode obj, String fieldName) {
		return obj != null ? obj(obj.get(fieldName)) : null;
	}
1209084
public function setFieldValue($object, $field, $value)
    {
        $this->assertObjectInstance($object);

        return $this->getField($field)->set($object, $value);
    }
709436
public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null)
    {
        $varchar = DBField::create_field("Varchar", null, $fieldName);
        if ($data = $varchar->getDataByFieldName($this->getFaker())) {
            $varchar->setValue($data);
            return $varchar;
        }

        return parent::obj($fieldName);
    }
907007
private function getValue($object, \ReflectionProperty $property)
    {
        $value = null;

        if ($property->isPublic()) {
            $value = $property->getValue($object);
        } else {
            // Try to use accessor if property is not public
            $accessorName = $this->formatter->getPhpAccessor($property->getName(), false);
            $reflectedObject = new \ReflectionObject($object);
            $reflectedMethod = $reflectedObject->getMethod($accessorName);

            if (null !== $reflectedMethod) {
                $value = $reflectedMethod->invoke($object);
            }
        }

        return $value;
    }
796302
public static ArrayNode getArray(ObjectNode obj, String fieldName) {
		return obj == null ? null : array(obj.get(fieldName));
	}
1014948
public static function toArray(object $obj)
    {
        $array = (array)get_object_vars($obj);
        foreach ($array as $key => &$value) {
            if (is_object($value) && method_exists($value, 'toArray')) {
                $array[$key] = $value->toArray();
            } else if (is_array($value)) {
                foreach ($value as $deeper => $deepValue) {
                    if (is_object($deepValue) && method_exists($deepValue, 'toArray')) {
                        $value[$deeper] = $deepValue->toArray();
                    }
                }
            }
        }

        return $array;
    }
238927
public static Object getFieldVal(Object obj, String fieldName) {
        Field field;
        if (obj == null) {
            return null;
        }
        try {
            field = getField(obj.getClass(), fieldName);
            field.setAccessible(true);//取消安全机制限制
            return field.get(obj);
        } catch (SecurityException e) {
            e.printStackTrace();
            return null;
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return null;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return null;
        }
    }
1157180
public static Object getObjectFieldValue( Object object, String fieldName )
            throws UtilEvalError, ReflectError {
        if ( object instanceof This ) {
            return ((This) object).namespace.getVariable( fieldName );
        } else if( object == Primitive.NULL ) {
            throw new UtilTargetError( new NullPointerException(
                "Attempt to access field '" +fieldName+"' on null value" ) );
        } else {
            try {
                return getFieldValue(
                    object.getClass(), object, fieldName, false/*onlystatic*/);
            } catch ( ReflectError e ) {
                // no field, try property access
                if ( hasObjectPropertyGetter( object.getClass(), fieldName ) )
                    return getObjectProperty( object, fieldName );
                else
                    throw e;
            }
        }
    }
879653
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
		Field field = getField(obj.getClass(), fieldName);
		if (field == null) {
			throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + ']');
		}
		setField(obj, field, value);
	}
637322
public function resolve($obj, array &$context)
    {
        if (empty($obj)) {
            return $obj;
        } elseif (is_array($obj)) {
            $res = [];
            foreach ($obj as $key => $value) {
                $res[$key] = $this->resolve($value, $context);
            }

            return $res;
        } elseif (is_string($obj)) {
            $availableVars = array_merge($context, $context[self::CONTEXT_VARS]);

            return $this->evaluateStringOrExpression($obj, $availableVars);
        }

        return $obj;
    }