Parses a PHP File and returns nested Array of collected Information.
@access		public
@param		string		$fileName		File Name of PHP File to parse
@param		string		$innerPath		Base Path to File to be removed in Information
@return		array
746
public function parseFile( $fileName, $innerPath )
	{
		$content		= FS_File_Reader::load( $fileName );
		if( !Alg_Text_Unicoder::isUnicode( $content ) )
			$content		= Alg_Text_Unicoder::convertToUnicode( $content );


		$lines			= explode( "\n", $content );
		$fileBlock		= NULL;
		$openClass		= FALSE;
		$function		= NULL;
		$functionBody	= array();
		$file			= new ADT_PHP_File;
		$file->setBasename( basename( $fileName ) );
		$file->setPathname( substr( str_replace( "\\", "/", $fileName ), strlen( $innerPath ) ) );
		$file->setUri( str_replace( "\\", "/", $fileName ) );
	
		$level	= 0;
		$class	= NULL;
		do
		{
			$line	= trim( array_shift( $lines ) );
#			remark( ( $openClass ? "I" : "O" )." :: ".$level." :: ".$this->lineNumber." :: ".$line );
			$this->lineNumber ++;
			if( preg_match( "@^(<\?(php)?)|((php)?\?>)$@", $line ) )
				continue;
			
			if( preg_match( '@}$@', $line ) )
				$level--;

			if( $line == "/**" && $level < 2 )
			{
				$list	= array();
				while( !preg_match( "@\*?\*/\s*$@", $line ) )
				{
					$list[]	= $line;
					$line	= trim( array_shift( $lines ) );
					$this->lineNumber ++;
				}
				array_unshift( $lines, $line );
				$this->lineNumber --;
				if( $list )
				{
					$this->openBlocks[]	= $this->parseDocBlock( $list );
					if( !$fileBlock && !$class )
					{
						$fileBlock	= array_shift( $this->openBlocks );
						array_unshift( $this->openBlocks, $fileBlock );
						$this->decorateCodeDataWithDocData( $file, $fileBlock );
					}
				}
				continue;
			}
			if( !$openClass )
			{
				if( preg_match( $this->regexClass, $line, $matches ) )
				{
					$parts	= array_slice( $matches, -1 );
					while( !trim( array_pop( $parts ) ) )
						array_pop( $matches );
					$class	= $this->parseClassOrInterface( $file, $matches );
					$openClass	= TRUE;
				}
				else if( preg_match( $this->regexMethod, $line, $matches ) )
				{
					$openClass	= FALSE;
					$function	= $this->parseFunction( $file, $matches );
					$file->setFunction( $function );
				}
			}
			else
			{
				if( preg_match( $this->regexClass, $line, $matches ) )
				{
					if( $class instanceof ADT_PHP_Class )
						$file->addClass( $class );
					else if( $class instanceof ADT_PHP_Interface )
						$file->addInterface( $class );
					array_unshift( $lines, $line );
					$this->lineNumber --;
					$openClass	= FALSE;
					$level		= 1;
					continue;
				}
				if( preg_match( $this->regexMethod, $line, $matches ) )
				{
					$method		= $this->parseMethod( $class, $matches );
					$function	= $matches[6];
					$class->setMethod( $method );
				}
				else if( $level <= 1 )
				{
					if( preg_match( $this->regexDocVariable, $line, $matches ) )
					{
						if( $openClass && $class )
							$this->varBlocks[$class->getName()."::".$matches[2]]	= $this->parseDocMember( $matches );
						else
							$this->varBlocks[$matches[2]]	= $this->parseDocVariable( $matches );
					}
					else if( preg_match( $this->regexVariable, $line, $matches ) )
					{
						$name		= $matches[4];
						if( $openClass && $class )
						{
							$key		= $class->getName()."::".$name;
							$varBlock	= isset( $this->varBlocks[$key] ) ? $this->varBlocks[$key] : NULL;
							$variable	= $this->parseMember( $class, $matches, $varBlock ); 
							$class->setMember( $variable );
						}
						else
						{
							remark( "Parser Error: found var after class -> not handled yet" );
/*							$key		= $name;
							$varBlock	= isset( $this->varBlocks[$key] ) ? $this->varBlocks[$key] : NULL;
							$variable	= $this->parseMember( $matches, $varBlock );*/
						}
					}
				}
				else if( $level > 1 && $function )
				{
					$functionBody[$function][]	= $line;
				}
			}
			if( preg_match( '@{$@', $line ) )
				$level++;
			if( $level < 1 && !preg_match( $this->regexClass, $line, $matches ) )
				$openClass	= FALSE;
		}
		while( $lines );

		$file->setSourceCode( $content );
		if( $class )
		{
			foreach( $class->getMethods() as $methodName => $method )
				if( isset( $functionBody[$methodName] ) )
					$method->setSourceCode( $functionBody[$methodName] );
			if( $class instanceof ADT_PHP_Class )
				$file->addClass( $class );
			else if( $class instanceof ADT_PHP_Interface )
				$file->addInterface( $class );
		}
		return $file;
	}
