public function createServerRequestFromArray(?array $server)
  {
    global $app;

    # Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
    # paramter, so we use that instead of the $_SERVER array guzzle uses by default

    $method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
    $headers = \function_exists('getallheaders') ? \getallheaders() : [];
    $uri = ServerRequest::getUriFromGlobals();
    $body = new LazyOpenStream('php://input', 'r+');
    $protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';

    $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $server);

    \logger()->debug('Created PSR-7 ServerRequest("'.$method.'","'.$uri.'") from array (Guzzle)');

    return $serverRequest
           ->withCookieParams($_COOKIE)
           ->withQueryParams($_GET)
           ->withParsedBody($_POST)
           ->withUploadedFiles(ServerRequest::normalizeFiles($_FILES));
  }
public function createServerRequestFromArray(?array $server)
  {
    global $app;

    # Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
    # paramter, so we use that instead of the $_SERVER array guzzle uses by default

    $method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
    $headers = \function_exists('getallheaders') ? \getallheaders() : [];
    $uri = ServerRequest::getUriFromGlobals();
    $body = new LazyOpenStream('php://input', 'r+');
    $protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';

    $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $server);

    \logger()->debug('Created PSR-7 ServerRequest("'.$method.'","'.$uri.'") from array (Guzzle)');

    return $serverRequest
           ->withCookieParams($_COOKIE)
           ->withQueryParams($_GET)
           ->withParsedBody($_POST)
           ->withUploadedFiles(ServerRequest::normalizeFiles($_FILES));
  }
public function createServerRequestFromArray ( ? array $ server ) { global $ app ; # Copied from Guzzles ::fromGlobals(), but we need to support the $server array as # paramter, so we use that instead of the $_SERVER array guzzle uses by default $ method = isset ( $ server [ 'REQUEST_METHOD' ] ) ? $ server [ 'REQUEST_METHOD' ] : 'GET' ; $ headers = \ function_exists ( 'getallheaders' ) ? \ getallheaders ( ) : [ ] ; $ uri = ServerRequest :: getUriFromGlobals ( ) ; $ body = new LazyOpenStream ( 'php://input' , 'r+' ) ; $ protocol = isset ( $ server [ 'SERVER_PROTOCOL' ] ) ? \ str_replace ( 'HTTP/' , '' , $ server [ 'SERVER_PROTOCOL' ] ) : '1.1' ; $ serverRequest = new ServerRequest ( $ method , $ uri , $ headers , $ body , $ protocol , $ server ) ; \ logger ( ) -> debug ( 'Created PSR-7 ServerRequest("' . $ method . '","' . $ uri . '") from array (Guzzle)' ) ; return $ serverRequest -> withCookieParams ( $ _COOKIE ) -> withQueryParams ( $ _GET ) -> withParsedBody ( $ _POST ) -> withUploadedFiles ( ServerRequest :: normalizeFiles ( $ _FILES ) ) ; }
Create a new server request from server variables array

@param      array                   $server  Typically $_SERVER or similar
array

@return     ServerRequestInterface

@throws     \InvalidArgumentException  If no valid method or URI can be determined.
Create a new server request from server variables array