Converts the $_FILES array to an array of UploadedFile objects.

@param  array $files File upload array
@return array
963059
protected function convertToUploadedFileObjects(array $files): array
	{
		$uploadedFiles = [];

		foreach($files as $name => $file)
		{
			if(is_array($file['name']))
			{
				foreach($this->normalizeMultiUpload($file) as $file)
				{
					$uploadedFiles[$name][] = $this->createUploadedFile($file);
				}
			}
			else
			{
				$uploadedFiles[$name] = $this->createUploadedFile($file);
			}
		}

		return $uploadedFiles;
	}
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;
    }
953179
public function set(array $files)
    {
        if (!empty($files)) {
            foreach ($files as $_file) {
                if (is_array($_file) && isset($_file['file'])) {
                    $this->add(
                        $_file['file'],
                        isset($_file['media']) ? $_file['media'] : '',
                        isset($_file['condition']) ? $_file['condition'] : null
                    );
                } elseif (is_string($_file)) {
                    $this->add($_file);
                }
            }
        }
        return $this;
    }
1089630
private function removeBrokenFiles(array $files)
    {
        // Recursive logic to replace broken arrays with empty ones (which to be removed later)
        if (isset($files['error'])) {
            return $files['error'] == 4 ? array() : $files;
        }

        foreach ($files as $key => $value) {
            // Recursive call
            $files[$key] = call_user_func(array($this, __FUNCTION__), $value);
        }

        // Now remove empty arrays
        return array_filter($files);
    }
374756
private static function convertFilesArray($files) {
		
		$result = [];

		foreach($files as $field => $data) {
			
			foreach($data as $key => $val) {
				
				$result[$field] = [];
				
				if(false === is_array($val)) {
					$result[$field] = $data;
				} 
				else {
					
					$res = [];
					static :: filesFlip($res, [], $data);
					$result[$field] += $res;
				}
			}
		}

		return $result;
	}
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;
    }
1138045
public function addServersFromFiles($files = [])
    {

        // Since we expect an array let us turn a string (i.e. single file) into an array
        if (!is_array($files)) {
            $files = [$files];
        }

        // Iterate over the file(s) and add them
        foreach ($files as $file) {
            // Check to make sure the file exists and we can read it
            if (!file_exists($file) || !is_readable($file)) {
                continue;
            }

            // See if this file is JSON
            if (($servers = json_decode(file_get_contents($file), true)) === null
                && json_last_error() !== JSON_ERROR_NONE
            ) {
                // Type not supported
                continue;
            }

            // Add this list of servers
            $this->addServers($servers);
        }

        return $this;
    }
1338231
protected function convertFileInformation($file)
    {
        if ($file instanceof UploadedFile) {
            return $file;
        }

        $file = $this->fixPhpFilesArray($file);
        if (\is_array($file)) {
            $keys = array_keys($file);
            sort($keys);

            if ($keys == self::$fileKeys) {
                if (UPLOAD_ERR_NO_FILE == $file['error']) {
                    $file = null;
                } else {
                    $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error']);
                }
            } else {
                $file = array_map([$this, 'convertFileInformation'], $file);
                if (array_keys($keys) === $keys) {
                    $file = array_filter($file);
                }
            }
        }

        return $file;
    }
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;
    }
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;
    }
1362544
protected function prepareFiles(array $files)
    {
        $prepared = array();
        foreach ($files as $file) {

            $type = $file->getType();
            $path = $file->getRealPath();
            $relative_path = gplcart_file_relative($path);

            $item = array(
                'info' => $file,
                'type' => $type,
                'path' => $relative_path,
                'owner' => fileowner($path),
                'extension' => $file->getExtension(),
                'size' => gplcart_file_size($file->getSize()),
                'command' => $type === 'dir' ? 'list' : 'read',
                'commands' => $this->command->getAllowed($file),
                'permissions' => gplcart_file_perms($file->getPerms())
            );

            $prepared[$relative_path] = $item;
            $prepared[$relative_path]['icon'] = $this->renderIcon($item);
        }

        return $prepared;
    }
759871
public function createUploadedFiles(array $files){
        $instances = [];

        foreach($files as $name => $value){
            if($value instanceof UploadedFileInterface){
                $instances[$name]  = $value;
                continue;
            }

            if(!is_array($value)){
                $class  = UploadedFileInterface::class;

                throw new \InvalidArgumentException(
                    "The file list must be an associative array whose value is"
                    . " an instance of a class implementing {$class} or an array"
                    . " having file information."
                    . " But the value of index A does not apply to them."
                );
            }

            $instances[$name]  = isset($value["error"]) && isset($value["tmp_name"])
                ? $this->createUploadedFileWithNest($value)
                : $this->createUploadedFiles($value)
            ;
        }

        return $instances;
    }
250391
public static function js_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 JS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."\n\n";
                continue;
            }
            $compressed[] = self::js($content);
        }

        return implode(";\n", $compressed);
    }
954029
public function handleFiles(array $files): array
    {
        $this->removeOldFiles();
        $metadata = [];
        foreach ($files as $file) {
            /**@var $file  UploadedFile */
            if ($file->getError() == UPLOAD_ERR_OK) {
                $originalName = $file->getClientOriginalName();
                $extension = $file->getClientOriginalExtension();
                /**@var $newFile  File */
                if ($newFile = $file->move($this->uploadDir, md5(time().basename($originalName)) . '.' . $extension)) {
                    $metadata[$originalName] = [
                        'host_url'    => $this->hostUrl,
                        'path'        => $newFile->getPathname(),
                        'origin_name' => $originalName,
                        'type'        => $newFile->getMimeType(),
                        'size'        => $newFile->getSize(),
                        'extension'   => $extension
                    ];
                } else {
                    throw new FileUploadException('File upload error');
                }
            }
        }

        return $metadata;
    }
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;
	}
427871
public static function file2array($file)
    {
        $aFile = [];
        if ($file instanceof UploadedFile) {
            $aFile = file($file->getRealPath());
        } elseif (is_array($file) && isset($file[0]) && is_string($file[0])) {
            $aFile = $file;
        } elseif (is_string($file) && is_file($file) && file_exists($file)) {
            $aFile = file($file);
        } elseif (is_string($file) && strstr($file, PHP_EOL) !== false) {
            $file_content = explode(PHP_EOL, $file);
            if (empty(end($file_content))) {
                array_pop($file_content);
            }
            reset($file_content);
            $aFile = $file_content;
        }

        return array_map('\ForceUTF8\Encoding::toUTF8', $aFile);
    }
361799
protected static function normalize(array $files)
    {
        $normalized = [];
        foreach ($files as $key => $value) {
            if ($value instanceof UploadedFileInterface) {
                $normalized[$key] = $value;

                continue;
            }

            if (! is_array($value)) {
                throw new InvalidArgumentException(
                    'Invalid value in files specification.'
                );
            }

            if (isset($value['tmp_name'])) {
                $normalized[$key] = static::build($value);

                continue;
            }

            $normalized[$key] = static::normalize($value);
        }

        return $normalized;
    }