381461
public function parseFile( $fileName, $innerPath )
	{
		$content		= FS_File_Reader::load( $fileName );
		if( !Alg_Text_Unicoder::isUnicode( $content ) )
			$content		= Alg_Text_Unicoder::convertToUnicode( $content );

		$listClasses	= get_declared_classes();													//  list builtin Classes
		$listInterfaces	= get_declared_interfaces();												//  list builtin Interfaces
		require_once( $fileName );
		$listClasses	= array_diff( get_declared_classes(), $listClasses );						//  get only own Classes
		$listInterfaces	= array_diff( get_declared_interfaces(), $listInterfaces );					//  get only own Interfaces

		$file			= new ADT_PHP_File;
		$file->setBasename( basename( $fileName ) );
		$file->setPathname( substr( str_replace( "\\", "/", $fileName ), strlen( $innerPath ) ) );
		$file->setUri( str_replace( "\\", "/", $fileName ) );
		$file->setSourceCode( $content );

		//  --  READING CLASSES  --  //
		$countClasses	= count( $listClasses );													//  count own Classes
		if( $countClasses )
		{
			if( $this->verbose )
				remark( 'Parsing Classes ('.$countClasses.'):'.PHP_EOL );
			$listClasses	= $this->readFromClassList( $listClasses );
			$this->application->updateStatus( 'Done.', $countClasses, $countClasses );
		}
		foreach( $listClasses as $class )
			if( $class instanceof ADT_PHP_Class )
				$file->addClass( $class );

		//  --  READING INTERFACES  --  //
		$countInterfaces	= count( $listInterfaces );												//  count own Interfaces
		if( $countInterfaces )
		{
			if( $this->verbose )
				remark( 'Parsing Interfaces ('.$countInterfaces.'):'.PHP_EOL );
			$listInterfaces	= $this->readFromClassList( $listInterfaces );
			$this->application->updateStatus( 'Done.', $countInterfaces, $countInterfaces );
		}
		foreach( $listInterfaces as $interface )
			if( $interface instanceof ADT_PHP_Interface )
				$file->addInterface( $interface );

/*		$functionBody	= array();
		$lines			= explode( "\n", $content );
		$fileBlock		= NULL;
		$openClass		= FALSE;
		$function		= NULL;
	
		$level	= 0;
		$class	= NULL;
		if( $class )
		{
			foreach( $class->getMethods() as $methodName => $method )
				if( isset( $functionBody[$methodName] ) )
					$method->setSourceCode( $functionBody[$methodName] );
		}*/
		return $file;
	}
705549
private function parseFileName($path, $file) {
		$result = Array();
		if (is_dir($path.'/'.$file)) {
			$result['name'] = $file;
			$result['ext'] = 'dir';
			$result['is_dir'] = 1;
		} else {
			$pos = strrpos($file, '.');
			$result['name'] = substr($file, 0, $pos);
			$result['ext'] = substr($file, $pos + 1);
			$result['is_dir'] = 0;
		}
		return $result;
	}
