public static function analyze($context, $var) {
        $levels = 0;
        $spvar = false;

        if (isset($var[0])) {
            // trace to parent
            if (!is_string($var[0]) && is_int($var[0])) {
                $levels = array_shift($var);
            }
        }

        if (isset($var[0])) {
            // handle @root, @index, @key, @last, etc
            if ($context['flags']['spvar']) {
                if (substr($var[0], 0, 1) === '@') {
                    $spvar = true;
                    $var[0] = substr($var[0], 1);
                }
            }
        }

        return array($levels, $spvar, $var);
    }
public static function analyze($context, $var) {
        $levels = 0;
        $spvar = false;

        if (isset($var[0])) {
            // trace to parent
            if (!is_string($var[0]) && is_int($var[0])) {
                $levels = array_shift($var);
            }
        }

        if (isset($var[0])) {
            // handle @root, @index, @key, @last, etc
            if ($context['flags']['spvar']) {
                if (substr($var[0], 0, 1) === '@') {
                    $spvar = true;
                    $var[0] = substr($var[0], 1);
                }
            }
        }

        return array($levels, $spvar, $var);
    }
public static function analyze ( $ context , $ var ) { $ levels = 0 ; $ spvar = false ; if ( isset ( $ var [ 0 ] ) ) { // trace to parent if ( ! is_string ( $ var [ 0 ] ) && is_int ( $ var [ 0 ] ) ) { $ levels = array_shift ( $ var ) ; } } if ( isset ( $ var [ 0 ] ) ) { // handle @root, @index, @key, @last, etc if ( $ context [ 'flags' ] [ 'spvar' ] ) { if ( substr ( $ var [ 0 ] , 0 , 1 ) === '@' ) { $ spvar = true ; $ var [ 0 ] = substr ( $ var [ 0 ] , 1 ) ; } } } return array ( $ levels , $ spvar , $ var ) ; }
Analyze an expression

@param array<string,array|string|integer> $context Current context
@param array<array|string|integer> $var variable parsed path

@return array<integer|boolean|array> analyzed result

@expect array(0, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(0, 'foo')
@expect array(1, false, array('foo')) when input array('flags' => array('spvar' => 0)), array(1, 'foo')
Analyze an expression