public function GetComponents($type)
    {
        $type = trim(str_replace("::", "\\", $type));
        
        $type_elements = explode("\\", $type);
        
        $components = new Element\TypeComponents();
        
        if(count($type_elements) > 1)
        {
            $last_element = $type_elements[count($type_elements)-1];
            unset($type_elements[count($type_elements)-1]);
            
            $prelast_element = $type_elements[count($type_elements)-1];
            
            $last_element_index = count($type_elements)-1;
            
            $namespace = "";
            
            for($ri=$last_element_index; $ri>=0; $ri--)
            {
                $namespace = implode("\\", $type_elements);
                
                if($this->HasNamespace($namespace))
                {
                    break;
                }
                
                $namespace = "";
                
                unset($type_elements[count($type_elements)-1]);
            }
            
            if($namespace)
                $components->namespace = $namespace;
            
            // If pre-last component isn't part of the namespace then
            // it must be a class.
            if(strstr($namespace, "\\$prelast_element") === false)
                $components->class = $prelast_element;
            
            $components->type = $last_element;
        }
        else
        {
            $components->type = $type;
        }
        
        return $components;
    }
public function GetComponents($type)
    {
        $type = trim(str_replace("::", "\\", $type));
        
        $type_elements = explode("\\", $type);
        
        $components = new Element\TypeComponents();
        
        if(count($type_elements) > 1)
        {
            $last_element = $type_elements[count($type_elements)-1];
            unset($type_elements[count($type_elements)-1]);
            
            $prelast_element = $type_elements[count($type_elements)-1];
            
            $last_element_index = count($type_elements)-1;
            
            $namespace = "";
            
            for($ri=$last_element_index; $ri>=0; $ri--)
            {
                $namespace = implode("\\", $type_elements);
                
                if($this->HasNamespace($namespace))
                {
                    break;
                }
                
                $namespace = "";
                
                unset($type_elements[count($type_elements)-1]);
            }
            
            if($namespace)
                $components->namespace = $namespace;
            
            // If pre-last component isn't part of the namespace then
            // it must be a class.
            if(strstr($namespace, "\\$prelast_element") === false)
                $components->class = $prelast_element;
            
            $components->type = $last_element;
        }
        else
        {
            $components->type = $type;
        }
        
        return $components;
    }
public function GetComponents ( $ type ) { $ type = trim ( str_replace ( "::" , "\\" , $ type ) ) ; $ type_elements = explode ( "\\" , $ type ) ; $ components = new Element \ TypeComponents ( ) ; if ( count ( $ type_elements ) > 1 ) { $ last_element = $ type_elements [ count ( $ type_elements ) - 1 ] ; unset ( $ type_elements [ count ( $ type_elements ) - 1 ] ) ; $ prelast_element = $ type_elements [ count ( $ type_elements ) - 1 ] ; $ last_element_index = count ( $ type_elements ) - 1 ; $ namespace = "" ; for ( $ ri = $ last_element_index ; $ ri >= 0 ; $ ri -- ) { $ namespace = implode ( "\\" , $ type_elements ) ; if ( $ this -> HasNamespace ( $ namespace ) ) { break ; } $ namespace = "" ; unset ( $ type_elements [ count ( $ type_elements ) - 1 ] ) ; } if ( $ namespace ) $ components -> namespace = $ namespace ; // If pre-last component isn't part of the namespace then // it must be a class. if ( strstr ( $ namespace , "\\$prelast_element" ) === false ) $ components -> class = $ prelast_element ; $ components -> type = $ last_element ; } else { $ components -> type = $ type ; } return $ components ; }
Get the components of a variable type as namespace and class by
checking the whole symbols object for matches.
@param string $type A plain variable type
eg: somens::sometype, somens::someclass::sometype.
@return \Peg\Lib\Definitions\Element\TypeComponents
Get the components of a variable type as namespace and class by checking the whole symbols object for matches .