949954
protected function getFiles($basePath, $path = null, &$files = array())
    {
        if (! is_dir($path))
            return null;
        if (substr($path, strlen($path) - 1) != '/')
            $path .= '/';
        $handle = opendir($path);
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                $path2 = $path . $file;
                if (is_dir($path2)) {
                    $this->getFiles($basePath, $path2, $files);
                } else {
                    $extension = strtolower(substr(strrchr($file, '.'), 1));
                    if (in_array($extension, $this->accept)) {
                        $files[] = array(
                            'object' => $this->normalizeWebPath($path2)
                        );
                    }
                }
            }
        }
        return $files;
    }
456048
public function getFilePath($filename, $basedir, $relative)
    {
        // Validating the 'file' information
        $files = (array) $filename;

        // Processing the file information
        foreach ($files as $index => $file) {
            $absolutefilename = (($relative === false) ? ($basedir . PhingFile::$separator) : '');
            $absolutefilename .= $file;
            if ($relative === false) {
                $files[$index] = (new FileUtils())->normalize($absolutefilename);
            } else {
                $files[$index] = $absolutefilename;
            }
        }

        return (is_array($filename) ? $files : $files[0]);
    }
841726
public static function theme($innerPath = '')
    {
        $path = untrailingslashit(apply_filters('baobab/paths/theme', get_stylesheet_directory()));

        if (!empty($innerPath)) {
            $innerPath = untrailingslashit($innerPath);
            $path .= '/' . $innerPath;
        }

        return $path;
    }
1170208
public static function GetXmlReaderInstanceForSourceFile($filePath, $fileName = null) {
        if (!isset($fileName)) {
            $fileName = substr($filePath, strrpos($filePath, "/") + 1);
        }
        $xmlFilesLoaded = apc_fetch(\Puzzlout\Framework\Enums\CacheKeys::XmlFilesLoaded);
        if (array_key_exists($fileName, $xmlFilesLoaded)) {
            $this->xmlReader = $xmlFilesLoaded[$fileName];
        } else {
            $this->xmlReader = isset($fileName) ?
                    new \Puzzlout\Framework\Core\XmlReader(null, $configFileName) :
                    new \Puzzlout\Framework\Core\XmlReader($filePath);
            $xmlFilesLoaded[$configFileName] = $this->xmlReader;
            apc_add(\Puzzlout\Framework\Enums\CacheKeys::XmlFilesLoaded, $xmlFilesLoaded);
        }
    }
822107
public function parse($path)
    {
        $data = @parse_ini_file($path, true);

        if (!$data) {
            $error = error_get_last();

            // parse_ini_file() may return NULL but set no error if the file contains no parsable data
            if (!is_array($error)) {
                $error["message"] = "No parsable content in file.";
            }

            // if file contains no parsable data, no error is set, resulting in any previous error
            // persisting in error_get_last(). in php 7 this can be addressed with error_clear_last()
            if (function_exists("error_clear_last")) {
                error_clear_last();
            }

            throw new ParseException($error);
        }

        return $this->expandDottedKey($data);
    }
570770
protected function parseFile(string $filePath)
    {
        $lexer = new Lexer([
            'usedAttributes' => [
                'comments', 'startLine', 'endLine',
            ],
        ]);

        $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7, $lexer);

        try {
            $statements = $parser->parse(file_get_contents($filePath));
        } catch (Error $e) {
            return null;
        }

        return $statements;
    }
672706
public static function within($listenerPath, $basePath)
    {
        return collect(static::getListenerEvents(
            (new Finder)->files()->in($listenerPath), $basePath
        ))->mapToDictionary(function ($event, $listener) {
            return [$event => $listener];
        })->all();
    }
