Normalize global $_FILES
@param array $files
@return array
550103
protected static function parseFiles(array $files)
    {
        $normalizedFiles = array();

        foreach($files as $name => $file)
        {
            if(is_array($file) && !isset($file['tmp_name']))
                $normalizedFiles[$name] = static::parseFiles($file);
            else if(isset($file['tmp_name']) && is_array($file['tmp_name']))
                $normalizedFiles[$name] = static::normalizeFilesTree($file);
            else if(isset($file['tmp_name']))
                $normalizedFiles[$name] = new static(
                    $file['name'], $file['type'], $file['tmp_name'], $file['error'], $file['size']
                    );
        }

        return $normalizedFiles;
    }
987825
public function deleteFiles(array $files) : bool
    {
        if (empty($files)) {
            return false;
        }

        $status = true;

        foreach ($files as $file) {
            if (file_exists($file)) {
                $status = $status && unlink($file);
            }
        }

        return $status;
    }
607083
private function SortFilesByVersion(array $files)
    {
        $result = array();
        $foreignKeysFile = '';
        foreach ($files as $file)
        {
            if ($file == 'foreign-keys.sql')
            {
                $foreignKeysFile = $file;
                continue;
            }
            $version = Path::RemoveExtension($file);
            if ($this->installedVersion && version_compare($version, $this->installedVersion) <= 0)
            {
                continue;
            }
            $result[$version] = $file;
        }
        uksort($result, "version_compare");
        if ($foreignKeysFile)
        {
            $result[] = $foreignKeysFile;
        }
        return $result;
    }
731245
public function normalizeMounts(array $mounts)
    {
        $normalized = [];
        foreach ($mounts as $path => $definition) {
            $normalized[$this->normalizeRelativePath($path)] = $this->normalizeDefinition($definition);
        }

        return $normalized;
    }
1179985
public function requireFiles(array $files)
    {
        $path = $this->getPath();
        foreach ($files as $file) {
            $this->laravel['files']->requireOnce($path . '/' . $file . '.php');
        }
    }
208985
function setFiles($files)
    {
        $this->files = \Poirot\Http\Psr\normalizeFiles($files);
        return $this;
    }
7079
public function delete(array $files)
    {
        $filesystem = $this->getFilesystem($this->field, $this->settings);
        $results = [];
        foreach ($files as $path) {
            $results[] = $this->deletePath($filesystem, $path);
        }

        return $results;
    }
719752
private function parseJson(array $files)
    {
        $fixable = 0;
        foreach ($files as $file) {
            foreach ($file['messages'] as $message) {
                if ($message['fixable']) {
                    $fixable++;
                    break;
                }
            }
        }
        return PHP_EOL . json_encode([
            'totals' => [
                'fixable' => $fixable
            ],
            'files' => $files
        ]);
    }
1345616
protected function deletingFilesNamesList($files) : array
	{
		return $files->flatMap(function($item) {
			$path_parts = pathinfo($item);
			$result[] = $path_parts['filename'];

			return $result;
		})->filter(function($item) {
			return trim($item) != '';
		})->all();
	}
391442
final public static function normalizeUploads(): Array
	{
		$files = [];

		foreach($_FILES as $name => $value) {
			$file_post = $_FILES[$name];
			if (
				array_key_exists('name', $file_post)
				and is_array($file_post['name'])
			) {
				$file_count = count($file_post['name']);
				$file_keys = array_keys($file_post);

				for ($i = 0; $i < $file_count; $i++) {
					foreach ($file_keys as $key) {
						$files[$name][$i][$key] = $file_post[$key][$i];
					}
				}
			} else {
				$files[$name] = [$value];
			}
		}

		return $files;
	}
1359152
public function createUploadedFileFromServer(array $files)
        {
            $normalized = [];
            foreach ($files as $key => $value) {
                
                if (!isset($value['error'])) {
                    if (is_array($value)) {
                        $normalized[$key] = $this->createUploadedFileFromServer($value);
                    }
                    continue;
                }
                
                $normalized[$key] = [];
                if (!is_array($value['error'])) {

                    if ($value['error'] === 4) {
                        $stream = (new StreamFactory)->createStream('');
                    } else {
                        $stream = (new StreamFactory)->createStreamFromFile($value['tmp_name'], 'r');    
                    }
                    
                    $normalized[$key] = $this->createUploadedFile(
                        $stream,
                        $value['size'],
                        $value['error'],
                        $value['name'],
                        $value['type']
                    );

                } else {

                    $sub = [];
                    foreach ($value['error'] as $id => $error) {
   
                        $sub[$id]['name']     = $value['name'][$id];
                        $sub[$id]['type']     = $value['type'][$id];
                        $sub[$id]['tmp_name'] = $value['tmp_name'][$id];
                        $sub[$id]['error']    = $value['error'][$id];
                        $sub[$id]['size']     = $value['size'][$id];
                        
                        $normalized[$key] = $this->createUploadedFileFromServer($sub);
                    
                    }

                }

            }
            return $normalized;
        }
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;
	}
437345
public function loadFiles($files)
    {
        $files = (array) $files;

        $success = true;
        foreach ($files as $file) {

            $this->loadFile($file);
        }
        return true;
    }
502180
public function buildUserConfigs(array $files): array
    {
        $resolver = new Resolver($files);
        $files = $resolver->get();
        foreach ($files as $name => $paths) {
            $this->getConfig($name)->load($paths)->build()->write();
        }

        return $files;
    }
31950
public function load(array $files = array())
    {
        $loader = new YamlLoader(new FileLocator, new YamlParser);

        foreach ($files as $file) {
            $configValues = $loader->load($file);

            $configValues = $this->loadImports($loader, $file, $configValues);

            $this->params = array_replace_recursive($this->params, $configValues);
        }
    }
316714
protected function getFilePayload(?array $files) : ?array
    {
        if (empty($files)) {
            return null;
        }

        $files = array_filter($files, function($file) {
            return $file instanceof ResourceSettings || (isset($file['key']) && isset($file['filename']));
        });

        return $files;
    }
178622
private function sanitizeFilenames(array $files, $version)
    {
        $filesWithoutVersion = array_map(function ($file) use ($version) {
            if (preg_match('/\?' . preg_quote($version, '/') . '$/', $file)) {
                return substr($file, 0, -(strlen($version) + 1));
            }

            return $file;
        }, $files);

        return $filesWithoutVersion;
    }