/**
  * Create a request from the supplied superglobal values.
  *
  * If any argument is not supplied, the corresponding superglobal value will
  * be used.
  *
  * The ServerRequest created is then passed to the fromServer() method in
  * order to marshal the request URI and headers.
  *
  * @see fromServer()
  * @param array $server $_SERVER superglobal
  * @param array $query $_GET superglobal
  * @param array $body $_POST superglobal
  * @param array $cookies $_COOKIE superglobal
  * @param array $files $_FILES superglobal
  * @return ServerRequest
  * @throws InvalidArgumentException for invalid file values
  */
 public static function fromGlobals(array $server = null, array $query = null, array $body = null, array $cookies = null, array $files = null)
 {
     $server = static::normalizeServer($server ?: $_SERVER);
     $files = static::normalizeFiles($files ?: $_FILES);
     $headers = static::marshalHeaders($server);
     $request = new ServerRequest($server, $files, static::marshalUriFromServer($server, $headers), static::get('REQUEST_METHOD', $server, 'GET'), 'php://input', $headers);
     return $request->withCookieParams($cookies ?: $_COOKIE)->withQueryParams($query ?: $_GET)->withParsedBody($body ?: $_POST);
 }
Пример #2
0
 /**
  * @group 46
  */
 public function testParsedBodyIsNullAtInitialization()
 {
     $request = new ServerRequest();
     $this->assertNull($request->getParsedBody());
 }