static public function getClassInfo($file) {
	    $buffer = file_get_contents($file);
	    $tokens = @token_get_all($buffer);
	    $class = $namespace = $buffer = '';
        for ($i=0;$i<count($tokens);$i++) {
            if ($tokens[$i][0] === T_NAMESPACE) {
                for ($j=$i+1;$j<count($tokens); $j++) {
                    if ($tokens[$j][0] === T_STRING) {
                        $namespace .= '\\'.$tokens[$j][1];
                    } else if ($tokens[$j] === '{' || $tokens[$j] === ';') {
                        break;
                    }
                }
            }

            if ($tokens[$i][0] === T_CLASS) {
                for ($j=$i+1;$j<count($tokens);$j++) {
                    if ($tokens[$j] === '{') {
                        if (!isset($tokens[$i+2][1])) {
                            error_log($file.' does not contain a valid class definition');
                            break(2);
                        } else {
                            $class = $tokens[$i+2][1];
                            break(2);
                        }
                    }
                }
            }
        }
        return array(
        	'ns' => $namespace,
            'class' => $class
        );
    }
static public function getClassInfo($file) {
	    $buffer = file_get_contents($file);
	    $tokens = @token_get_all($buffer);
	    $class = $namespace = $buffer = '';
        for ($i=0;$i<count($tokens);$i++) {
            if ($tokens[$i][0] === T_NAMESPACE) {
                for ($j=$i+1;$j<count($tokens); $j++) {
                    if ($tokens[$j][0] === T_STRING) {
                        $namespace .= '\\'.$tokens[$j][1];
                    } else if ($tokens[$j] === '{' || $tokens[$j] === ';') {
                        break;
                    }
                }
            }

            if ($tokens[$i][0] === T_CLASS) {
                for ($j=$i+1;$j<count($tokens);$j++) {
                    if ($tokens[$j] === '{') {
                        if (!isset($tokens[$i+2][1])) {
                            error_log($file.' does not contain a valid class definition');
                            break(2);
                        } else {
                            $class = $tokens[$i+2][1];
                            break(2);
                        }
                    }
                }
            }
        }
        return array(
        	'ns' => $namespace,
            'class' => $class
        );
    }
static public function getClassInfo ( $ file ) { $ buffer = file_get_contents ( $ file ) ; $ tokens = @ token_get_all ( $ buffer ) ; $ class = $ namespace = $ buffer = '' ; for ( $ i = 0 ; $ i < count ( $ tokens ) ; $ i ++ ) { if ( $ tokens [ $ i ] [ 0 ] === T_NAMESPACE ) { for ( $ j = $ i + 1 ; $ j < count ( $ tokens ) ; $ j ++ ) { if ( $ tokens [ $ j ] [ 0 ] === T_STRING ) { $ namespace .= '\\' . $ tokens [ $ j ] [ 1 ] ; } else if ( $ tokens [ $ j ] === '{' || $ tokens [ $ j ] === ';' ) { break ; } } } if ( $ tokens [ $ i ] [ 0 ] === T_CLASS ) { for ( $ j = $ i + 1 ; $ j < count ( $ tokens ) ; $ j ++ ) { if ( $ tokens [ $ j ] === '{' ) { if ( ! isset ( $ tokens [ $ i + 2 ] [ 1 ] ) ) { error_log ( $ file . ' does not contain a valid class definition' ) ; break ( 2 ) ; } else { $ class = $ tokens [ $ i + 2 ] [ 1 ] ; break ( 2 ) ; } } } } } return array ( 'ns' => $ namespace , 'class' => $ class ) ; }
Returns an array that contains namespace and name of the class defined in the file

Code losely based on http://stackoverflow.com/questions/7153000/get-class-name-from-file
by user http://stackoverflow.com/users/492901/netcoder

@param string file to anaylse
@return array
Returns an array that contains namespace and name of the class defined in the file