public function assignInScope($value, $scope)
    {
        if (!is_string($scope)) {
            $this->triggerError('Assignments must be done into strings, (' . gettype($scope) . ') ' . var_export($scope, true) . ' given', E_USER_ERROR);
        }
        if (strstr($scope, '.') === false && strstr($scope, '->') === false) {
            $this->scope[$scope] = $value;
        } else {
            // TODO handle _root/_parent scopes ?
            preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m);

            $cur  = &$this->scope;
            $last = array(
                array_pop($m[1]),
                array_pop($m[2])
            );

            foreach ($m[1] as $k => $sep) {
                if ($sep === '.' || $sep === '[' || $sep === '') {
                    if (is_array($cur) === false) {
                        $cur = array();
                    }
                    $cur = &$cur[$m[2][$k]];
                } elseif ($sep === '->') {
                    if (is_object($cur) === false) {
                        $cur = new stdClass();
                    }
                    $cur = &$cur->{$m[2][$k]};
                } else {
                    return false;
                }
            }

            if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') {
                if (is_array($cur) === false) {
                    $cur = array();
                }
                $cur[$last[1]] = $value;
            } elseif ($last[0] === '->') {
                if (is_object($cur) === false) {
                    $cur = new stdClass();
                }
                $cur->{$last[1]} = $value;
            } else {
                return false;
            }
        }
    }
public function assignInScope($value, $scope)
    {
        if (!is_string($scope)) {
            $this->triggerError('Assignments must be done into strings, (' . gettype($scope) . ') ' . var_export($scope, true) . ' given', E_USER_ERROR);
        }
        if (strstr($scope, '.') === false && strstr($scope, '->') === false) {
            $this->scope[$scope] = $value;
        } else {
            // TODO handle _root/_parent scopes ?
            preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m);

            $cur  = &$this->scope;
            $last = array(
                array_pop($m[1]),
                array_pop($m[2])
            );

            foreach ($m[1] as $k => $sep) {
                if ($sep === '.' || $sep === '[' || $sep === '') {
                    if (is_array($cur) === false) {
                        $cur = array();
                    }
                    $cur = &$cur[$m[2][$k]];
                } elseif ($sep === '->') {
                    if (is_object($cur) === false) {
                        $cur = new stdClass();
                    }
                    $cur = &$cur->{$m[2][$k]};
                } else {
                    return false;
                }
            }

            if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') {
                if (is_array($cur) === false) {
                    $cur = array();
                }
                $cur[$last[1]] = $value;
            } elseif ($last[0] === '->') {
                if (is_object($cur) === false) {
                    $cur = new stdClass();
                }
                $cur->{$last[1]} = $value;
            } else {
                return false;
            }
        }
    }
public function assignInScope ( $ value , $ scope ) { if ( ! is_string ( $ scope ) ) { $ this -> triggerError ( 'Assignments must be done into strings, (' . gettype ( $ scope ) . ') ' . var_export ( $ scope , true ) . ' given' , E_USER_ERROR ) ; } if ( strstr ( $ scope , '.' ) === false && strstr ( $ scope , '->' ) === false ) { $ this -> scope [ $ scope ] = $ value ; } else { // TODO handle _root/_parent scopes ? preg_match_all ( '#(\[|->|\.)?([^.[\]-]+)\]?#i' , $ scope , $ m ) ; $ cur = & $ this -> scope ; $ last = array ( array_pop ( $ m [ 1 ] ) , array_pop ( $ m [ 2 ] ) ) ; foreach ( $ m [ 1 ] as $ k => $ sep ) { if ( $ sep === '.' || $ sep === '[' || $ sep === '' ) { if ( is_array ( $ cur ) === false ) { $ cur = array ( ) ; } $ cur = & $ cur [ $ m [ 2 ] [ $ k ] ] ; } elseif ( $ sep === '->' ) { if ( is_object ( $ cur ) === false ) { $ cur = new stdClass ( ) ; } $ cur = & $ cur -> { $ m [ 2 ] [ $ k ] } ; } else { return false ; } } if ( $ last [ 0 ] === '.' || $ last [ 0 ] === '[' || $ last [ 0 ] === '' ) { if ( is_array ( $ cur ) === false ) { $ cur = array ( ) ; } $ cur [ $ last [ 1 ] ] = $ value ; } elseif ( $ last [ 0 ] === '->' ) { if ( is_object ( $ cur ) === false ) { $ cur = new stdClass ( ) ; } $ cur -> { $ last [ 1 ] } = $ value ; } else { return false ; } } }
Assign the value to the given variable.

@param mixed  $value the value to assign
@param string $scope the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")

@return bool true if assigned correctly or false if a problem occured while parsing the var string
Assign the value to the given variable .