protected function generateNamespaceContext(array & $tokens)
	{
		$namespaceContext = new NamespaceContext();
		
		for($size = count($tokens), $i = 0; $i < $size; $i++)
		{
			if(is_array($tokens[$i]))
			{
				switch($tokens[$i][0])
				{
					case T_NAMESPACE:
						
						$namespace = '';
						
						for($i++; $i < $size; $i++)
						{
							if(is_array($tokens[$i]))
							{
								switch($tokens[$i][0])
								{
									case T_WHITESPACE:
									case T_COMMENT:
									case T_DOC_COMMENT:
										continue 2;
									case T_NS_SEPARATOR:
									case T_STRING:
										$namespace .= $tokens[$i][1];
										continue 2;
								}
							}
							
							break;
						}
						
						$namespaceContext = new NamespaceContext($namespace);
						
						break;
					case T_USE:
						do
						{
							$i++;
							$this->readImport($tokens, $i, $namespaceContext);
						}
						while($tokens[$i] == ',');
						
						break;
					case T_CLASS:
					case T_INTERFACE:
					case T_TRAIT:
						// Abort namespace detection as soon as code declaring a type is reached.
						break 2;
				}
			}
		}
		
		return $namespaceContext;
	}
protected function generateNamespaceContext(array & $tokens)
	{
		$namespaceContext = new NamespaceContext();
		
		for($size = count($tokens), $i = 0; $i < $size; $i++)
		{
			if(is_array($tokens[$i]))
			{
				switch($tokens[$i][0])
				{
					case T_NAMESPACE:
						
						$namespace = '';
						
						for($i++; $i < $size; $i++)
						{
							if(is_array($tokens[$i]))
							{
								switch($tokens[$i][0])
								{
									case T_WHITESPACE:
									case T_COMMENT:
									case T_DOC_COMMENT:
										continue 2;
									case T_NS_SEPARATOR:
									case T_STRING:
										$namespace .= $tokens[$i][1];
										continue 2;
								}
							}
							
							break;
						}
						
						$namespaceContext = new NamespaceContext($namespace);
						
						break;
					case T_USE:
						do
						{
							$i++;
							$this->readImport($tokens, $i, $namespaceContext);
						}
						while($tokens[$i] == ',');
						
						break;
					case T_CLASS:
					case T_INTERFACE:
					case T_TRAIT:
						// Abort namespace detection as soon as code declaring a type is reached.
						break 2;
				}
			}
		}
		
		return $namespaceContext;
	}
protected function generateNamespaceContext ( array & $ tokens ) { $ namespaceContext = new NamespaceContext ( ) ; for ( $ size = count ( $ tokens ) , $ i = 0 ; $ i < $ size ; $ i ++ ) { if ( is_array ( $ tokens [ $ i ] ) ) { switch ( $ tokens [ $ i ] [ 0 ] ) { case T_NAMESPACE : $ namespace = '' ; for ( $ i ++ ; $ i < $ size ; $ i ++ ) { if ( is_array ( $ tokens [ $ i ] ) ) { switch ( $ tokens [ $ i ] [ 0 ] ) { case T_WHITESPACE : case T_COMMENT : case T_DOC_COMMENT : continue 2 ; case T_NS_SEPARATOR : case T_STRING : $ namespace .= $ tokens [ $ i ] [ 1 ] ; continue 2 ; } } break ; } $ namespaceContext = new NamespaceContext ( $ namespace ) ; break ; case T_USE : do { $ i ++ ; $ this -> readImport ( $ tokens , $ i , $ namespaceContext ) ; } while ( $ tokens [ $ i ] == ',' ) ; break ; case T_CLASS : case T_INTERFACE : case T_TRAIT : // Abort namespace detection as soon as code declaring a type is reached. break 2 ; } } } return $ namespaceContext ; }
Read namespace context from the given PHP source tokens.

@param array $tokens
@return NamespaceContext
Read namespace context from the given PHP source tokens .