1318821
public function fromString($fileName)
    {
        $fileNameArray = $fileName ? explode('.', $fileName) : array();
        if(!$fileNameArray || count($fileNameArray) < 2){
            throw new Exception\InvalidArgumentException('File name not correct');
        }

        $fileExt = array_pop($fileNameArray);
        $fileNameMain = implode('.', $fileNameArray);
        $fileNameArray = explode(',', $fileNameMain);
        if(!$fileExt || !$fileNameArray || !$fileNameArray[0]){
            throw new Exception\InvalidArgumentException('File name not correct');
        }

        //remove empty elements
        $fileNameArray = array_filter($fileNameArray);
        $fileNameMain = array_shift($fileNameArray);
        $this->setExtension($fileExt);
        $this->setFilename($fileNameMain);

        $args = $fileNameArray;
        $argMapping = $this->argMapping;
        $params = array();
        foreach($args as $arg){
            if(!$arg){
                continue;
            }
            if(strlen($arg) < 3 || strpos($arg, '_') !== 1){
                continue;
            }
            $argKey = $arg{0};
            if(isset($argMapping[$argKey])){
                $arg = substr($arg, 2);
                if($arg !== ''){
                    $params[$argMapping[$argKey]] = $arg;
                }
            }
        }

        $this->fromArray($params);
        return $params;
    }
1295742
public function parseFile($path)
    {
        $factory = new ParserFactory();
        $parser  = $factory->create(ParserFactory::PREFER_PHP7);

        try {
            $statements = $parser->parse($this->loadFile($path));
        } catch (Error $e) {
            throw new \RuntimeException(sprintf('Failed to parse %s file due to parse error: %s', $path, $e->getMessage()), 0, $e);
        }
        if ($statements === null) {
            throw new \RuntimeException(sprintf('Failed to parse %s', $path));
        }

        return $statements;
    }
712047
public function readFile($filePath = null, array $options = [])
    {
        $filePath = empty($filePath)
            ? $this->filePath
            : $filePath;

        $result = new ArrayIterator();

        if (false !== ($xml = simplexml_load_file($filePath))) {
            $contents = json_decode(json_encode($xml), true); // force to array conversion

            if (count($contents) == 1) {
                $contents = reset($contents);
            }

            if (json_last_error() === JSON_ERROR_NONE) {
                foreach ($contents as $content) {
                    $result[] = new SplArrayObject($content);
                }
            }
        }

        return $result;
    }
966288
private function extractOneFileInternal($fileName, $path)
    {
        $tmpPath = str_replace($this->getInternalPath(), '', $fileName);

        // We need to create the directory first in case it doesn't exist
        $dir = pathinfo($path.DIRECTORY_SEPARATOR.$tmpPath, PATHINFO_DIRNAME);
        if (!$this->file->exists($dir) && !$this->file->makeDirectory($dir, 0755, true, true)) {
            throw new \RuntimeException('Failed to create folders');
        }

        $toPath = $path.DIRECTORY_SEPARATOR.$tmpPath;
        $fileStream = $this->getRepository()->getFileStream($fileName);
        $this->getFileHandler()->put($toPath, $fileStream);
    }
1034576
public static function parseFile($fileName, $fileContent = null)
    {
        $fileName = PathResolver::realpath($fileName);
        if (isset(self::$parsedFiles[$fileName]) && !isset($fileContent)) {
            return self::$parsedFiles[$fileName];
        }

        if (isset(self::$maximumCachedFiles) && (count(self::$parsedFiles) === self::$maximumCachedFiles)) {
            array_shift(self::$parsedFiles);
        }

        if (!isset($fileContent)) {
            $fileContent = file_get_contents($fileName);
        }
        $treeNode = self::$parser->parse($fileContent);
        $treeNode = self::$traverser->traverse($treeNode);

        self::$parsedFiles[$fileName] = $treeNode;

        return $treeNode;
    }
781209
public function parse($path)
    {
        libxml_use_internal_errors(true);

        $data = simplexml_load_file($path, null, LIBXML_NOERROR);

        if ($data === false) {
            $errors      = libxml_get_errors();
            $latestError = array_pop($errors);
            $error       = array(
                'message' => $latestError->message,
                'type'    => $latestError->level,
                'code'    => $latestError->code,
                'file'    => $latestError->file,
                'line'    => $latestError->line,
            );
            throw new ParseException($error);
        }

        $data = json_decode(json_encode($data), true);

        return $data;
    }
155176
public static function views($innerPath = '')
    {
        $path = 'app/views';

        if (!empty($innerPath)) {
            $innerPath = untrailingslashit($innerPath);
            $path .= '/' . $innerPath;
        }

        return apply_filters('baobab/paths/views', self::theme($path), $innerPath);
    }