Extracts the file information as flat array.

@param array $files File array to parse

@author Benjamin Carl <opensource@clickalicious.de>

@return array Resulting array
5575
protected function extract(array $files)
    {
        foreach ($files as $key => $file) {
            if ($file instanceof Doozr_Request_File) {

                // Simple security layer
                $filename = $this->cleanFilename($file->getClientFilename());

                // @todo Move to a basic validation applied always for files if enabled in configuration.
                #$mediaType = $this->getMimeTypeByExtension(pathinfo($filename)['extension']);

                /* @var Doozr_Request_File $file */
                // Put everything in a simple array structure ...
                $files[$key] = [
                    'name'     => $filename,
                    'type'     => $file->getClientMediaType(),
                    'tmp_name' => $file->getTemporaryName(),
                    'error'    => $file->getError(),
                    'size'     => $file->getSize(),
                    'emulated' => false,
                ];
            } else {
                $files[$key] = $this->extract($file);
            }
        }

        return $files;
    }
905331
public function getConflicts(array $files)
    {
        $conflicts = array();

        // flip so the files are hash keys to speed lookups
        $files = array_flip($files);

        $fileInfo = $this->getFileInfo();

        foreach ($files as $file => $garbage) {
            if (array_key_exists($file, $fileInfo)) {
                $fileFileInfo = $fileInfo[$file];
                if (isset($fileFileInfo['Conflicts'])
                    && is_array($fileFileInfo['Conflicts'])
                ) {
                    foreach ($fileFileInfo['Conflicts'] as $conflict) {
                        if (array_key_exists($conflict, $files)) {
                            if (!isset($conflicts[$file])) {
                                $conflicts[$file] = array();
                            }
                            $conflicts[$file][] = $conflict;
                        }
                    }
                }
            }
        }

        return $conflicts;
    }
1075524
private static function normaliseMultiFile(array $files)
    {
        $output = [];
        /* Second parcour. */
        foreach (array_keys($files) as $value) {
            self::normaliseFile($output, $files[ $value ], $value);
        }

        return $output;
    }
875144
public function handleMultipleFiles(array $files)
    {
        foreach ($files as $file) {
            $this->handleSingleFile($file);
        }
        return $this->getUploadedFilesList();
    }
240149
public function getRelatedFiles(array $files = [])
    {
        if (in_array($this->fileName, $files)) {
            return $files;
        }

        $files[] = $this->fileName;
        foreach ($this->properties as $property) {
            if (in_array($property->getType(), [Reflection\Property::TYPE_COLLECTION, Reflection\Property::TYPE_ENTITY])) {
                $files += self::load($property->getTypeOption())->getRelatedFiles($files);
            }
        }
        return $files;
    }
514221
private static function normaliseUplaod(array $files)
    {
        $output = [];
        foreach ($files as $key => $value) {
            if ($value instanceof UploadedFileInterface) {
                $output[ $key ] = $value;
            } elseif (is_array($value) && isset($value[ 'tmp_name' ])) {
                $output[ $key ] = UploadedFile::create($value);
            } elseif (is_array($value)) {
                $output[ $key ] = self::normaliseUplaod($value);
            } else {
                throw new \InvalidArgumentException('The input parameter is not in the correct format.');
            }
        }

        return $output;
    }
67051
protected function convertTo($type, array $files) {
		$res = [];
		foreach($files as $name=>$file) {
			if(is_array($file))
				$res[$name] = $this->convertTo($type, $file);
			else
				$res[$name][$type] = $file;
		}

		return $res;
	}
311502
protected function loadGuideStructure($files)
    {
        $chapters = [];
        foreach ($files as $file) {
            $contents = file_get_contents($file);
            if (basename($file) == 'README.md') {
                $indexAnalyzer = new IndexFileAnalyzer();
                $chapters = $indexAnalyzer->analyze($contents);
                break;
            }
            if (preg_match("/^(.*)\n=+/", $contents, $matches)) {
                $headlines[$file] = $matches[1];
            } else {
                $headlines[$file] = basename($file);
            }

        }
        return $chapters;
    }
