Create a normalized tree of UploadedFile instances from the Environment.

@param array $globals The global server variables.

@return UploadedFile[]|UploadedFile[][] A normalized tree
of UploadedFile instances or null if none are provided.
541591
public static function createFromGlobals(array $globals = null) : array
    {
        $globals = $globals === null
            || ! isset($globals[static::GLOBAL_KEY_NAME])
            || ! is_array($globals[static::GLOBAL_KEY_NAME])
            ? (isset($_FILES) ? $_FILES : [])
            : $globals;
        return static::parseFromArrayUploadedFiles($globals);
    }
928038
public function settings(array $settings = null)
    {
        if ($settings !== null) {
            $this->settings = $settings;
        }

        return $this->settings + static::$globalSettings;
    }
875814
public static function createFromGlobals() {
		$request = new static;
		$request->get->setAll($_GET);
		$request->post->setAll($_POST);
		$request->setFiles($_FILES);
		$request->header->setAll(static::getAllHeaders());
		$request->server->setAll($_SERVER);
		$request->cookie->setAll($_COOKIE);
		$request->body = file_get_contents('php://input');

		$server = trim($request->server['SERVER_NAME'], '/');
		if(isset($request->server['SERVER_PORT']) && $request->server['SERVER_PORT'] != '80')
			$server .= ':'.$request->server['SERVER_PORT'];
		if($request->server->has('ORIG_SCRIPT_NAME'))
			$root = dirname($request->server['ORIG_SCRIPT_NAME']);
		else
			$root = dirname($request->server['SCRIPT_NAME']);
		$root = trim($root, '/');

		if($request->header->has('X_ORIGINAL_URL'))
			$url = $request->header['X_ORIGINAL_URL'];
		if($request->header->has('X_REWRITE_URL'))
			$url = $request->header['X_REWRITE_URL'];
		elseif($request->server->has('IIS_WasUrlRewritten'))
			$url = $request->server['IIS_WasUrlRewritten'];
		elseif($request->server->has('REQUEST_URI'))
			$url = $request->server['REQUEST_URI'];
		elseif($request->server->has('ORIG_PATH_INFO'))
			$url = $request->server['ORIG_PATH_INFO'];
		else
			$url = '';
		$url = ltrim($url, '/');
		$parse = parse_url($url);
		if(isset($parse['path']))
			$url = $parse['path'];
		else
			$url = '';
		$root = trim($root, '/');
		$url = preg_replace('/^'.preg_quote($root, '/').'/', '', $url);

		$protocol = $request->server['REQUEST_SCHEME'].'://';

		$request->setURL($server, $root, $url, $protocol);

		return $request;
	}
337956
public function make_section_globals($section) {
		if(!is_null($section) && strlen($section) && in_array($section, $this->get_valid_sections())) {
			foreach($this->fullConfig[$section] as $k=>$parsedValue) {
				//TODO: implement option to set a section/value as a GLOBAL
				$GLOBALS[$k] = $parsedValue;
			}
		}
		else {
			throw InvalidArgumentException("non-existent section, '". $section ."'");
		}
	}
1360211
public function locales(array $locales = null)
    {
        return is_null($locales)
            ? $this->locales
            : ($this->locales = $locales);
    }
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;
    }
11504
public static function createFromStatics(array $statics)
    {
        $mode = false;

        if (isset($statics['enabled_mode'])) {
            $mode = $statics['enabled_mode'];

            if (true === $statics['enabled_mode'] && isset($statics['mode_default'])) {
                $mode = $statics['mode_default'];

                if (PHP_SAPI === 'cli' && !empty($statics['cli_detection']) && isset($statics['mode_default_cli'])) {
                    $mode = $statics['mode_default_cli'];
                }
            }
        }

        if (!$mode) {
            return null;
        }

        if (!isset($statics['renderers'][$mode])) {
            $renderer = new TextRenderer();
        } else {
            /** @var Renderer */
            $renderer = new $statics['renderers'][$mode]();
        }

        return new self(new Parser(), $renderer);
    }
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;
	}
363739
public function loadFromArray(array $locales)
    {
        $this->items = [];

        foreach ($locales as $key => $locale) {
            $this->put($key, Locale::make($key, $locale));
        }

        return $this;
    }
882466
public final function withUploadedFiles(
       array $uploadedFiles): ServerRequestInterface
   {
       foreach ($uploadedFiles as &$value) {
           if (!$value instanceof UploadedFileInterface) {
               throw new InvalidArgumentException(
                   "Can't get instance: "
                 . "must implement UploadedFileInterface");
           }
       }
       return $this->with("uploadedFiles", $uploadedFiles);
   }
1310988
private function getFiles(array $uploadedFiles)
    {
        $files = [];

        foreach ($uploadedFiles as $key => $value) {
            if (null === $value) {
                $files[$key] = new DiactorosUploadedFile(null, 0, UPLOAD_ERR_NO_FILE, null, null);
                continue;
            }
            if ($value instanceof UploadedFile) {
                $files[$key] = $this->createUploadedFile($value);
            } else {
                $files[$key] = $this->getFiles($value);
            }
        }

        return $files;
    }
1074086
protected function normaliseUploadedFile($uploadedFile, $localPath, $visibility)
    {
        list ($parentId, $fileName) = $this->splitPath($localPath);

        if (!($uploadedFile instanceof Google_Service_Drive_DriveFile)) {
            return false;
        }

        $this->cacheFileObjects[$uploadedFile->getId()] = $uploadedFile;
        if (! $this->getFileObject($localPath)) {
            $this->cacheFileObjectsByName[$parentId . '/' . $fileName] = $uploadedFile;
        }
        $result = $this->normaliseObject($uploadedFile, Util::dirname($localPath));

        if ($visibility && $this->setVisibility($localPath, $visibility)) {
            $result['visibility'] = $visibility;
        }

        return $result;
    }
1247289
protected function generateNamespaceTree($namespaces)
    {
        sort($namespaces);

        $result = array();
        foreach ($namespaces as $namespace) {
            if (!$namespace) {
                $namespace = 'global';
            }

            $namespace_list = explode('\\', $namespace);

            $node = &$result;
            foreach ($namespace_list as $singular) {
                if (!isset($node[$singular])) {
                    $node[$singular] = array();
                }

                $node = &$node[$singular];
            }
        }

        return $result;
    }
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;
    }
166340
static public function setNamespaces($nss)
	{
	    static::initNamespace();
	    
	    $nss = (array) $nss;
	    $rnss = [];
	    foreach ($nss as $ns => $path) {
	        if (!is_numeric($ns)) {
	            $ns = static::formatNamespace($ns);
	            static::loader()->setPsr4($ns, $path);
	        } else {
	            $ns = static::formatNamespace($path);
	        }
	        $rnss[] = $ns;
	    }
	    static::$namespaces = array_merge(static::$namespaces, $rnss);
	    return static::$namespaces = array_unique(static::$namespaces);
	}
513949
private function loadResourceFiles($filenames)
    {
        if (!is_array($filenames)) {
            $filenames = array($filenames);
        }

        foreach ($filenames as $glob) {
            $globs = glob(str_replace('[', '[[]', $glob));
            if ($globs) {
                foreach ($globs as $filename) {
                    require_once $filename;
                }
            }
        }
    }
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;
    }