src/SymbolTable.php
public function resolve($sym, $type=Symbol::T_NULL) {
        $val = $sym;
        if($sym instanceof \ECL\Symbol) {
           $val = $this->offsetGet($sym->getName());
           if($type == Symbol::T_NULL) {
               $type = $sym->getType();
           }
        }

        switch($type) {
        case Symbol::T_INT:
            $val = (int) $val;
            break;
        case Symbol::T_FLOAT:
            $val = (double) $val;
            break;
        case Symbol::T_STR:
            $val = (string) $val;
            break;
        case Symbol::T_LIST:
            if(!is_array($val)) {
                if(!($val instanceof \ECL\ResultSet)) {
                    throw new WrongTypeException($sym->getName());
                }
                $val = array_unique(\ECL\Util::pluck($val->getAll(), $sym->getPath()));
            }
            break;
        case Symbol::T_RES:
            if(!is_array($val)) {
                if(!($val instanceof \ECL\ResultSet)) {
                    throw new WrongTypeException($sym->getName());
                }
            } else {
                $val = new \ECL\ResultSet(array_map(function($x) { return ['value' => $x]; }, $val), ['value']);
            }
            break;
        }

        return $val;
    }
public function resolve($sym, $type=Symbol::T_NULL) {
        $val = $sym;
        if($sym instanceof \ECL\Symbol) {
           $val = $this->offsetGet($sym->getName());
           if($type == Symbol::T_NULL) {
               $type = $sym->getType();
           }
        }

        switch($type) {
        case Symbol::T_INT:
            $val = (int) $val;
            break;
        case Symbol::T_FLOAT:
            $val = (double) $val;
            break;
        case Symbol::T_STR:
            $val = (string) $val;
            break;
        case Symbol::T_LIST:
            if(!is_array($val)) {
                if(!($val instanceof \ECL\ResultSet)) {
                    throw new WrongTypeException($sym->getName());
                }
                $val = array_unique(\ECL\Util::pluck($val->getAll(), $sym->getPath()));
            }
            break;
        case Symbol::T_RES:
            if(!is_array($val)) {
                if(!($val instanceof \ECL\ResultSet)) {
                    throw new WrongTypeException($sym->getName());
                }
            } else {
                $val = new \ECL\ResultSet(array_map(function($x) { return ['value' => $x]; }, $val), ['value']);
            }
            break;
        }

        return $val;
    }
public function resolve ( $ sym , $ type = Symbol :: T_NULL ) { $ val = $ sym ; if ( $ sym instanceof \ ECL \ Symbol ) { $ val = $ this -> offsetGet ( $ sym -> getName ( ) ) ; if ( $ type == Symbol :: T_NULL ) { $ type = $ sym -> getType ( ) ; } } switch ( $ type ) { case Symbol :: T_INT : $ val = ( int ) $ val ; break ; case Symbol :: T_FLOAT : $ val = ( double ) $ val ; break ; case Symbol :: T_STR : $ val = ( string ) $ val ; break ; case Symbol :: T_LIST : if ( ! is_array ( $ val ) ) { if ( ! ( $ val instanceof \ ECL \ ResultSet ) ) { throw new WrongTypeException ( $ sym -> getName ( ) ) ; } $ val = array_unique ( \ ECL \ Util :: pluck ( $ val -> getAll ( ) , $ sym -> getPath ( ) ) ) ; } break ; case Symbol :: T_RES : if ( ! is_array ( $ val ) ) { if ( ! ( $ val instanceof \ ECL \ ResultSet ) ) { throw new WrongTypeException ( $ sym -> getName ( ) ) ; } } else { $ val = new \ ECL \ ResultSet ( array_map ( function ( $ x ) { return [ 'value' => $ x ] ; } , $ val ) , [ 'value' ] ) ; } break ; } return $ val ; }
Check if the input is a Symbol and resolve it if so.
@param Symbol|mixed $sym A symbol object or builtin type.
@param int $type Data type.
@return mixed A resolved symbol or the passed in data.
Check if the input is a Symbol and resolve it if so .