public function prepareValue(Context $context)
    {
        $name  = $this->getName();
        $value = $this->parent->prepareValue($context)->getValue();

        if (is_object($value) && !$value instanceof \Closure) {
            if (method_exists($value, $name)) {
                return $this->asValue(call_user_func(array($value, $name)));
            } elseif (isset($value->$name)) {
                return $this->asValue($value->$name);
            } elseif ($value instanceof \ArrayAccess && $value->offsetExists($name)) {
                return $this->asValue($value->offsetGet($name));
            }
        } elseif (is_array($value) && array_key_exists($name, $value)) {
            return $this->asValue($value[$name]);
        }

        return $this->asValue($this->getValue());
    }
public function prepareValue(Context $context)
    {
        $name  = $this->getName();
        $value = $this->parent->prepareValue($context)->getValue();

        if (is_object($value) && !$value instanceof \Closure) {
            if (method_exists($value, $name)) {
                return $this->asValue(call_user_func(array($value, $name)));
            } elseif (isset($value->$name)) {
                return $this->asValue($value->$name);
            } elseif ($value instanceof \ArrayAccess && $value->offsetExists($name)) {
                return $this->asValue($value->offsetGet($name));
            }
        } elseif (is_array($value) && array_key_exists($name, $value)) {
            return $this->asValue($value[$name]);
        }

        return $this->asValue($this->getValue());
    }
public function prepareValue ( Context $ context ) { $ name = $ this -> getName ( ) ; $ value = $ this -> parent -> prepareValue ( $ context ) -> getValue ( ) ; if ( is_object ( $ value ) && ! $ value instanceof \ Closure ) { if ( method_exists ( $ value , $ name ) ) { return $ this -> asValue ( call_user_func ( array ( $ value , $ name ) ) ) ; } elseif ( isset ( $ value -> $ name ) ) { return $ this -> asValue ( $ value -> $ name ) ; } elseif ( $ value instanceof \ ArrayAccess && $ value -> offsetExists ( $ name ) ) { return $ this -> asValue ( $ value -> offsetGet ( $ name ) ) ; } } elseif ( is_array ( $ value ) && array_key_exists ( $ name , $ value ) ) { return $ this -> asValue ( $ value [ $ name ] ) ; } return $ this -> asValue ( $ this -> getValue ( ) ) ; }
Prepare a Value for this VariableProperty given the current Context.

To retrieve a Value, the parent Variable is first resolved given the
current context. Then, depending on its type, a method, property or
offset of the parent Value is returned.

If the parent Value is an object, and this VariableProperty name is
"bar", it will do a prioritized lookup for:

1. A method named `bar`
2. A public property named `bar`
3. ArrayAccess + offsetExists named `bar`

If it is an array:

1. Array index `bar`

Otherwise, return the default value for this VariableProperty.

@param Context $context The current Context

@return Value
Prepare a Value for this VariableProperty given the current Context .