1041069
public function createUploadedFilesFromArray(array $files)
    {
        $uploadedFiles = [];

        if (isset($files['tmp_name']) && ! is_array($files['tmp_name'])) {
            $uploadedFiles[] = $this->createUploadedFile(
                $files['tmp_name'],
                $files['size'],
                $files['error'],
                $files['name'],
                $files['type']
            );
        } elseif (isset($files['tmp_name']) && is_array($files['tmp_name'])) {
            foreach ($files['tmp_name'] as $key => $file) {
                $uploadedFiles[] = $this->createUploadedFile(
                    $file,
                    $files['size'][$key],
                    $files['error'][$key],
                    $files['name'][$key],
                    $files['type'][$key]
                );
            }
        } else {
            foreach ($files as $key => $value) {
                $uploadedFiles[$key] = $this->createUploadedFilesFromArray($value);
            }
        }

        return $uploadedFiles;
    }
1202483
protected function parseCombinedFile($file)
    {
        // Array with path and type keys
        if (is_array($file) && isset($file['path']) && isset($file['type'])) {
            return array($file['path'], $file['type']);
        }

        // Extract value from indexed array
        if (is_array($file)) {
            $path = array_shift($file);

            // See if there's a type specifier
            if ($file) {
                $type = array_shift($file);
                return array($path, $type);
            }

            // Otherwise convent to string
            $file = $path;
        }

        $type = File::get_file_extension($file);
        return array($file, $type);
    }
988800
protected function normalizeFiles($files)
    {
        foreach ($files as $name => $info) {
            $this->loadFilesRecursive($name, $info['name'], $info['tmp_name'], $info['type'], $info['size'], $info['error']);
        }

        return $this->_files;
    }
1318411
public static function css_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n/* Cannot read CSS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."*/\n\n";
                continue;
            }
            $compressed[] = self::css($content);
        }

        return implode("\n", $compressed);
    }
484220
public static function getFirstExistingFileArray($files = [])
    {
        foreach ($files as $file) {
            if (file_exists(\Yii::getAlias($file))) {
                return $file;
            }
        }

        return null;
    }
1345206
protected function filter($files) {
		foreach ($files as $i => $file) {
			if (!empty($file['hidden']) || !$this->default->mimeAccepted($file['mime'])) {
				unset($files[$i]);
			}
		}
		return array_merge($files, array());
	}
1348636
public function parseFiles($files, $exclude = false)
    {
        $parser = $this->getParser();
        $result = [];
        foreach ($files as $path) {
            if ($exclude && preg_match($exclude, $path)) {
                continue;
            }
            try {
                $code = file_get_contents($path);
                $stmts = $parser->parse($code);
                $result[$path] = new CodeFile($stmts, $path);
            } catch (PhpParserError $e) {
                echo $path, ' Line ', $e->getLine(), ":\n";
                echo 'Parse Error: ', $e->getRawMessage();
                echo "\n";
            }
        }
        $this->_files = $result + $this->_files;
        return $result;
    }
990561
public function createForDocumentation(array $files): array
    {
        if (in_array(Constants::TEST_TYPE_DOCUMENTATION, $this->types)) {
            $definitions = [];
            foreach ($files as $file) {
                $key = $this->getTestGroupNameForDocumentationFile($file);
                $definitions[$key] = $this->collectDefinitionsForFile($file);
            }

            return $definitions;
        }

        return [];
    }
126813
public function build(array $files)
    {
        $processed = array();

        foreach ($files as $file) {
            if ($this->parser->supports($file)) {
                $metadata = $this->parser->parse($file);
                $map = $this->buildMap($metadata);

                $processed[$map->getClass()] = $map;
            }
        }

        return $processed;
    }