protected function getReflection($filepath)
    {
        // Regexp instead of tokenizer because of the bad perf @link > https://gist.github.com/1886076
        if (!preg_match('#^namespace\s+(.+?);.*class\s+(\w+).+;$#sm', file_get_contents($filepath), $captured)) {
            throw new \RuntimeException('Unable to find namespace or class declaration');
        }

        $fqcn = $captured[1].'\\'.$captured[2];

        try {
            $reflectedClass = new \ReflectionClass($fqcn);
        } catch (\ReflectionException $exception) {
            $this->registerAutoload($fqcn, $filepath);
            $reflectedClass = new \ReflectionClass($fqcn);
        }

        return $reflectedClass;
    }
protected function getReflection($filepath)
    {
        // Regexp instead of tokenizer because of the bad perf @link > https://gist.github.com/1886076
        if (!preg_match('#^namespace\s+(.+?);.*class\s+(\w+).+;$#sm', file_get_contents($filepath), $captured)) {
            throw new \RuntimeException('Unable to find namespace or class declaration');
        }

        $fqcn = $captured[1].'\\'.$captured[2];

        try {
            $reflectedClass = new \ReflectionClass($fqcn);
        } catch (\ReflectionException $exception) {
            $this->registerAutoload($fqcn, $filepath);
            $reflectedClass = new \ReflectionClass($fqcn);
        }

        return $reflectedClass;
    }
protected function getReflection ( $ filepath ) { // Regexp instead of tokenizer because of the bad perf @link > https://gist.github.com/1886076 if ( ! preg_match ( '#^namespace\s+(.+?);.*class\s+(\w+).+;$#sm' , file_get_contents ( $ filepath ) , $ captured ) ) { throw new \ RuntimeException ( 'Unable to find namespace or class declaration' ) ; } $ fqcn = $ captured [ 1 ] . '\\' . $ captured [ 2 ] ; try { $ reflectedClass = new \ ReflectionClass ( $ fqcn ) ; } catch ( \ ReflectionException $ exception ) { $ this -> registerAutoload ( $ fqcn , $ filepath ) ; $ reflectedClass = new \ ReflectionClass ( $ fqcn ) ; } return $ reflectedClass ; }
Extract the fully qualified namespace and return a ReflectionClass object

@param string $filepath Path to the file to parse

@return ReflectionClass
Extract the fully qualified namespace and return a ReflectionClass object