public static function fromGlobals(
        array $server = null,
        array $query = null,
        array $body = null,
        array $cookies = null,
        array $files = null
    ) {
        $server  = \Zend\Diactoros\normalizeServer($server ?: $_SERVER);
        $files   = \Zend\Diactoros\normalizeUploadedFiles($files ?: $_FILES);
        $headers = [];
        foreach ($server as $key => $value) {
            if (strpos($key, 'REDIRECT_') === 0) {
                $key = substr($key, 9);
                if (array_key_exists($key, $server)) {
                    continue;
                }
            }
            if (is_string($value) && strlen($value) && strpos($key, 'HTTP_') === 0) {
                $name = strtr(strtolower(substr($key, 5)), '_', '-');
                $headers[$name] = $value;
                continue;
            }
            if (is_string($value) && strlen($value) && strpos($key, 'CONTENT_') === 0) {
                $name = 'content-' . strtolower(substr($key, 8));
                $headers[$name] = $value;
                continue;
            }
        }

        $method  = \Zend\Diactoros\marshalMethodFromSapi($server);
        $uri     = \Zend\Diactoros\marshalUriFromSapi($server, $headers);

        if (null === $cookies && array_key_exists('cookie', $headers)) {
            $cookies = self::parseCookieHeader($headers['cookie']);
        }
        

        if ($body === null) {
            $body = [];
            if (isset($headers['content-type']) && strpos($headers['content-type'], 'json') !== false) {
                $body = json_decode($body, true);
                if ($body === null) {
                    $body = [];
                }
            } else {
                $body = static::fixedQueryParams(file_get_contents('php://input'));
            }
        }

        return new static(
            $server,
            $files,
            $uri,
            $method,
            'php://input',
            $headers,
            $cookies ?: $_COOKIE,
            $query ?: static::fixedQueryParams($uri->getQuery()),
            $body ?: (count($_POST) ? $_POST : json_decode(file_get_contents('php://input'), true)),
            \Zend\Diactoros\marshalProtocolVersionFromSapi($server)
        );
    }
public static function fromGlobals(
        array $server = null,
        array $query = null,
        array $body = null,
        array $cookies = null,
        array $files = null
    ) {
        $server  = \Zend\Diactoros\normalizeServer($server ?: $_SERVER);
        $files   = \Zend\Diactoros\normalizeUploadedFiles($files ?: $_FILES);
        $headers = [];
        foreach ($server as $key => $value) {
            if (strpos($key, 'REDIRECT_') === 0) {
                $key = substr($key, 9);
                if (array_key_exists($key, $server)) {
                    continue;
                }
            }
            if (is_string($value) && strlen($value) && strpos($key, 'HTTP_') === 0) {
                $name = strtr(strtolower(substr($key, 5)), '_', '-');
                $headers[$name] = $value;
                continue;
            }
            if (is_string($value) && strlen($value) && strpos($key, 'CONTENT_') === 0) {
                $name = 'content-' . strtolower(substr($key, 8));
                $headers[$name] = $value;
                continue;
            }
        }

        $method  = \Zend\Diactoros\marshalMethodFromSapi($server);
        $uri     = \Zend\Diactoros\marshalUriFromSapi($server, $headers);

        if (null === $cookies && array_key_exists('cookie', $headers)) {
            $cookies = self::parseCookieHeader($headers['cookie']);
        }
        

        if ($body === null) {
            $body = [];
            if (isset($headers['content-type']) && strpos($headers['content-type'], 'json') !== false) {
                $body = json_decode($body, true);
                if ($body === null) {
                    $body = [];
                }
            } else {
                $body = static::fixedQueryParams(file_get_contents('php://input'));
            }
        }

        return new static(
            $server,
            $files,
            $uri,
            $method,
            'php://input',
            $headers,
            $cookies ?: $_COOKIE,
            $query ?: static::fixedQueryParams($uri->getQuery()),
            $body ?: (count($_POST) ? $_POST : json_decode(file_get_contents('php://input'), true)),
            \Zend\Diactoros\marshalProtocolVersionFromSapi($server)
        );
    }
public static function fromGlobals ( array $ server = null , array $ query = null , array $ body = null , array $ cookies = null , array $ files = null ) { $ server = \ Zend \ Diactoros \ normalizeServer ( $ server ? : $ _SERVER ) ; $ files = \ Zend \ Diactoros \ normalizeUploadedFiles ( $ files ? : $ _FILES ) ; $ headers = [ ] ; foreach ( $ server as $ key => $ value ) { if ( strpos ( $ key , 'REDIRECT_' ) === 0 ) { $ key = substr ( $ key , 9 ) ; if ( array_key_exists ( $ key , $ server ) ) { continue ; } } if ( is_string ( $ value ) && strlen ( $ value ) && strpos ( $ key , 'HTTP_' ) === 0 ) { $ name = strtr ( strtolower ( substr ( $ key , 5 ) ) , '_' , '-' ) ; $ headers [ $ name ] = $ value ; continue ; } if ( is_string ( $ value ) && strlen ( $ value ) && strpos ( $ key , 'CONTENT_' ) === 0 ) { $ name = 'content-' . strtolower ( substr ( $ key , 8 ) ) ; $ headers [ $ name ] = $ value ; continue ; } } $ method = \ Zend \ Diactoros \ marshalMethodFromSapi ( $ server ) ; $ uri = \ Zend \ Diactoros \ marshalUriFromSapi ( $ server , $ headers ) ; if ( null === $ cookies && array_key_exists ( 'cookie' , $ headers ) ) { $ cookies = self :: parseCookieHeader ( $ headers [ 'cookie' ] ) ; } if ( $ body === null ) { $ body = [ ] ; if ( isset ( $ headers [ 'content-type' ] ) && strpos ( $ headers [ 'content-type' ] , 'json' ) !== false ) { $ body = json_decode ( $ body , true ) ; if ( $ body === null ) { $ body = [ ] ; } } else { $ body = static :: fixedQueryParams ( file_get_contents ( 'php://input' ) ) ; } } return new static ( $ server , $ files , $ uri , $ method , 'php://input' , $ headers , $ cookies ? : $ _COOKIE , $ query ? : static :: fixedQueryParams ( $ uri -> getQuery ( ) ) , $ body ? : ( count ( $ _POST ) ? $ _POST : json_decode ( file_get_contents ( 'php://input' ) , true ) ) , \ Zend \ Diactoros \ marshalProtocolVersionFromSapi ( $ server ) ) ; }
Create an instance from globals

@param array $server
@param array $query
@param array $body
@param array $cookies
@param array $files
@return Request
Create an instance from globals