Normalize files array.
@param  array $files
@return array
181189
public static function normalizeFilesArray(array $files): array
    {
        $return = [];
        foreach ($files as $i => $file) {
            foreach ($file as $key => $value) {
                $return[$key][$i] = $value;
            }
        }

        return $return;
    }
431566
protected static function normalizeNested(array $files)
    {
        $normalized = [];
        foreach (array_keys($files['tmp_name']) as $key) {
            $spec = [
                'name'     => $files['name'][$key],
                'tmp_name' => $files['tmp_name'][$key],
                'type'     => $files['type'][$key],
                'size'     => $files['size'][$key],
                'error'    => $files['error'][$key],
            ];
            $normalized[$key] = static::build($spec);
        }

        return $normalized;
    }
717582
protected static function getFlattenFileData(array $files = [])
    {
        $return = [];

        foreach (array_keys($files['tmp_name']) as $key) {
            $file = [
                'tmp_name' => $files['tmp_name'][$key],
                'size' => $files['size'][$key],
                'error' => $files['error'][$key],
                'name' => $files['name'][$key],
                'type' => $files['type'][$key],
            ];

            $return[$key] = self::createUploadedFile($file);
        }

        return $return;
    }
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;
    }
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;
    }
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;
	}
731245
public function normalizeMounts(array $mounts)
    {
        $normalized = [];
        foreach ($mounts as $path => $definition) {
            $normalized[$this->normalizeRelativePath($path)] = $this->normalizeDefinition($definition);
        }

        return $normalized;
    }
491772
public function normalizeArray($objects)
    {
        $normal = [];
        foreach ($objects as $i => $objectName) {
            $config = [];
            if (!is_int($i)) {
                $config = (array)$objectName;
                $objectName = $i;
            }
            list(, $name) = pluginSplit($objectName);
            if (isset($config['class'])) {
                $normal[$name] = $config;
            } else {
                $normal[$name] = ['class' => $objectName, 'config' => $config];
            }
        }

        return $normal;
    }
189847
public function commonDir(array $files)
    {
        $files = array_values($files);
        $cut = 0;
        $count = count($files);
        $shortest = min(array_map('mb_strlen', $files));
        while ($cut < $shortest) {
            $char = $files[0][$cut];
            for ($i = 1; $i < $count; ++$i) {
                if ($files[$i][$cut] !== $char) {
                    break 2;
                }
            }
            ++$cut;
        }
        $dir = mb_substr($files[0], 0, $cut);
        if (false !== $slash = mb_strrpos($dir, '/')) {
            $dir = mb_substr($dir, 0, $slash + 1);
        } elseif (false !== $slash = mb_strrpos($dir, '\\')) {
            $dir = mb_substr($dir, 0, $slash + 1);
        } else {
            $dir = ''; // no common folder
        }

        return $dir; // with trailing slash (if any)
    }
1152698
private static function normalizeSuperglobal(array $files) : array
    {
        $result = [];

        foreach ($files as $file) {
            $keys = array_keys($file);

            if (is_array($keys)) {
                foreach ($keys as $key) {
                    $result[$key] = [];
                    foreach ($files as $index => $file) {
                        $result[$key][$index] = $file[$key];
                    }
                }
            }

            // Only one of the entries was needed to get the PHP upload keys (name, tmp_name, etc.).
            break;
        }

        return $result;
    }
755367
public static function convert($files)
    {
        $result = array();
        foreach ($files as $key => $file) {
            if (isset($file['tmp_name'])) {
                if (is_string($file['tmp_name'])) {
                    $result[$key] = new UploadedFile($file);
                    continue;
                }
                if (is_array($file['tmp_name'])) {
                    if (isset($file['tmp_name'][0]) and is_string($file['tmp_name'][0])) {
                        $result[$key] = array();
                        foreach ($file['tmp_name'] as $offset => $tmpName) {
                            $result[$key][] = new UploadedFile($file, $offset);
                        }
                        continue;
                    }
                }
            }
            $result[$key] = self::convert($file);
        }
        return $result;
    }
1105759
private function getTableRows($files)
    {
        $rows = [];

        foreach ($files as $file => $keys) {
            $rows[] = [count($keys), $file];
        }

        return $rows;
    }
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;
	}
780887
protected function getFiles( array $files )
	{
		$list = [];

		foreach( $files as $key => $value )
		{
			if( $value instanceof \Symfony\Component\HttpFoundation\File\UploadedFile )
			{
				$list[$key] = new \Zend\Diactoros\UploadedFile(
					$value->getRealPath(),
					$value->getSize(),
					$value->getError(),
					$value->getClientOriginalName(),
					$value->getClientMimeType()
				);
			}
			elseif( is_array( $value ) )
			{
				$list[$key] = $this->getFiles( $value );
			}
		}

		return $list;
	}
1341850
protected function loadBaseConfig(array $files) : array
    {
        $config = [];
        foreach ($files as $file) {
            if (file_exists($file = Yii::getAlias($file))) {
                $config = ArrayHelper::merge($config, (array) require $file);
            }
        }
        return $config;
    }
408645
public function setFiles(array $files) {
        if(!$this->setModified('files', $files)->isModified()) {
            return $this;
        }
		$this->files = $files;
		return $this;
    }
734121
public function setFiles($files = array())
    {
        if (count($files) === 0) {
            $this->_files = $_FILES;
        } else {
            $this->_files = $files;
        }

        foreach($this->_files as $file => $content) {
            if (!isset($content['error'])) {
                unset($this->_files[$file]);
            }
        }

        return $this;
    }